Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python please class Monster(): def __init__(self, name, hp=20): self.name = name self.type = Normal self.max_hp = hp self.current_hp = hp self.attacks = {'wait': 0} self.exp
python please
class Monster():
def __init__(self, name, hp=20):
self.name = name
self.type = "Normal"
self.max_hp = hp
self.current_hp = hp
self.attacks = {'wait': 0}
self.exp = 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 }
def add_attack(self, attack_name):
if ((attack_name in self.possible_attacks) and (attack_name not in self.attacks)):
if(len(self.attacks)
self.attacks[attack_name] = self.possible_attacks[attack_name]
return True
else:
weak_attack = min(self.attacks.values())
weak_list = []
for attack in self.attacks:
if self.attacks[attack] == weak_attack:
weak_list.append(attack)
weak_list.sort()
del self.attacks[weak_list[0]]
self.attacks[attack_name] = self.possible_attacks[attack_name]
return True
else:
return False
def remove_attack(self, attack_name):
if((attack_name in self.possible_attacks) and (attack_name in self.attacks)):
del self.attacks[attack_name]
if len(self.attacks) == 0:
self.add_attack('wait')
return True
else:
return False
def win_fight(self):
self.exp = self.exp + 5
self.current_hp = self.max_hp
def lose_fight(self):
self.exp = self.exp + 1
self.current_hp = self.max_hp
class Ghost(Monster):
def win_fight(self):
#your code here
def lose_fight(self):
#your code here
class Dragon(Monster):
def win_fight(self):
#your code here
def lose_fight(self):
#your code here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started