You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
885 B

package server
import (
"log"
)
// melee is a game type that allows dead players to respond after a particular
// number of ms.
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)
// gg.stats.playerStats[p.Id].botStats[r.Name].deaths++
}
}
}
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)
}
}
}