feat: show player id, game id on click

This commit is contained in:
Settel 2022-04-12 14:27:49 +02:00
parent 6305c7beda
commit 4c34172e62
5 changed files with 39 additions and 26 deletions

View File

@ -20,6 +20,13 @@
<td><input v-model="authcode" size="6" maxlength="6" /></td> <td><input v-model="authcode" size="6" maxlength="6" /></td>
<td><span class="admin-edit-player__button-generate-code" @click="generateCode">generate code</span></td> <td><span class="admin-edit-player__button-generate-code" @click="generateCode">generate code</span></td>
</tr> </tr>
<tr v-if="!showId">
<td colspan="3" @click="showId=true">&nbsp;</td>
</tr>
<tr v-if="showId">
<td>id: </td>
<td colspan="2">{{ id }}</td>
</tr>
<tr> <tr>
<td colspan="3">&nbsp;</td> <td colspan="3">&nbsp;</td>
</tr> </tr>
@ -40,6 +47,7 @@ export default {
props: ['player'], props: ['player'],
data() { data() {
return { return {
showId: false,
name: '', name: '',
score: 0, score: 0,
authcode: '', authcode: '',

View File

@ -20,6 +20,12 @@
{{ gameinfo.numQuotesTotal - gameinfo.numQuotesLeft }} / {{ gameinfo.numQuotesTotal }} {{ gameinfo.numQuotesTotal - gameinfo.numQuotesLeft }} / {{ gameinfo.numQuotesTotal }}
</td> </td>
</tr> </tr>
<tr v-if="!showId">
<td colspan="3" @click="showId=true">&nbsp;</td>
</tr>
<tr v-if="showId">
<td colspan="3">{{ gameinfo.id }}</td>
</tr>
</table> </table>
</AdminTile> </AdminTile>
</template> </template>
@ -27,6 +33,11 @@
<script> <script>
export default { export default {
props: ['gameinfo', 'players'], props: ['gameinfo', 'players'],
data() {
return {
showId: false,
}
},
methods: { methods: {
async editName() { async editName() {
const name = window.prompt('new game name: ') const name = window.prompt('new game name: ')

View File

@ -17,6 +17,7 @@ func (gm *Game) initGameInfoJson() *GameInfoJson {
defer gm.mu.Unlock() defer gm.mu.Unlock()
gameInfo := GameInfoJson{ gameInfo := GameInfoJson{
Id: gm.id,
Name: gm.name, Name: gm.name,
Created: gm.created, Created: gm.created,
State: gm.state, State: gm.state,
@ -27,14 +28,12 @@ func (gm *Game) initGameInfoJson() *GameInfoJson {
for _, player := range gm.players { for _, player := range gm.players {
gameInfo.Players = append(gameInfo.Players, PlayerInfoJson{ gameInfo.Players = append(gameInfo.Players, PlayerInfoJson{
Id: player.id, Id: player.id,
Name: player.name, Name: player.name,
Created: player.created, Score: player.score,
LastLoggedIn: player.lastLoggedIn, IsPlaying: player.isPlaying,
Score: player.score, IsIdle: player.isIdle,
IsPlaying: player.isPlaying, Role: player.role,
IsIdle: player.isIdle,
Role: player.role,
}) })
} }

View File

@ -62,14 +62,12 @@ func (gm *Game) AddPlayer(usr *user.User) {
} }
gm.players[usrId] = playerInfo{ gm.players[usrId] = playerInfo{
id: usrId, id: usrId,
name: usr.GetName(), name: usr.GetName(),
created: usr.GetCreated(), isPlaying: false,
lastLoggedIn: usr.GetLastLoggedIn(), isIdle: true,
isPlaying: false, score: 0,
isIdle: true, role: usr.GetRole(),
score: 0,
role: usr.GetRole(),
} }
} }
@ -85,8 +83,6 @@ func (gm *Game) UpdatePlayer(usr *user.User) {
} }
player.name = usr.GetName() player.name = usr.GetName()
player.created = usr.GetCreated()
player.lastLoggedIn = usr.GetLastLoggedIn()
gm.players[usrId] = player gm.players[usrId] = player
} }

View File

@ -30,14 +30,12 @@ const (
) )
type playerInfo struct { type playerInfo struct {
id string id string
name string name string
created int64 isPlaying bool
lastLoggedIn int64 isIdle bool
isPlaying bool score int
isIdle bool role string
score int
role string
} }
type Source struct { type Source struct {
@ -99,6 +97,7 @@ type PlayerInfoJson struct {
} }
type GameInfoJson struct { type GameInfoJson struct {
Id string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Created int64 `json:"created"` Created int64 `json:"created"`
State string `json:"state"` State string `json:"state"`