Package cs2110
Class Monster
java.lang.Object
cs2110.Monster
- All Implemented Interfaces:
Actor
A monster in our game simulation that attacks a random living player on each of its turns.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe starting health level of a monster. -
Constructor Summary
ConstructorsConstructorDescriptionMonster(String name, GameEngine engine) Constructs a new monster with the given `name` and initializes its health and power levels. -
Method Summary
Modifier and TypeMethodDescriptionvoidLaunches an attack against the given `target`.booleandefend(int atk) Responds to an attack with the given `atk` roll.inthealth()Returns the current health level for this Actor.name()Returns the name of this Actor.intpower()Returns the base power level for this Actor.voidtakeTurn()Launches an attack against a random living player.toString()
-
Field Details
-
STARTING_HEALTH
public static final int STARTING_HEALTHThe starting health level of a monster.- See Also:
-
-
Constructor Details
-
Monster
Constructs a new monster with the given `name` and initializes its health and power levels.
-
-
Method Details
-
takeTurn
public void takeTurn()Launches an attack against a random living player. -
attack
Description copied from interface:ActorLaunches an attack against the given `target`. -
defend
public boolean defend(int atk) Description copied from interface:ActorResponds to an attack with the given `atk` roll. Returns `true` if the defense succeeded, false otherwise. -
name
Description copied from interface:ActorReturns the name of this Actor. -
health
public int health()Description copied from interface:ActorReturns the current health level for this Actor. -
power
public int power()Description copied from interface:ActorReturns the base power level for this Actor. -
toString
-