rewrite of the stats system

This commit is contained in:
Fraser Graham
2014-01-16 00:02:59 -08:00
parent 90b7731865
commit 3fa53daadb
7 changed files with 46 additions and 14 deletions
+8 -3
View File
@@ -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
}