update score
This commit is contained in:
parent
f65a5ca2a2
commit
dfda2d25cf
@ -18,6 +18,7 @@ func (gm *Game) EventPlayerJoins(usr *user.User) {
|
|||||||
name: usrName,
|
name: usrName,
|
||||||
isPlaying: true,
|
isPlaying: true,
|
||||||
isIdle: false,
|
isIdle: false,
|
||||||
|
score: prevPlayer.score,
|
||||||
}
|
}
|
||||||
gm.players[usrId] = player
|
gm.players[usrId] = player
|
||||||
|
|
||||||
@ -64,5 +65,6 @@ func (gm *Game) AddPlayer(usr *user.User) {
|
|||||||
name: usr.GetName(),
|
name: usr.GetName(),
|
||||||
isPlaying: false,
|
isPlaying: false,
|
||||||
isIdle: true,
|
isIdle: true,
|
||||||
|
score: 7,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ func (gm *Game) populateGetPlayers() []syncdata.PlayerInfo {
|
|||||||
Id: p.id,
|
Id: p.id,
|
||||||
Name: p.name,
|
Name: p.name,
|
||||||
IsIdle: p.isIdle,
|
IsIdle: p.isIdle,
|
||||||
|
Score: p.score,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,21 @@ func (gm *Game) revealSource() {
|
|||||||
gm.round.revelation.sources[source.id] = false
|
gm.round.revelation.sources[source.id] = false
|
||||||
}
|
}
|
||||||
quote := gm.quotes[gm.round.quoteId]
|
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.mu.Unlock()
|
||||||
|
|
||||||
gm.notifyClients()
|
gm.notifyClients()
|
||||||
|
@ -31,6 +31,7 @@ type playerInfo struct {
|
|||||||
name string
|
name string
|
||||||
isPlaying bool
|
isPlaying bool
|
||||||
isIdle bool
|
isIdle bool
|
||||||
|
score int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Source struct {
|
type Source struct {
|
||||||
|
@ -10,6 +10,7 @@ type PlayerInfo struct {
|
|||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
IsIdle bool `json:"isIdle"`
|
IsIdle bool `json:"isIdle"`
|
||||||
|
Score int `json:"score"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SourceInfo struct {
|
type SourceInfo struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user