server/melee.go

43 lines
886 B
Go
Raw Normal View History

package botserv
2014-01-15 21:41:40 -08:00
import (
"log"
)
2014-04-14 00:26:41 -07:00
// melee is a game type that allows dead players to respond after a particular
// number of ms.
2014-01-15 21:41:40 -08:00
type melee struct {
respawn map[*Robot]float64
respawn_timer float64
}
func (g *melee) setup(gg *Game) {
2014-01-15 21:41:40 -08:00
g.respawn_timer = 5000
}
func (g *melee) gameOver(gg *Game) (bool, *GameOver) {
2014-01-15 21:41:40 -08:00
return false, &GameOver{}
}
func (g *melee) tick(gg *Game, payload *Boardstate) {
2014-01-15 21:41:40 -08:00
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)
}
}
}