Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. import random
  2. from pydub import AudioSegment
  3. from pydub.playback import play
  4.  
  5. song = AudioSegment.from_wav("warhead.wav")
  6. play(song)
  7.  
  8.  
  9.  
  10.  
  11. class Arena:
  12. def __init__(self, Bot1, Bot2):
  13. self.bbot1 = Bot1
  14. self.bbot2 = Bot2
  15. def battle(self):
  16. while self.bbot1.is_alive() and self.bbot2.is_alive():
  17. #begin battle round
  18. if self.bbot1.speed <= self.bbot2.speed:
  19. self.bbot1.action(self.bbot2)
  20. self.bbot2.action(self.bbot1)
  21. self.bbot1.get_stats()
  22. self.bbot2.get_stats()
  23. input("Press enter for next round")
  24. else:
  25. self.bbot2.action(self.bbot1)
  26. self.bbot1.action(self.bbot2)
  27. self.bbot1.get_stats()
  28. self.bbot2.get_stats()
  29. input("Press enter for next round")
  30. if self.bbot1.is_alive():
  31. print(self.bbot1.name + " is the winner!")
  32. else:
  33. print(self.bbot2.name + " is the winner!")
  34.  
  35. class BattleBot:
  36. def __init__(self, name):
  37. self.name = name
  38. self.health = 100.0
  39. self.base_armor = 10.0
  40. self.base_damage = 10.0
  41. self.speed = 10.0
  42.  
  43. def attack(self, opponent):
  44. damage_dealt = self.base_damage - (self.base_damage * (opponent.base_armor/100))
  45. opponent.take_damage(damage_dealt)
  46.  
  47. def take_damage(self, damage_dealt):
  48. self.health -= damage_dealt
  49.  
  50. def build_attack(self):
  51. self.base_armor -= 1
  52. self.base_damage += 2
  53. self.speed -= 1
  54.  
  55. def build_speed(self):
  56. self.base_armor -= 1
  57. self.base_damage -= 1
  58. self.speed += 2
  59.  
  60. def build_armor(self):
  61. self.base_armor += 2
  62. self.base_damage -= 1
  63. self.speed -= 1
  64.  
  65. def is_alive(self):
  66. if self.health <= 0:
  67. return False
  68. else:
  69. return True
  70.  
  71. def get_stats(self):
  72. print(self.name)
  73. print("Health " + str(self.health))
  74. print("Defence " + str(self.base_armor))
  75. print("Attack " + str(self.base_damage))
  76. print("Speed " + str(self.speed))
  77.  
  78. def action(self, opponent):
  79. random_num = random.randint(0, 100)
  80. if(random_num <= 25):
  81. self.build_armor()
  82. elif random_num <= 50:
  83. self.build_attack()
  84. elif random_num <= 75:
  85. self.build_speed()
  86. elif random_num <= 100:
  87. self.attack(opponent)
  88. else:
  89. print(self.name + " glitched out!")
  90.  
  91. Bot1 = BattleBot("HomeBot")
  92. Bot2 = BattleBot("VisitorBot")
  93. arena = Arena(Bot1, Bot2)
  94. arena.battle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement