Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 3 . 1 2 PA 4 Q 2 : Fight! Now we want a way to make our monsters fight! Before two monsters can

13.12 PA4 Q2: Fight!
Now we want a way to make our monsters fight!
Before two monsters can fight, we need to give 2 new class methods that update their stats. Implement a method for "win_fight" and "lose_fight". Win_fight should add 5 to the monster's self.exp and reset their hp to max_hp. "lose_fight" should also reset their hp but only adds 1 exp to self.exp.
Now write a function that takes 2 instances of the monster class and makes them fight. This function should be defined outside the Monster class, i.e. it is not a Monster method. A fight goes as follows:
The monster that entered as the first function goes first.
Each monster takes a turn using one attack move. The monster selects this attack move from the strongest to the weakest in a circular function.
For example:
A monster has a dictionary of possible attack as follows:
["fire_storm": 3, "double_hit": 4, "earthquake": 2, "ice_storm": 3]
Monster will select the following attacks:
\table[[Round No,Move,],[1,double_hit,Highest hit points],[2,fire_storm,Same hit points as ice_storm but comes first alphabetically],[3,ice_storm,],[4,earthquake,],[5,double_hit,],[6,fire_storm,],[7,ice_storm,]]
And so on.
3. An attack is always successful and will decrease the opponent's hp by the given number of points in self attacks dictionary. The monsters continue taking turns until their current hp becomes less than or equal to zero.
4. At this point, the win_fight and lose_fight method should be invoked. Once this complete, return 3 things from the function.
Round_number
Monster that won (return the corresponding Monster object)
List of attacks the monster used
Special Edge Case: If both monster only have "wait" as an attack, return
-1(round_number)
None (for monster name that won)
None (for list of attack that monster use)
image text in transcribed

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

Step: 3

blur-text-image

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago