Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Enemy(Character):
- def __init__(self,name,description):
- super().__init__(name,description)
- self.weakness = None
- def get_weakness(self):
- if self.weakness == None:
- return 'Immune'
- else:
- return self.weakness
- def set_weakness(self,weakness):
- self.weakness = weakness
- def fight(self,combatItem):
- if combatItem == self.weakness:
- print('You defeat {} with {}'.format(self.name,combatItem))
- return 'Win'
- elif combatItem == 'Jelly':
- print('Pathetic Earthling. Your {} is no match for me.'.format(combatItem))
- return 'Lose'
- else:
- print('Nothing Happens')
- return 'Draw'
- def describe(self):
- print('I am the mighty {}!'.format(self.name))
- print(self.description)
- print(self.weakness)
- def prepareEnemy():
- zach = Enemy('Zach','A Zombie and he wants to eat your brain')
- zach.set_weakness('Cheese')
- zach.set_conversation('Hello')
- zach.talk()
- zach.describe()
- return zach
- def fightEnemy(enemy):
- fight = True
- while fight:
- weapon = input('Choose your weapon (Cheese / Jelly):').strip()
- result = enemy.fight(weapon)
- if result == 'Win' or result == 'Lose':
- fight = False
- zach = prepareEnemy()
- fightEnemy(zach)
Advertisement
Add Comment
Please, Sign In to add comment