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.

deathmatch.go 915B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package botserv
  2. import (
  3. "log"
  4. )
  5. type deathmatch struct {
  6. }
  7. func (g *deathmatch) setup(gg *Game) {
  8. }
  9. func (g *deathmatch) gameOver(gg *Game) (bool, *GameOver) {
  10. over := false
  11. var stats *GameOver
  12. if gg.players_remaining <= 1 && len(gg.players) > 1 {
  13. gg.obstacles = GenerateObstacles(gg.obstacle_count, gg.width, gg.height)
  14. log.Printf("game %s: game over", gg.id)
  15. stats = NewGameOver()
  16. for p := range gg.players {
  17. gg.stats.Lock()
  18. playerWin := false
  19. for _, r := range p.Robots {
  20. if r.Health > 0 {
  21. log.Printf("Robot %v Survived", r.Id)
  22. gg.stats.PlayerStats[p.Id].BotStats[r.Name].Wins += 1
  23. stats.Winners = append(stats.Winners, r.Id)
  24. playerWin = true
  25. }
  26. r.reset(gg)
  27. }
  28. if playerWin {
  29. gg.stats.PlayerStats[p.Id].Wins += 1
  30. }
  31. gg.stats.Unlock()
  32. }
  33. over = true
  34. }
  35. return over, stats
  36. }
  37. func (g *deathmatch) tick(gg *Game, payload *Boardstate) {
  38. }