knowyt/server/src/game/runRound.go
2021-09-06 21:26:55 +02:00

55 lines
1.5 KiB
Go

package game
import (
"fmt"
)
func (gm *Game) runRound() {
state, _ := gm.GetState()
if state != STATE_IDLE && state != STATE_PLAY {
fmt.Println(fmt.Errorf("expected state \"IDLE\" | \"PLAY\" != \"%s\"", state))
return
}
err := gm.changeGameState(STATE_ANY, STATE_PLAY, PHASE_SELECT_QUOTE)
if err != nil {
fmt.Println(err)
return
}
gm.setupRound()
gm.selectQuote()
gm.notifyClients()
}
func (gm *Game) setupRound() {
gm.mu.Lock()
defer gm.mu.Unlock()
gm.round = Round{
selections: make(map[string]string, 0),
revelation: Revelation{
votes: make(map[string][]string, 0),
},
}
}
func (gm *Game) selectQuote() {
gm.mu.Lock()
defer gm.mu.Unlock()
gm.round.quoteId = "455df6bc-070d-4728-83ab-481ceafa8590"
gm.round.sources = []Source{
{id: "cbc34770-3686-45ee-93bd-c5521e276e21", name: "Herbert Grönemeyer"},
{id: "f0422e15-59c7-480b-adea-9e54f8471f02", name: "Frank Sinatra"},
{id: "22915112-836e-4a11-b66c-a38a0e0f87b2", name: "Gaius Julius Cäsar"},
{id: "f17065b7-88e7-4777-bc48-15770a5b7c83", name: "Thomas Alva Edison"},
{id: "b6b3cd30-1d52-4e62-a0bd-bf3847c5c396", name: "Konfuzius"},
{id: "c3fc2091-ae0e-433d-b4c3-215a5b57b2b7", name: "George W. Bush jun."},
{id: "49514b62-96cf-4ee0-a59a-154c23b7df53", name: "Plato"},
{id: "7545ee0f-0447-4c15-adc2-87d85304aeea", name: "Christoph Kolumbus"},
{id: "dc20b5f1-23bc-4d80-ab2e-f3caa005064a", name: "Neil Armstrong"},
{id: "2b9fbc3c-589f-4176-8708-cc8239e19a4f", name: "Max Planck"},
}
}