Advertisement
jabela

Simple RPG

Apr 22nd, 2020
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. import random
  2.  
  3. class Character:
  4.     def __init__(self):
  5.         self.name = ""
  6.         self.attack = 0
  7.         self.defence = 0
  8.         self.__health = 0
  9.         self.experience = 0
  10.  
  11.     def print_basics(self):
  12.         print("\nName:       ",self.name)
  13.         print("attack:     ",self.attack)
  14.         print("defence     ",self.defence)
  15.         print("health:     ",self.__health)
  16.         print("experience: ",self.experience)
  17.  
  18.     def setter(self,name):
  19.         self.name = name
  20.         self.attack = random.randint(0,50)
  21.         self.defence = random.randint(0,50)
  22.         self.__health = random.randint(30,50)
  23.  
  24.     def health_getter(self):
  25.         return self.__health
  26.  
  27.     def print_me(self):
  28.         self.print_basics()
  29.  
  30.  
  31. class wizard(Character):
  32.     def __init__(self):
  33.         Character.__init__(self) #need to add in parent classes
  34.         self.magic = 30
  35.  
  36.     def print_me(self):
  37.         self.print_basics()
  38.         print("magic       ",self.magic)
  39.  
  40. class knight(Character):
  41.     def __init__(self):
  42.         Character.__init__(self) #need to add in parent classes
  43.         self.armour = 30
  44.  
  45.     def print_me(self):
  46.         self.print_basics()
  47.         print("armour      ",self.armour)
  48.  
  49. Arthur = knight()
  50. Arthur.setter("Arthur")
  51. Arthur.print_me()
  52.  
  53. Merlin = wizard()
  54. Merlin.setter("Merlin")
  55. Merlin.print_me()
  56.  
  57. caste = input("\nWould you like to be a Wizard or Knight? W or K")
  58. char_name = input("And what is your name?")
  59.  
  60. if caste.upper() == "K":
  61.     print("A great knight is created!")
  62.     you = knight()
  63. elif caste.upper() == "W":
  64.     print("A great wizards shimmers into existance")
  65.     you = wizard()
  66. else:
  67.     print("\nTyping W or K too much for you! \nClearly you plan to die...\nBasic peasant for you!")
  68.     you = Character()
  69.  
  70. you.setter(char_name)
  71. you.print_me()
  72.  
  73. print("\nThere's a game to be made here! \nBut the gods of youtube have not delivered me enough subscribers!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement