From 4f760bb5ed3f0af6dbb8552bf03a56c6c90a840b Mon Sep 17 00:00:00 2001 From: Settel Date: Tue, 1 Mar 2022 12:25:25 +0100 Subject: [PATCH] refactor: admin interface: number of quotes instead of quotes --- client/src/components/admin/AdminTilePlayers.vue | 2 +- server/src/game/getGameInfo.go | 3 ++- server/src/game/struct.go | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client/src/components/admin/AdminTilePlayers.vue b/client/src/components/admin/AdminTilePlayers.vue index 69cca66..3a309ed 100644 --- a/client/src/components/admin/AdminTilePlayers.vue +++ b/client/src/components/admin/AdminTilePlayers.vue @@ -9,7 +9,7 @@ {{ player.name }} - {{ player.quotes.length }} + {{ player.numQuotes }} {{ player.score }} {{ player.isPlaying ? (player.isIdle ? 'idle' : 'active') : '-'}} diff --git a/server/src/game/getGameInfo.go b/server/src/game/getGameInfo.go index 844a44b..0b432e4 100644 --- a/server/src/game/getGameInfo.go +++ b/server/src/game/getGameInfo.go @@ -6,7 +6,8 @@ func (gm *Game) GetGameInfo() *GameInfoJson { gameInfo := gm.initGameInfoJson() for i, _ := range gameInfo.Players { - gameInfo.Players[i].Quotes = gm.getQuotesInfoByUserId(gameInfo.Players[i].Id) + quotes := gm.getQuotesInfoByUserId(gameInfo.Players[i].Id) + gameInfo.Players[i].NumberOfQuotes = len(quotes) } return gameInfo } diff --git a/server/src/game/struct.go b/server/src/game/struct.go index 9865c15..0b972ab 100644 --- a/server/src/game/struct.go +++ b/server/src/game/struct.go @@ -81,12 +81,12 @@ type QuotesInfo struct { } type PlayerInfoJson struct { - Id string `json:"id"` - Name string `json:"name"` - Score int `json:"score"` - IsPlaying bool `json:"isPlaying"` - IsIdle bool `json:"isIdle"` - Quotes []Quote `json:"quotes"` + Id string `json:"id"` + Name string `json:"name"` + Score int `json:"score"` + IsPlaying bool `json:"isPlaying"` + IsIdle bool `json:"isIdle"` + NumberOfQuotes int `json:"numQuotes"` } type GameInfoJson struct {