Package cs2110

Class Monster

java.lang.Object
cs2110.Monster
All Implemented Interfaces:
Actor

public class Monster extends Object implements Actor
A monster in our game simulation that attacks a random living player on each of its turns.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The starting health level of a monster.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Monster(String name, GameEngine engine)
    Constructs a new monster with the given `name` and initializes its health and power levels.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attack(Actor target)
    Launches an attack against the given `target`.
    boolean
    defend(int atk)
    Responds to an attack with the given `atk` roll.
    int
    Returns the current health level for this Actor.
    Returns the name of this Actor.
    int
    Returns the base power level for this Actor.
    void
    Launches an attack against a random living player.
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • STARTING_HEALTH

      public static final int STARTING_HEALTH
      The starting health level of a monster.
      See Also:
  • Constructor Details

    • Monster

      public Monster(String name, GameEngine engine)
      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.
      Specified by:
      takeTurn in interface Actor
    • attack

      public void attack(Actor target)
      Description copied from interface: Actor
      Launches an attack against the given `target`.
      Specified by:
      attack in interface Actor
    • defend

      public boolean defend(int atk)
      Description copied from interface: Actor
      Responds to an attack with the given `atk` roll. Returns `true` if the defense succeeded, false otherwise.
      Specified by:
      defend in interface Actor
    • name

      public String name()
      Description copied from interface: Actor
      Returns the name of this Actor.
      Specified by:
      name in interface Actor
    • health

      public int health()
      Description copied from interface: Actor
      Returns the current health level for this Actor.
      Specified by:
      health in interface Actor
    • power

      public int power()
      Description copied from interface: Actor
      Returns the base power level for this Actor.
      Specified by:
      power in interface Actor
    • toString

      public String toString()
      Overrides:
      toString in class Object