feat: gamemaster: show number of quotes already played
This commit is contained in:
parent
fcec00345e
commit
4951f0746f
@ -10,6 +10,12 @@
|
||||
<td># Players:</td>
|
||||
<td colspan="2">{{ players.length }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td># Quotes played:</td>
|
||||
<td colspan="2">
|
||||
{{ gameinfo.numQuotesTotal - gameinfo.numQuotesLeft }} / {{ gameinfo.numQuotesTotal }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</AdminTile>
|
||||
</template>
|
||||
|
@ -11,6 +11,8 @@ func (gm *Game) GetGameInfo() *GameInfoJson {
|
||||
}
|
||||
|
||||
func (gm *Game) initGameInfoJson() *GameInfoJson {
|
||||
numQuotesLeft, numQuotesTotal := gm.countQuotes()
|
||||
|
||||
gm.mu.Lock()
|
||||
defer gm.mu.Unlock()
|
||||
|
||||
@ -18,6 +20,8 @@ func (gm *Game) initGameInfoJson() *GameInfoJson {
|
||||
Name: gm.name,
|
||||
State: gm.state,
|
||||
Players: make([]PlayerInfoJson, 0),
|
||||
NumQuotesLeft: numQuotesLeft,
|
||||
NumQuotesTotal: numQuotesTotal,
|
||||
}
|
||||
|
||||
for _, player := range gm.players {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ type GameInfoJson struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Players []PlayerInfoJson `json:"players"`
|
||||
NumQuotesLeft int `json:"numQuotesLeft"`
|
||||
NumQuotesTotal int `json:"numQuotesTotal"`
|
||||
}
|
||||
|
||||
type GameStateJson struct {
|
||||
|
Loading…
Reference in New Issue
Block a user