Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class Monster:
- def __init__(self, player_level, difficulty):
- self.hp = 9
- self.type = f"{random.choice(monster_detail)} {self.__class__.__name__}"
- @ staticmethod
- def spawn(player_lvl, difficulty):
- # Monster.__subclasses__(): get the list of Monster class's subclasses
- # random.choice(...): get one of the Monster subclasses
- # ...(): get an instance of the (sub)class
- return random.choice(
- Monster.__subclasses__()
- )(player_lvl, difficulty)
- monster_detail = ["Alchemist", "Archer", "Assassin", "Berserker", "Cleric", "Druid", "Fighter", "Monk", "Paladin", "Ranger", "Rogue", "Sorcerer", "Warlock", "Wizard"]
- Orc = Monster(1, "Easy")
- Orc.hp = Orc.hp + 20
- print(Orc.hp)
Advertisement
Add Comment
Please, Sign In to add comment