collect quotes status added
This commit is contained in:
parent
d783ceba93
commit
b24f222533
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
TMUX_SESSION=knyt
|
||||
TMUX_SESSION=knowyt
|
||||
|
||||
info:
|
||||
@echo available targets:
|
||||
|
18
client/src/components/CollectQuotes.vue
Normal file
18
client/src/components/CollectQuotes.vue
Normal file
@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div class="collect-quotes">
|
||||
<p>collecting ...</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.collect-quotes {
|
||||
font-family: 'Wendy One';
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<nav v-if="isGamemaster" class="gamecontrols">
|
||||
<button @click="collectQuotes">Collect Quotes</button>
|
||||
<button @click="startGame">Start</button>
|
||||
<button @click="continueGame">Continue</button>
|
||||
<button @click="resetGame">Reset Round</button>
|
||||
@ -19,6 +20,9 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
collectQuotes() {
|
||||
this.$engine.collectQuotes()
|
||||
},
|
||||
startGame() {
|
||||
this.$engine.startGame()
|
||||
},
|
||||
|
@ -11,6 +11,7 @@
|
||||
</div>
|
||||
<ReadySet v-if="gameState === 'ready-set'" :text="gamePhase" />
|
||||
<Play v-if="gameState === 'play'" />
|
||||
<CollectQuotes v-if="gameState === 'collect'" />
|
||||
<Final v-if="gameState === 'final'" />
|
||||
</div>
|
||||
</div>
|
||||
|
7
client/src/plugins/engine/collectQuotes.js
Normal file
7
client/src/plugins/engine/collectQuotes.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default async function() {
|
||||
const { store } = this.context
|
||||
|
||||
await this.callApi('/api/collectQuotes', {
|
||||
g: store.state.engine.user?.game,
|
||||
})
|
||||
}
|
@ -3,6 +3,7 @@ import start from './start'
|
||||
import stop from './stop'
|
||||
import fetchUpdate from './fetchUpdate'
|
||||
import fetchUserInfo from './fetchUserInfo'
|
||||
import collectQuotes from './collectQuotes'
|
||||
import startGame from './startGame'
|
||||
import resetGame from './resetGame'
|
||||
import continueGame from './continueGame'
|
||||
@ -22,6 +23,7 @@ export default (context, inject) => {
|
||||
stop,
|
||||
fetchUpdate,
|
||||
fetchUserInfo,
|
||||
collectQuotes,
|
||||
startGame,
|
||||
resetGame,
|
||||
continueGame,
|
||||
|
@ -3,10 +3,10 @@ info:
|
||||
@perl -ne 'm/^([a-zA-Z0-9\-]+):/ && print(" $$1\n");' Makefile
|
||||
|
||||
build:
|
||||
cd src/ && go build -o ../knyt knyt.go
|
||||
cd src/ && go build -o ../knowyt knowyt.go
|
||||
|
||||
run:
|
||||
cd src/ && go run knyt.go
|
||||
cd src/ && go run knowyt.go
|
||||
|
||||
run-loop:
|
||||
pexec -R -c -e TARGET \
|
||||
@ -15,7 +15,7 @@ run-loop:
|
||||
-- $(MAKE) '$$TARGET'
|
||||
|
||||
run-standalone:
|
||||
cd src/ && ../knyt
|
||||
cd src/ && ../knowyt
|
||||
|
||||
_run-endless-loop:
|
||||
while true; do $(MAKE) run || sleep 3; done
|
||||
|
25
server/src/application/collectQuotes.go
Normal file
25
server/src/application/collectQuotes.go
Normal file
@ -0,0 +1,25 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sirlab.de/go/knyt/user"
|
||||
)
|
||||
|
||||
func (app *Application) CollectQuotes(usr *user.User, w http.ResponseWriter, r *http.Request) {
|
||||
gameRef := r.URL.Query().Get("g")
|
||||
gm, err := app.GetGameById(gameRef)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
fmt.Fprintf(w, "game not found")
|
||||
return
|
||||
}
|
||||
|
||||
if usr.GetGameId() != gameRef || !usr.IsGamemaster() {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
fmt.Fprintf(w, "forbidden")
|
||||
return
|
||||
}
|
||||
|
||||
gm.CollectQuotes()
|
||||
}
|
15
server/src/game/collectQuotes.go
Normal file
15
server/src/game/collectQuotes.go
Normal file
@ -0,0 +1,15 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (gm *Game) CollectQuotes() {
|
||||
err := gm.changeGameState(STATE_ANY, STATE_COLLECT, PHASE_NONE)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
gm.notifyClients()
|
||||
}
|
@ -6,8 +6,8 @@ import (
|
||||
|
||||
func (gm *Game) runRound() {
|
||||
state, _ := gm.GetState()
|
||||
if state != STATE_IDLE && state != STATE_PLAY {
|
||||
fmt.Println(fmt.Errorf("expected state \"IDLE\" | \"PLAY\" != \"%s\"", state))
|
||||
if state != STATE_IDLE && state != STATE_PLAY && state != STATE_COLLECT {
|
||||
fmt.Println(fmt.Errorf("expected state \"IDLE\" | \"PLAY\" | \"COLLECT\" != \"%s\"", state))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
|
||||
const (
|
||||
STATE_ANY = "*"
|
||||
STATE_COLLECT = "collect"
|
||||
STATE_IDLE = "idle"
|
||||
STATE_READY_SET = "ready-set"
|
||||
STATE_PLAY = "play"
|
||||
|
@ -23,6 +23,7 @@ func main() {
|
||||
mux.PublicHandleFunc("/api/logout", mux.Logout)
|
||||
mux.PrivateHandleFunc("/api/userinfo", mux.GetUserInfo)
|
||||
mux.PrivateHandleFunc("/api/sync", app.SyncHandler)
|
||||
mux.PrivateHandleFunc("/api/collectQuotes", app.CollectQuotes)
|
||||
mux.PrivateHandleFunc("/api/startGame", app.StartGame)
|
||||
mux.PrivateHandleFunc("/api/resetGame", app.ResetGame)
|
||||
mux.PrivateHandleFunc("/api/continueGame", app.ContinueGame)
|
Loading…
Reference in New Issue
Block a user