Advertisement
JAS_Software

Zombie Fight

May 21st, 2021
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Enemy(Character):
  2.     def __init__(self,name,description):
  3.         super().__init__(name,description)
  4.         self.weakness = None
  5.        
  6.     def get_weakness(self):
  7.         if self.weakness == None:
  8.             return 'Immune'
  9.         else:
  10.             return self.weakness
  11.        
  12.     def set_weakness(self,weakness):
  13.         self.weakness = weakness
  14.        
  15.     def fight(self,combatItem):
  16.         if combatItem == self.weakness:
  17.             print('You defeat {} with {}'.format(self.name,combatItem))
  18.             return 'Win'
  19.         elif combatItem == 'Jelly':
  20.             print('Pathetic Earthling. Your {} is no match for me.'.format(combatItem))
  21.             return 'Lose'
  22.         else:
  23.             print('Nothing Happens')
  24.             return 'Draw'
  25.  
  26.     def describe(self):
  27.         print('I am the mighty {}!'.format(self.name))
  28.         print(self.description)
  29.         print(self.weakness)
  30.  
  31.  
  32.  
  33. def prepareEnemy():
  34.     zach = Enemy('Zach','A Zombie and he wants to eat your brain')
  35.     zach.set_weakness('Cheese')
  36.     zach.set_conversation('Hello')
  37.     zach.talk()
  38.     zach.describe()
  39.     return zach
  40.    
  41. def fightEnemy(enemy):
  42.     fight = True
  43.     while fight:
  44.         weapon = input('Choose your weapon (Cheese / Jelly):').strip()
  45.         result = enemy.fight(weapon)
  46.         if result == 'Win' or result == 'Lose':
  47.             fight = False
  48.            
  49.  
  50. zach = prepareEnemy()
  51. fightEnemy(zach)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement