diff --git a/client/src/components/admin/AdminTileGameinfo.vue b/client/src/components/admin/AdminTileGameinfo.vue index 6b672fa..060919d 100644 --- a/client/src/components/admin/AdminTileGameinfo.vue +++ b/client/src/components/admin/AdminTileGameinfo.vue @@ -10,6 +10,12 @@ # Players: {{ players.length }} + + # Quotes played: + + {{ gameinfo.numQuotesTotal - gameinfo.numQuotesLeft }} / {{ gameinfo.numQuotesTotal }} + + diff --git a/server/src/game/getGameInfo.go b/server/src/game/getGameInfo.go index d82562a..4281fb2 100644 --- a/server/src/game/getGameInfo.go +++ b/server/src/game/getGameInfo.go @@ -11,13 +11,17 @@ func (gm *Game) GetGameInfo() *GameInfoJson { } func (gm *Game) initGameInfoJson() *GameInfoJson { + numQuotesLeft, numQuotesTotal := gm.countQuotes() + gm.mu.Lock() defer gm.mu.Unlock() gameInfo := GameInfoJson{ - Name: gm.name, - State: gm.state, - Players: make([]PlayerInfoJson, 0), + Name: gm.name, + State: gm.state, + Players: make([]PlayerInfoJson, 0), + NumQuotesLeft: numQuotesLeft, + NumQuotesTotal: numQuotesTotal, } for _, player := range gm.players { diff --git a/server/src/game/getQuote.go b/server/src/game/getQuote.go index 380e253..4297d64 100644 --- a/server/src/game/getQuote.go +++ b/server/src/game/getQuote.go @@ -27,3 +27,16 @@ func (gm *Game) getAllQuotes() []*quote.Quote { } return quotes } + +func (gm *Game) countQuotes() (int, int) { + allQuotes := gm.getAllQuotes() + numQuotesLeft := 0 + + for _, q := range allQuotes { + if !q.IsPlayed() { + numQuotesLeft++ + } + } + + return numQuotesLeft, len(allQuotes) +} diff --git a/server/src/game/populateSyncDataCb.go b/server/src/game/populateSyncDataCb.go index f44583a..98beb1e 100644 --- a/server/src/game/populateSyncDataCb.go +++ b/server/src/game/populateSyncDataCb.go @@ -25,16 +25,3 @@ func (gm *Game) populateGameInfo() syncdata.GameInfo { NumQuotesTotal: numQuotesTotal, } } - -func (gm *Game) countQuotes() (int, int) { - allQuotes := gm.getAllQuotes() - numQuotesLeft := 0 - - for _, q := range allQuotes { - if !q.IsPlayed() { - numQuotesLeft++ - } - } - - return numQuotesLeft, len(allQuotes) -} diff --git a/server/src/game/struct.go b/server/src/game/struct.go index 503e311..a4a8af2 100644 --- a/server/src/game/struct.go +++ b/server/src/game/struct.go @@ -93,9 +93,11 @@ type PlayerInfoJson struct { } type GameInfoJson struct { - Name string `json:"name"` - State string `json:"state"` - Players []PlayerInfoJson `json:"players"` + Name string `json:"name"` + State string `json:"state"` + Players []PlayerInfoJson `json:"players"` + NumQuotesLeft int `json:"numQuotesLeft"` + NumQuotesTotal int `json:"numQuotesTotal"` } type GameStateJson struct {