Package characters.monsters
Class Monster
java.lang.Object
characters.DungeonCharacter
characters.monsters.Monster
- All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>
public abstract class Monster extends DungeonCharacter
Abstract base class for a hierarchy of Monsters. It is derived from DungeonCharacter.
-
Field Summary
Fields Modifier and Type Field Description protected double
chanceToHeal
protected int
maxHeal
protected int
minHeal
Fields inherited from class characters.DungeonCharacter
attackSpeed, chanceToHit, damageMax, damageMin, hitPoints, name, randomInt
-
Constructor Summary
Constructors Modifier Constructor Description protected
Monster(java.lang.String name, int hitPoints, int attackSpeed, double chanceToHit, double chanceToHeal, int damageMin, int damageMax, int minHeal, int maxHeal)
Constructor. -
Method Summary
Modifier and Type Method Description void
battleChoices(DungeonCharacter theMonster)
Abstract of the battleChoices class, to be implemented by the Hero class.void
heal()
Monsters have a chance to heal themselves.void
subtractHitPoints(int hitPoints)
Additionally calls the heal method.Methods inherited from class characters.DungeonCharacter
addHitPoints, attack, compareTo, getAttackSpeed, getHitPoints, getName, isAlive
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
chanceToHeal
protected double chanceToHeal -
minHeal
protected int minHeal -
maxHeal
protected int maxHeal
-
-
Constructor Details
-
Monster
protected Monster(java.lang.String name, int hitPoints, int attackSpeed, double chanceToHit, double chanceToHeal, int damageMin, int damageMax, int minHeal, int maxHeal)Constructor.- Parameters:
name
- Name of character.hitPoints
- Points of damage a character can take before killed.attackSpeed
- How fast the character can attack.chanceToHit
- Chance an attack will strike the opponent.chanceToHeal
- Chance a character has to heal.damageMin
- Minimum amount of damage a character can inflict.damageMax
- Maximum amount of damage a character can inflict.minHeal
- The minimum amount of health to be restored.maxHeal
- The maximum amount of health to be restored...
-
-
Method Details
-
heal
public void heal()Monsters have a chance to heal themselves. -
subtractHitPoints
public void subtractHitPoints(int hitPoints)Additionally calls the heal method.- Overrides:
subtractHitPoints
in classDungeonCharacter
- Parameters:
hitPoints
- The number of hit points to subtract.
-
battleChoices
Description copied from class:DungeonCharacter
Abstract of the battleChoices class, to be implemented by the Hero class.- Specified by:
battleChoices
in classDungeonCharacter
- Parameters:
theMonster
- The opponent to be fought.
-