No Description
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.

melee.go 790B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package botserv
  2. import (
  3. "log"
  4. )
  5. type melee struct {
  6. respawn map[*Robot]float64
  7. respawn_timer float64
  8. }
  9. func (g *melee) setup(gg *Game) {
  10. g.respawn_timer = 5000
  11. }
  12. func (g *melee) gameOver(gg *Game) (bool, *GameOver) {
  13. return false, &GameOver{}
  14. }
  15. func (g *melee) tick(gg *Game, payload *Boardstate) {
  16. for p := range gg.players {
  17. for _, r := range p.Robots {
  18. _, ok := g.respawn[r]
  19. if r.Health <= 0 && !ok {
  20. g.respawn[r] = g.respawn_timer
  21. log.Printf("%v Died, Respawn in %v", r.Name, g.respawn_timer)
  22. // gg.stats.playerStats[p.Id].botStats[r.Name].deaths++
  23. }
  24. }
  25. }
  26. for r, _ := range g.respawn {
  27. g.respawn[r] -= float64(gg.tick_duration)
  28. if g.respawn[r] <= 0 {
  29. log.Printf("%v Respawned", r.Name)
  30. r.reset(gg)
  31. delete(g.respawn, r)
  32. }
  33. }
  34. }