server/melee.go

41 lines
787 B
Go
Raw Normal View History

2014-01-15 21:41:40 -08:00
package main
import (
"log"
)
type melee struct {
respawn map[*Robot]float64
respawn_timer float64
}
func (g *melee) setup(gg *game) {
g.respawn_timer = 5000
}
func (g *melee) gameOver(gg *game) (bool, *GameOver) {
return false, &GameOver{}
}
func (g *melee) tick(gg *game, payload *Boardstate) {
for p := range gg.players {
for _, r := range p.Robots {
_, ok := g.respawn[r]
if r.Health <= 0 && !ok {
g.respawn[r] = g.respawn_timer
log.Printf("%v Died, Respawn in %v", r.Name, g.respawn_timer)
2014-01-16 00:02:59 -08:00
// gg.stats.playerStats[p.Id].botStats[r.Name].deaths++
2014-01-15 21:41:40 -08:00
}
}
}
for r, _ := range g.respawn {
g.respawn[r] -= float64(gg.tick_duration)
if g.respawn[r] <= 0 {
log.Printf("%v Respawned", r.Name)
r.reset(gg)
delete(g.respawn, r)
}
}
}