Please help me complete the code for this in python.
13.11 PA4 Q1: Build a Monster
Construct a class “Monster” with the following attributes:
- self.name (a string)
- self.type (a string, default is ‘Normal’)
- self.current_hp (int, start out equal to max_hp)
- self.max_hp ( int, is given as input when the class instance is created, default is 20)
- self.attacks (a dictionary of all known attacks)
- self. possible_attacks ( a dictionary of all possible attacks)
The dictionary of possible_attacks will map the name of an attack ( the key) to how many points of damage the attack does. They must be of the following list:
- sneak_attack: 1
- slash: 2
- ice_storm: 3
- fire_storm: 3
- whirlwind: 3
- earthquake: 2
- double_hit: 4
- tornado: 4
- wait: 0
Every monster will start out with only the “wait” attack within self.attacks.
You will need to construct the method 'add_attack' and 'remove_attack'. Both methods will take in an attack name as a parameter. A monster can only have a maximum of four attacks at a time. If you add an attack when the monster already has four, the weakest one should be dropped automatically. If there is a tie for the weakest attack, drop the attack that comes first alphabetically. If adding the attack ended successfully, return True. If you try to add an invalid attack return False. If all of a monster’s attacks are removed, “wait” should automatically be added again, so that every monster always has at least 1 attack. If removing an attack ended successfully return True. If you try to remove an invalid attack or an attack that has not been learned return False.
【General guidance】The answer provided below has been developed in a clear step by step manner.Step1/1class Monster: def __init__(self, name, hp=20) -> None: self.name = name self.type = "Normal" self.max_hp = hp self.current_hp = self.max_hp self.attacks = {"wait":0} self.possible_attacks = {'sneak_attack': 1, "slash": 2, "ice_storm": 3, "fire_storm": 3, "whirlwind": 3, "earthquake": 2, "double_hit": 4, "tornado": 4, "wait": 0} pass def add_attack(self,attack_name): if attack_name in self.possible_attacks.keys(): ... See the full answer