Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

deathmatch.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. gg.obstacles = GenerateObstacles(gg.obstacle_count, gg.width, gg.height)
  16. log.Printf("game %s: game over", gg.id)
  17. stats = NewGameOver()
  18. for p := range gg.players {
  19. gg.stats.Lock()
  20. playerWin := false
  21. for _, r := range p.Robots {
  22. if r.Health > 0 {
  23. log.Printf("Robot %v Survived", r.Id)
  24. gg.stats.PlayerStats[p.Id].BotStats[r.Name].Wins += 1
  25. stats.Winners = append(stats.Winners, r.Id)
  26. playerWin = true
  27. }
  28. r.reset(gg)
  29. }
  30. if playerWin {
  31. gg.stats.PlayerStats[p.Id].Wins += 1
  32. }
  33. gg.stats.Unlock()
  34. }
  35. over = true
  36. }
  37. return over, stats
  38. }
  39. func (g *deathmatch) tick(gg *Game, payload *Boardstate) {
  40. }