Advertisement
kenadams53

FinishedCharacter.py

Aug 15th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #FinishedCharacter
  2. # z=10
  3. class Character():
  4. z = 10
  5. # Create a character
  6. def __init__(self, char_name, char_description):
  7. self.name = char_name
  8. self.description = char_description
  9. self.conversation = None
  10.  
  11. # Describe this character
  12. def describe(self):
  13. print( self.name + " is here!" )
  14. print( self.description )
  15.  
  16. # Set what this character will say when talked to
  17. def set_conversation(self, conversation):
  18. self.conversation = conversation
  19.  
  20. # Talk to this character
  21. def talk(self):
  22. if self.conversation is not None:
  23. print("[" + self.name + " says]: " + self.conversation)
  24. else:
  25. print(self.name + " doesn't want to talk to you")
  26.  
  27. # Fight with this character
  28. def fight(self, combat_item):
  29. print(self.name + " doesn't want to fight with you")
  30. return False
  31.  
  32. def addition(self):
  33. print("in addition method")
  34. x = int(input("What is the first number? "))
  35. y = int(input("What is the second number? "))
  36. sum = x+y+self.z
  37. print(self.name + " says: The sum with z is " + str(sum) )
  38.  
  39. class Enemy(Character):
  40.  
  41. enemies_defeated = 0
  42.  
  43. def __init__(self, char_name, char_description):
  44.  
  45. super().__init__(char_name, char_description)
  46. self.weakness = None
  47.  
  48. # Fight with an enemy
  49. def fight(self, combat_item):
  50. if combat_item == self.weakness:
  51. print("You fend " + self.name + " off with the " + combat_item)
  52. Enemy.enemies_defeated += 1
  53. return True
  54. else:
  55. print(self.name + " crushes you, puny adventurer!")
  56. return False
  57.  
  58. def set_weakness(self, item_weakness):
  59. self.weakness = item_weakness
  60.  
  61. def get_weakness(self):
  62. return self.weakness
  63.  
  64. # Getters and setters for the enemies_defeated variable
  65. def get_defeated(self):
  66. return Enemy.enemies_defeated
  67.  
  68. def set_defeated(self, number_defeated):
  69. Enemy.enemies_defeated = number_defeated
  70.  
  71. def steal(self):
  72. print("You steal from " + self.name)
  73. # How will you decide what this character has to steal?
  74.  
  75.  
  76.  
  77. class Friend(Character):
  78.  
  79. def __init__(self, char_name, char_description):
  80.  
  81. super().__init__(char_name, char_description)
  82. self.feeling = None
  83.  
  84. def hug(self):
  85. print(self.name + " hugs you back!")#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement