Advertisement
kevinbocky

character_test1.py

Jan 19th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. class Character:
  2.  
  3.  
  4. def __init__ (self, char_name, char_description):
  5. self.name = char_name
  6. self.description = char_description
  7. self.conversation = None
  8.  
  9. def describe(self):
  10. print(self.name + " is here! ")
  11. print(self.description)
  12.  
  13. def set_weakness(self):
  14. print(self.name + " has no weakness ")
  15.  
  16. def fight(self):
  17. print(self.name + " doesn't want to fight with you")
  18.  
  19.  
  20. def talk(self):
  21.  
  22. for loop in range(1):
  23. print("Hi i'm Dave")
  24. question1 = input("How are you? ")
  25. if question1 == "Good" or question1 == "good":
  26. print("OK nice")
  27. elif question1 == "Bad" or question1 == "bad":
  28. print("I'm sorry to hear that")
  29. else:
  30. print("I'm sorry i don't understand")
  31.  
  32.  
  33. class Enemy(Character):
  34.  
  35. def __init__ (self, char_name, char_description):
  36.  
  37. super(). __init__(char_name, char_description)
  38. self.weakness = None
  39.  
  40. def set_weakness(self, weakness):
  41. self.weakness = weakness
  42.  
  43. def get_weakness(self):
  44. return self.weakness
  45.  
  46. def fight(self):
  47. combat_item = input("What will you fight with? ")
  48. if combat_item == self.weakness:
  49. print("You fend " + self.name + " off with the " + combat_item)
  50. return True
  51. else:
  52. print(self.name + " crushes you, puny adventurer")
  53. return False
  54.  
  55. ----------------------------------------------------
  56. from character import Character
  57. from character import Enemy
  58.  
  59. dave = Enemy("Dave", "A smelly zombie")
  60.  
  61. dave.describe()
  62. dave.talk()
  63. dave.set_weakness("cheese")
  64. dave.fight()
  65.  
  66. dennis = Character("Dennis", "A friendly skeleton")
  67.  
  68. dennis.describe()
  69. dennis.talk()
  70. dennis.fight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement