Answered step by step
Verified Expert Solution
Link Copied!

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 image text in transcribed
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
13.13 PA4 Q3: Dragons and Ghosts Make 2 monster subclasses: Dragon and ghosts, both of which inherit all of the properties of the Monster class. Both should have their "type attribute updated to 'dragon' and 'ghost' respectively. Dragon and ghosts have the ability to level up! Every time a dragon gains 10 exp all of its attacks gain +1 damage. For Example, at 30 exp a dragon's attack will have each +3 damage total. This does NOT include any new attacks learned after gaining exp. For Ghosts, every time a Ghost gains 10exp it gains +5 to its max hp and therefore current_hp. In order to implement this change the win_fight and lose_fight methods within each subclass to account for these changes. There is no need to change the Monster class or the monster_fight function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

Students also viewed these Databases questions

Question

How does the grapevine work in organizations?

Answered: 1 week ago

Question

What are hallucinogens, and what are their effects?

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago