From 24c93623dcddcd05fe78f147b54349e4919c7d65 Mon Sep 17 00:00:00 2001 From: Settel Date: Mon, 19 Jun 2023 10:42:00 +0200 Subject: [PATCH] feat: show number of quotes played by player --- client/src/components/admin/InfoTile.vue | 2 +- client/src/components/admin/PlayersTile.vue | 14 +++++++------- client/src/composables/engine.d.ts | 1 + client/src/pages/admin.vue | 1 + client/src/pages/gamemaster.vue | 1 + server/src/game/getGameInfo.go | 8 ++++++++ server/src/game/struct.go | 21 +++++++++++---------- 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/client/src/components/admin/InfoTile.vue b/client/src/components/admin/InfoTile.vue index 7127e9c..d8a3861 100644 --- a/client/src/components/admin/InfoTile.vue +++ b/client/src/components/admin/InfoTile.vue @@ -30,7 +30,7 @@ const emit = defineEmits(['icon-top-click', 'icon-bottom-click']) &__container { position: relative; min-width: 300px; - margin: 40px; + margin: 16px; padding: 16px 30px; background-color: $admin-tile-background-color; border: $admin-tile-border; diff --git a/client/src/components/admin/PlayersTile.vue b/client/src/components/admin/PlayersTile.vue index e99310e..8c19dd5 100644 --- a/client/src/components/admin/PlayersTile.vue +++ b/client/src/components/admin/PlayersTile.vue @@ -3,10 +3,10 @@ - - - - + + + + - + @@ -42,7 +42,7 @@ const emit = defineEmits(['update']) const { $t } = useI18n({ name: { en: 'Name', de: 'Name' }, - 'num-quotes': { en: '# quotes', de: '# Quotes' }, + 'num-quotes': { en: '# quotes', de: '# Aussagen gespielt' }, 'score': { en: 'Score', de: 'Score' }, 'last-logged-in': { en: 'last logged in', de: 'zuletzt eingeloggt' }, }) @@ -135,7 +135,7 @@ const playerDialogSubmit = async (action: ButtonAction): Promise => { } &__cell { - padding-right: 8px; + padding-right: 16px; } &__is-gamemaster { diff --git a/client/src/composables/engine.d.ts b/client/src/composables/engine.d.ts index a101441..8b188bd 100644 --- a/client/src/composables/engine.d.ts +++ b/client/src/composables/engine.d.ts @@ -18,6 +18,7 @@ export type PlayerInfo = PlayerEdit & { lastLoggedIn: number isPlaying: boolean numQuotes: number + numQuotesPlayed: number role: Role } diff --git a/client/src/pages/admin.vue b/client/src/pages/admin.vue index 025e6ff..8ae8ef3 100644 --- a/client/src/pages/admin.vue +++ b/client/src/pages/admin.vue @@ -24,6 +24,7 @@ await useAuth().authenticateAndLoadUserInfo(['admin']) &__tiles { display: flex; + margin: 24px; } } \ No newline at end of file diff --git a/client/src/pages/gamemaster.vue b/client/src/pages/gamemaster.vue index 1d698e6..a7f8c9d 100644 --- a/client/src/pages/gamemaster.vue +++ b/client/src/pages/gamemaster.vue @@ -42,6 +42,7 @@ updateGameinfo() &__tiles { display: flex; + margin: 24px; } &__tiles-spacer { diff --git a/server/src/game/getGameInfo.go b/server/src/game/getGameInfo.go index 5d5ac10..8161fbc 100644 --- a/server/src/game/getGameInfo.go +++ b/server/src/game/getGameInfo.go @@ -5,7 +5,15 @@ func (gm *Game) GetGameInfo() *GameInfoJson { for i := range gameInfo.Players { quotes := gm.getQuotesInfoByUserId(gameInfo.Players[i].Id) + numPlayed := 0 + for j := range quotes { + if quotes[j].IsPlayed { + numPlayed++ + } + } + gameInfo.Players[i].NumberOfQuotes = len(quotes) + gameInfo.Players[i].NumberOfQuotesPlayed = numPlayed } return gameInfo } diff --git a/server/src/game/struct.go b/server/src/game/struct.go index 8377aa7..8e6fb0f 100644 --- a/server/src/game/struct.go +++ b/server/src/game/struct.go @@ -90,16 +90,17 @@ type QuotesInfo struct { } type PlayerInfoJson struct { - Id string `json:"id"` - Name string `json:"name"` - Created int64 `json:"created"` - LastLoggedIn int64 `json:"lastLoggedIn"` - Score int `json:"score"` - IsPlaying bool `json:"isPlaying"` - IsIdle bool `json:"isIdle"` - NumberOfQuotes int `json:"numQuotes"` - AuthCode string `json:"authcode,omitempty"` - Role string `json:"role"` + Id string `json:"id"` + Name string `json:"name"` + Created int64 `json:"created"` + LastLoggedIn int64 `json:"lastLoggedIn"` + Score int `json:"score"` + IsPlaying bool `json:"isPlaying"` + IsIdle bool `json:"isIdle"` + NumberOfQuotes int `json:"numQuotes"` + NumberOfQuotesPlayed int `json:"numQuotesPlayed"` + AuthCode string `json:"authcode,omitempty"` + Role string `json:"role"` } type GameInfoJson struct {
{{ $t('name') }}:{{ $t('num-quotes') }}{{ $t('score') }}{{ $t('last-logged-in') }}{{ $t('name') }}:{{ $t('num-quotes') }}{{ $t('score') }}{{ $t('last-logged-in') }}
@@ -15,7 +15,7 @@ {{ player.numQuotes }}{{ player.numQuotesPlayed }} / {{ player.numQuotes }} {{ player.score }} {{ !player.isIdle ? 'online' : player.lastLoggedIn === 0 ? '-' : datetime(player.lastLoggedIn) }}