rewrite of the stats system
This commit is contained in:
+8
-3
@@ -21,16 +21,21 @@ func (g *deathmatch) gameOver(gg *game) (bool, *GameOver) {
|
||||
stats = NewGameOver()
|
||||
|
||||
for p := range gg.players {
|
||||
gg.stats.Lock()
|
||||
playerWin := false
|
||||
for _, r := range p.Robots {
|
||||
if r.Health > 0 {
|
||||
log.Printf("Robot %v Survived", r.Id)
|
||||
gg.winners.Lock()
|
||||
gg.winners.m[r.Id] += 1
|
||||
gg.winners.Unlock()
|
||||
gg.stats.PlayerStats[p.Id].BotStats[r.Name].Wins += 1
|
||||
stats.Winners = append(stats.Winners, r.Id)
|
||||
playerWin = true
|
||||
}
|
||||
r.reset(gg)
|
||||
}
|
||||
if playerWin {
|
||||
gg.stats.PlayerStats[p.Id].Wins += 1
|
||||
}
|
||||
gg.stats.Unlock()
|
||||
}
|
||||
over = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user