Geocrack

Orc

Jul 14th, 2022 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import random
  2.  
  3. class Monster:
  4.  
  5.     def __init__(self, player_level, difficulty):
  6.         self.hp = 9
  7.         self.type = f"{random.choice(monster_detail)} {self.__class__.__name__}"
  8.  
  9.     @ staticmethod
  10.     def spawn(player_lvl, difficulty):
  11.         # Monster.__subclasses__(): get the list of Monster class's subclasses
  12.         # random.choice(...): get one of the Monster subclasses
  13.         # ...(): get an instance of the (sub)class
  14.  
  15.         return random.choice(
  16.             Monster.__subclasses__()
  17.         )(player_lvl, difficulty)  
  18.  
  19. monster_detail = ["Alchemist", "Archer", "Assassin", "Berserker", "Cleric", "Druid", "Fighter", "Monk", "Paladin", "Ranger", "Rogue", "Sorcerer", "Warlock", "Wizard"]
  20.  
  21. Orc = Monster(1, "Easy")
  22. Orc.hp = Orc.hp + 20
  23. print(Orc.hp)
Advertisement
Add Comment
Please, Sign In to add comment