feat: show number of quotes played by player

This commit is contained in:
Settel 2023-06-19 10:42:00 +02:00
parent fee9caff08
commit 24c93623dc
7 changed files with 30 additions and 18 deletions

View File

@ -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;

View File

@ -3,10 +3,10 @@
<AdminInfoTile title="Players" icon-top="reload" @icon-top-click="reload" icon-bottom="add" @icon-bottom-click="addPlayer">
<table class="players-tile__table">
<tr>
<th class="players-tile__table-head">{{ $t('name') }}:</th>
<th class="players-tile__table-head">{{ $t('num-quotes') }}</th>
<th class="players-tile__table-head">{{ $t('score') }}</th>
<th class="players-tile__table-head">{{ $t('last-logged-in') }}</th>
<th class="players-tile__table-head players-tile__cell">{{ $t('name') }}:</th>
<th class="players-tile__table-head players-tile__cell">{{ $t('num-quotes') }}</th>
<th class="players-tile__table-head players-tile__cell">{{ $t('score') }}</th>
<th class="players-tile__table-head players-tile__cell">{{ $t('last-logged-in') }}</th>
</tr>
<tr v-for="player in players" class="players-tile__row" :key="player.id" @click="editPlayer(player)">
<td class="players-tile__cell">
@ -15,7 +15,7 @@
<nuxt-icon name="crown" filled />
</div>
</td>
<td class="players-tile__cell">{{ player.numQuotes }}</td>
<td class="players-tile__cell">{{ player.numQuotesPlayed }} / {{ player.numQuotes }}</td>
<td class="players-tile__cell">{{ player.score }}</td>
<td class="players-tile__cell">{{ !player.isIdle ? 'online' : player.lastLoggedIn === 0 ? '-' : datetime(player.lastLoggedIn) }}</td>
</tr>
@ -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<void> => {
}
&__cell {
padding-right: 8px;
padding-right: 16px;
}
&__is-gamemaster {

View File

@ -18,6 +18,7 @@ export type PlayerInfo = PlayerEdit & {
lastLoggedIn: number
isPlaying: boolean
numQuotes: number
numQuotesPlayed: number
role: Role
}

View File

@ -24,6 +24,7 @@ await useAuth().authenticateAndLoadUserInfo(['admin'])
&__tiles {
display: flex;
margin: 24px;
}
}
</style>

View File

@ -42,6 +42,7 @@ updateGameinfo()
&__tiles {
display: flex;
margin: 24px;
}
&__tiles-spacer {

View File

@ -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
}

View File

@ -98,6 +98,7 @@ type PlayerInfoJson struct {
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"`
}