server/deathmatch.go

46 lines
912 B
Go
Raw Normal View History

2014-01-15 21:41:40 -08:00
package main
import (
"log"
)
type deathmatch struct {
}
func (g *deathmatch) setup(gg *game) {
}
func (g *deathmatch) gameOver(gg *game) (bool, *GameOver) {
over := false
var stats *GameOver
if gg.players_remaining <= 1 && len(gg.players) > 1 {
gg.obstacles = GenerateObstacles(gg.obstacle_count, gg.width, gg.height)
log.Printf("game %s: game over", gg.id)
stats = NewGameOver()
for p := range gg.players {
2014-01-16 00:02:59 -08:00
gg.stats.Lock()
playerWin := false
2014-01-15 21:41:40 -08:00
for _, r := range p.Robots {
if r.Health > 0 {
log.Printf("Robot %v Survived", r.Id)
2014-01-16 00:02:59 -08:00
gg.stats.PlayerStats[p.Id].BotStats[r.Name].Wins += 1
2014-01-15 21:41:40 -08:00
stats.Winners = append(stats.Winners, r.Id)
2014-01-16 00:02:59 -08:00
playerWin = true
2014-01-15 21:41:40 -08:00
}
r.reset(gg)
}
2014-01-16 00:02:59 -08:00
if playerWin {
gg.stats.PlayerStats[p.Id].Wins += 1
}
gg.stats.Unlock()
2014-01-15 21:41:40 -08:00
}
over = true
}
return over, stats
}
func (g *deathmatch) tick(gg *game, payload *Boardstate) {
}