update score
This commit is contained in:
parent
f65a5ca2a2
commit
dfda2d25cf
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ func (gm *Game) populateGetPlayers() []syncdata.PlayerInfo {
|
||||
Id: p.id,
|
||||
Name: p.name,
|
||||
IsIdle: p.isIdle,
|
||||
Score: p.score,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -31,6 +31,7 @@ type playerInfo struct {
|
||||
name string
|
||||
isPlaying bool
|
||||
isIdle bool
|
||||
score int
|
||||
}
|
||||
|
||||
type Source struct {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user