102 lines
1.9 KiB
Go
102 lines
1.9 KiB
Go
package game
|
|
|
|
import (
|
|
"sirlab.de/go/knowyt/engine"
|
|
"sirlab.de/go/knowyt/quote"
|
|
"sync"
|
|
)
|
|
|
|
const (
|
|
STATE_ANY = "*"
|
|
STATE_COLLECT = "collect"
|
|
STATE_IDLE = "idle"
|
|
STATE_READY_SET = "ready-set"
|
|
STATE_PLAY = "play"
|
|
STATE_FINAL = "final"
|
|
)
|
|
|
|
const (
|
|
PHASE_NONE = ""
|
|
PHASE_SELECT_QUOTE = "select-quote"
|
|
PHASE_REVEAL_START = "reveal-start"
|
|
PHASE_REVEAL_SHOW_COUNT = "reveal-show-count"
|
|
PHASE_REVEAL_SOURCE = "reveal-source"
|
|
PHASE_ROUND_END = "round-end"
|
|
)
|
|
|
|
const (
|
|
PLAYER_SELECTION_EMPTY = ""
|
|
PLAYER_SELECTION_NONE = "-"
|
|
)
|
|
|
|
type playerInfo struct {
|
|
id string
|
|
name string
|
|
isPlaying bool
|
|
isIdle bool
|
|
score int
|
|
}
|
|
|
|
type Source struct {
|
|
id string
|
|
name string
|
|
}
|
|
|
|
type Revelation struct {
|
|
votes map[string][]string
|
|
sources map[string]bool
|
|
}
|
|
|
|
type Round struct {
|
|
quoteId string
|
|
selections map[string]string
|
|
sources []Source
|
|
revelation Revelation
|
|
}
|
|
|
|
type Game struct {
|
|
mu sync.Mutex
|
|
id string
|
|
filename string
|
|
name string
|
|
players map[string]playerInfo
|
|
eng *engine.Engine
|
|
state string
|
|
phase string
|
|
quotes map[string]*quote.Quote
|
|
round Round
|
|
}
|
|
|
|
type GameJson struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type Quote struct {
|
|
Id string `json:"id"`
|
|
Quote string `json:"quote"`
|
|
}
|
|
|
|
type QuotesInfo struct {
|
|
Quotes []Quote `json:"quotes"`
|
|
}
|
|
|
|
type PlayerInfoJson struct {
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
Score int `json:"score"`
|
|
IsPlaying bool `json:"isPlaying"`
|
|
IsIdle bool `json:"isIdle"`
|
|
NumberOfQuotes int `json:"numQuotes"`
|
|
AuthCode string `json:"authcode"`
|
|
}
|
|
|
|
type GameInfoJson struct {
|
|
Name string `json:"name"`
|
|
Players []PlayerInfoJson `json:"players"`
|
|
}
|
|
|
|
type GameStateJson struct {
|
|
Scores map[string]int `json:"scores"`
|
|
QuotesPlayed []string `json:"quotesPlayed"`
|
|
}
|