Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from pydub import AudioSegment
- from pydub.playback import play
- song = AudioSegment.from_wav("warhead.wav")
- play(song)
- class Arena:
- def __init__(self, Bot1, Bot2):
- self.bbot1 = Bot1
- self.bbot2 = Bot2
- def battle(self):
- while self.bbot1.is_alive() and self.bbot2.is_alive():
- #begin battle round
- if self.bbot1.speed <= self.bbot2.speed:
- self.bbot1.action(self.bbot2)
- self.bbot2.action(self.bbot1)
- self.bbot1.get_stats()
- self.bbot2.get_stats()
- input("Press enter for next round")
- else:
- self.bbot2.action(self.bbot1)
- self.bbot1.action(self.bbot2)
- self.bbot1.get_stats()
- self.bbot2.get_stats()
- input("Press enter for next round")
- if self.bbot1.is_alive():
- print(self.bbot1.name + " is the winner!")
- else:
- print(self.bbot2.name + " is the winner!")
- class BattleBot:
- def __init__(self, name):
- self.name = name
- self.health = 100.0
- self.base_armor = 10.0
- self.base_damage = 10.0
- self.speed = 10.0
- def attack(self, opponent):
- damage_dealt = self.base_damage - (self.base_damage * (opponent.base_armor/100))
- opponent.take_damage(damage_dealt)
- def take_damage(self, damage_dealt):
- self.health -= damage_dealt
- def build_attack(self):
- self.base_armor -= 1
- self.base_damage += 2
- self.speed -= 1
- def build_speed(self):
- self.base_armor -= 1
- self.base_damage -= 1
- self.speed += 2
- def build_armor(self):
- self.base_armor += 2
- self.base_damage -= 1
- self.speed -= 1
- def is_alive(self):
- if self.health <= 0:
- return False
- else:
- return True
- def get_stats(self):
- print(self.name)
- print("Health " + str(self.health))
- print("Defence " + str(self.base_armor))
- print("Attack " + str(self.base_damage))
- print("Speed " + str(self.speed))
- def action(self, opponent):
- random_num = random.randint(0, 100)
- if(random_num <= 25):
- self.build_armor()
- elif random_num <= 50:
- self.build_attack()
- elif random_num <= 75:
- self.build_speed()
- elif random_num <= 100:
- self.attack(opponent)
- else:
- print(self.name + " glitched out!")
- Bot1 = BattleBot("HomeBot")
- Bot2 = BattleBot("VisitorBot")
- arena = Arena(Bot1, Bot2)
- arena.battle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement