Stephen McQuay
c8efd34080
Create new bserv binary Herein lie the following ideas: - change package visibility of many things - try to stash the globals into structs - the code is far from correct; it merely compiles
41 lines
790 B
Go
41 lines
790 B
Go
package botserv
|
|
|
|
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)
|
|
// 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)
|
|
}
|
|
}
|
|
}
|