Question: Classes: 1 . Entity abstract class - describes a character in the game. a . _ _ init _ _ ( self , name, max
Classes:
Entity abstract class describes a character in the game.
ainitself name, maxhp initializes each of the instance variables
b takedamageself dmg subtracts the dmg from the hp but does not allow the
hp to drop below
c healself restores the entitys hp to maxhp
dstrself returns a string in the format Name
HP: hpmaxhp
e attackself entity abstract method no code that all entity subclasses will
override to attack and do damage to the opposing entity.
Hero extends entity the users character
ainitself name initializes the name and maxhp using super, sets the
heros starting location to row col
b attackself entity hero attacks the enemy randomize damage in the range
the enemy should take the damage and the method should return a string
representing the event.
c gonorthsoutheastwestself update the heros location by adding or
subtracting to the row or column, but only if that location is within the bounds
of the map between and the lenmap If it is return the character at that
location, if it isnt return an o to signify that the direction is out of bounds.
Enemy extends entity monster character that the hero encounters in the maze.
ainitself randomizes a name from a list of names exGoblinVampire
GhoulSkeletonZombie etc and randomizes the monsters hp
b attackself entity enemy attacks hero randomize damage in the range
The hero should take the damage and the method should return a string
representing the event.
Cleary
Map singleton the map of the dungeon maze.
anewcls if the map hasnt been constructed, then construct it and store it in
the instance class variable and return it If it has, then just return the instance.
binitself create and fill the D map list from the file contents. Create and
fill the D revealed list with all False values. The map stores the contents of the
file and the revealed list is used to determine whether the contents of the map are
displayed or not x if not displayed
cgetitemself row overloaded operator returns the specified row from
the map. Note: this operator can be used to access a row ex mr or can be
used to access a value at a row and column ex mrc
dlenself returns the number of rows in the map list. Note: if you want to
know the number of rows, use lenm if you need the number of columns, use
lenmr
e showmapself loc returns the map as a string in the format of a x matrix of
characters where revealed locations are the characters from the map, unrevealed
locations are xs and the heros location is a
f revealself loc sets the value in the D revealed list at the specified location to
True.
g removeatlocself loc overwrites the character in the map list at the specified
location with an n
Main prompt the user to enter their name, then construct the hero and a map object.
Create a loop that repeats until the hero dies, the hero finds the finish, or the user quits the
game. Present a menu that allows the user to choose a direction to move in north south,
east, west move the hero in that direction, reveal that spot, and then present the
encounter at that location as follows:
am monster construct an enemy and display its information. Create a loop
that allows the user to either attack or run away. If they attack, the hero attacks
the monster, and if the monster has hp left, then the monster attacks back. If the
monster is dead, then display a message and remove the m from the map. If the
user chooses to run away, then choose a random direction to run in reveal but
dont present the encounter for the new locationm should remain on the map
bo invalid direction display a message stating that they cannot move that
direction.
cn nothing display a message stating that this room is empty.
ds start display a message that they wound up back at the start of the dungeon.
ei item room display a message stating that they found a health potion. Heal
the hero and remove the i from the map so they cant get it again not required,
but you can add a check to see if the hero has full hp if they do then you can
leave the i on the map to save it for later
ff finish display a congratulatory message stating that they found the way out
of the maze and won the game.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
