Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. class Character():
  2.  
  3. # Create a character
  4. def __init__(self, char_name, char_description):
  5. self.name = char_name
  6. self.description = char_description
  7. self.conversation = None
  8.  
  9. # Describe this character
  10. def describe(self):
  11. print( self.name + " is here!" )
  12. print( self.description )
  13.  
  14. # Set what this character will say when talked to
  15. def set_conversation(self, conversation):
  16. self.conversation = conversation
  17.  
  18. # Talk to this character
  19. def talk(self):
  20. if self.conversation is not None:
  21. print("[" + self.name + " says]: " + self.conversation)
  22. else:
  23. print(self.name + " doesn't want to talk to you")
  24.  
  25. # Fight with this character
  26. def fight(self, combat_item):
  27. print(self.name + " doesn't want to fight with you")
  28. return True
  29.  
  30. class Enemy(Character):
  31.  
  32. def __init__(self, char_name, char_description):
  33.  
  34. super().__init__(char_name, char_description)
  35. self.weakness = None
  36.  
  37. # Fight with an enemy
  38. def fight(self, combat_item):
  39. if combat_item == self.weakness:
  40. print("You fend " + self.name + " off with the " + combat_item)
  41. return True
  42. else:
  43. print(self.name + " crushes you, puny adventurer!")
  44. return False
  45.  
  46. def set_weakness(self, item_weakness):
  47. self.weakness = item_weakness
  48.  
  49. def get_weakness(self):
  50. return self.weakness
  51.  
  52. def steal(self):
  53. print("You steal from " + self.name)
  54. # How will you decide what this character has to steal?
  55.  
  56.  
  57. class Friend(Character):
  58.  
  59. def __init__(self, char_name, char_description):
  60.  
  61. super().__init__(char_name, char_description)
  62. self.feeling = None
  63.  
  64. def hug(self):
  65. print(self.name + " hugs you back!")
  66.  
  67. # What other methods could your Friend class have?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement