2014-04-23 14:28:13 -07:00
|
|
|
package server
|
2014-01-15 21:41:40 -08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
2014-04-14 00:26:41 -07:00
|
|
|
// deathmatch is a game type that resets when there is one bot standing. There
|
|
|
|
// is an obvious winner each round.
|
2014-01-15 21:41:40 -08:00
|
|
|
type deathmatch struct {
|
|
|
|
}
|
|
|
|
|
2014-03-18 23:38:06 -07:00
|
|
|
func (g *deathmatch) setup(gg *Game) {
|
2014-01-15 21:41:40 -08:00
|
|
|
}
|
|
|
|
|
2014-03-18 23:38:06 -07:00
|
|
|
func (g *deathmatch) gameOver(gg *Game) (bool, *GameOver) {
|
2014-01-15 21:41:40 -08:00
|
|
|
over := false
|
|
|
|
var stats *GameOver
|
|
|
|
|
|
|
|
if gg.players_remaining <= 1 && len(gg.players) > 1 {
|
2014-04-26 23:05:53 -07:00
|
|
|
if len(gg.defaultObstacles) == 0 {
|
|
|
|
gg.obstacles = GenerateObstacles(
|
|
|
|
gg.obstacleCount,
|
|
|
|
gg.width,
|
|
|
|
gg.height,
|
|
|
|
)
|
|
|
|
}
|
2014-01-15 21:41:40 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2014-03-18 23:38:06 -07:00
|
|
|
func (g *deathmatch) tick(gg *Game, payload *Boardstate) {
|
2014-01-15 21:41:40 -08:00
|
|
|
}
|