Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

13.11 Programming Assignment 4- 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

13.11 Programming Assignment 4- Build a Monster

Construct a class Monster with the following attributes:

  1. self.name (a.string)
  2. self.type (a string, default is Normal)
  3. self.currenthp (int, start out equal to maxhp)
  4. self.max_hp ( int, is given as input when the class instance is created, default is 20)
  5. self.attacks (a dictionary of all known attacks)
  6. 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:

  1. sneak_attack: 1
  2. slash: 2
  3. ice_storm: 3
  4. fire_storm: 3
  5. whirlwind: 3
  6. earthquake: 2
  7. double_hit: 4
  8. tornado: 4
  9. 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 monsters 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.

IN PYTHON PLEASE

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions