dragon, 100, 50
troll, 50, 20
water_golem, 30, 20
cyclops, 60, 30
b) Now we should have 3 variables in our add_monster() method. Use these 3 variables to create a Monster object, passing those 3 variables in as parameters to the constructor.
c) Finally time to use our self.monster_dictionary attribute. Use the species variable as the key, and the object we made in part (b) as the value. AKA, add the new monster object to our dictionary using species as the key.
Code from class in case you lost it:
import random class MonsterSystem: def __init__(self): self.main_menu = """ Main Menu 1. Add Monster 2. List all monsters 3. Play Adventure 4. Exit Enter your selection: """ self.attack_menu = """ 1. Magic attack 2. Sword attack - 10 to 20 damage Enter your selection: """ self.magic_attack_menu = """ What kind of magic attack you want to do: 1. Fire magic - Max damage: 10 2. Water magic - Max damage: 10 3. Earth magic - Max damage: 15 4. Wind magic - Max damage: 8 Enter your selection: """ self.monster_list = ["dragon", "troll", "water_golem", "cyclops"] self.monster_healths = { "dragon": 100 } self.monster_max_attacks = { "dragon": 50 } self.monster_dictionary = {} self.player_health = 200 def add_monster(self): species = random.choice(self.monster_list) health = random.randint(self.monster_healths[species]) max_attack = random.randint(self.monster_max_attacks[species] def application_loop(self): while True: selection = input(self.main_menu) if selection == "1": self.add_monster()