update score

This commit is contained in:
Settel 2021-09-17 23:21:06 +02:00
parent f65a5ca2a2
commit dfda2d25cf
5 changed files with 20 additions and 1 deletions

View File

@ -18,6 +18,7 @@ func (gm *Game) EventPlayerJoins(usr *user.User) {
name: usrName,
isPlaying: true,
isIdle: false,
score: prevPlayer.score,
}
gm.players[usrId] = player
@ -64,5 +65,6 @@ func (gm *Game) AddPlayer(usr *user.User) {
name: usr.GetName(),
isPlaying: false,
isIdle: true,
score: 7,
}
}

View File

@ -13,6 +13,7 @@ func (gm *Game) populateGetPlayers() []syncdata.PlayerInfo {
Id: p.id,
Name: p.name,
IsIdle: p.isIdle,
Score: p.score,
})
}
}

View File

@ -15,7 +15,21 @@ func (gm *Game) revealSource() {
gm.round.revelation.sources[source.id] = false
}
quote := gm.quotes[gm.round.quoteId]
gm.round.revelation.sources[quote.GetSourceId()] = true
sourceId := quote.GetSourceId()
gm.round.revelation.sources[sourceId] = true
for _, p := range gm.players {
selId := gm.round.selections[p.id]
if selId == PLAYER_SELECTION_EMPTY || selId == PLAYER_SELECTION_NONE {
continue
} else if selId == sourceId {
p.score += 10
} else {
p.score -= 3
}
gm.players[p.id] = p
}
gm.mu.Unlock()
gm.notifyClients()

View File

@ -31,6 +31,7 @@ type playerInfo struct {
name string
isPlaying bool
isIdle bool
score int
}
type Source struct {

View File

@ -10,6 +10,7 @@ type PlayerInfo struct {
Id string `json:"id"`
Name string `json:"name"`
IsIdle bool `json:"isIdle"`
Score int `json:"score"`
}
type SourceInfo struct {