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 885B

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