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 { &__container {
position: relative; position: relative;
min-width: 300px; min-width: 300px;
margin: 40px; margin: 16px;
padding: 16px 30px; padding: 16px 30px;
background-color: $admin-tile-background-color; background-color: $admin-tile-background-color;
border: $admin-tile-border; 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"> <AdminInfoTile title="Players" icon-top="reload" @icon-top-click="reload" icon-bottom="add" @icon-bottom-click="addPlayer">
<table class="players-tile__table"> <table class="players-tile__table">
<tr> <tr>
<th class="players-tile__table-head">{{ $t('name') }}:</th> <th class="players-tile__table-head players-tile__cell">{{ $t('name') }}:</th>
<th class="players-tile__table-head">{{ $t('num-quotes') }}</th> <th class="players-tile__table-head players-tile__cell">{{ $t('num-quotes') }}</th>
<th class="players-tile__table-head">{{ $t('score') }}</th> <th class="players-tile__table-head players-tile__cell">{{ $t('score') }}</th>
<th class="players-tile__table-head">{{ $t('last-logged-in') }}</th> <th class="players-tile__table-head players-tile__cell">{{ $t('last-logged-in') }}</th>
</tr> </tr>
<tr v-for="player in players" class="players-tile__row" :key="player.id" @click="editPlayer(player)"> <tr v-for="player in players" class="players-tile__row" :key="player.id" @click="editPlayer(player)">
<td class="players-tile__cell"> <td class="players-tile__cell">
@ -15,7 +15,7 @@
<nuxt-icon name="crown" filled /> <nuxt-icon name="crown" filled />
</div> </div>
</td> </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.score }}</td>
<td class="players-tile__cell">{{ !player.isIdle ? 'online' : player.lastLoggedIn === 0 ? '-' : datetime(player.lastLoggedIn) }}</td> <td class="players-tile__cell">{{ !player.isIdle ? 'online' : player.lastLoggedIn === 0 ? '-' : datetime(player.lastLoggedIn) }}</td>
</tr> </tr>
@ -42,7 +42,7 @@ const emit = defineEmits(['update'])
const { $t } = useI18n({ const { $t } = useI18n({
name: { en: 'Name', de: 'Name' }, name: { en: 'Name', de: 'Name' },
'num-quotes': { en: '# quotes', de: '# Quotes' }, 'num-quotes': { en: '# quotes', de: '# Aussagen gespielt' },
'score': { en: 'Score', de: 'Score' }, 'score': { en: 'Score', de: 'Score' },
'last-logged-in': { en: 'last logged in', de: 'zuletzt eingeloggt' }, 'last-logged-in': { en: 'last logged in', de: 'zuletzt eingeloggt' },
}) })
@ -135,7 +135,7 @@ const playerDialogSubmit = async (action: ButtonAction): Promise<void> => {
} }
&__cell { &__cell {
padding-right: 8px; padding-right: 16px;
} }
&__is-gamemaster { &__is-gamemaster {

View File

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

View File

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

View File

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

View File

@ -5,7 +5,15 @@ func (gm *Game) GetGameInfo() *GameInfoJson {
for i := range gameInfo.Players { for i := range gameInfo.Players {
quotes := gm.getQuotesInfoByUserId(gameInfo.Players[i].Id) 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].NumberOfQuotes = len(quotes)
gameInfo.Players[i].NumberOfQuotesPlayed = numPlayed
} }
return gameInfo return gameInfo
} }

View File

@ -90,16 +90,17 @@ type QuotesInfo struct {
} }
type PlayerInfoJson struct { type PlayerInfoJson struct {
Id string `json:"id"` Id string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Created int64 `json:"created"` Created int64 `json:"created"`
LastLoggedIn int64 `json:"lastLoggedIn"` LastLoggedIn int64 `json:"lastLoggedIn"`
Score int `json:"score"` Score int `json:"score"`
IsPlaying bool `json:"isPlaying"` IsPlaying bool `json:"isPlaying"`
IsIdle bool `json:"isIdle"` IsIdle bool `json:"isIdle"`
NumberOfQuotes int `json:"numQuotes"` NumberOfQuotes int `json:"numQuotes"`
AuthCode string `json:"authcode,omitempty"` NumberOfQuotesPlayed int `json:"numQuotesPlayed"`
Role string `json:"role"` AuthCode string `json:"authcode,omitempty"`
Role string `json:"role"`
} }
type GameInfoJson struct { type GameInfoJson struct {