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 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package server
  2. import (
  3. "log"
  4. )
  5. // deathmatch is a game type that resets when there is one bot standing. There
  6. // is an obvious winner each round.
  7. type deathmatch struct {
  8. }
  9. func (g *deathmatch) setup(gg *Game) {
  10. }
  11. func (g *deathmatch) gameOver(gg *Game) (bool, *GameOver) {
  12. over := false
  13. var stats *GameOver
  14. if gg.players_remaining <= 1 && len(gg.players) > 1 {
  15. if len(gg.defaultObstacles) == 0 {
  16. gg.obstacles = GenerateObstacles(
  17. gg.obstacleCount,
  18. gg.width,
  19. gg.height,
  20. )
  21. }
  22. log.Printf("game %s: game over", gg.id)
  23. stats = NewGameOver()
  24. for p := range gg.players {
  25. gg.stats.Lock()
  26. playerWin := false
  27. for _, r := range p.Robots {
  28. if r.Health > 0 {
  29. log.Printf("Robot %v Survived", r.Id)
  30. gg.stats.PlayerStats[p.Id].BotStats[r.Name].Wins += 1
  31. stats.Winners = append(stats.Winners, r.Id)
  32. playerWin = true
  33. }
  34. r.reset(gg)
  35. }
  36. if playerWin {
  37. gg.stats.PlayerStats[p.Id].Wins += 1
  38. }
  39. gg.stats.Unlock()
  40. }
  41. over = true
  42. }
  43. return over, stats
  44. }
  45. func (g *deathmatch) tick(gg *Game, payload *Boardstate) {
  46. }