Class MOB
Object
MOB
- All Implemented Interfaces:
Attributes
- Direct Known Subclasses:
Knight
A MOB, short for Mobile Object,
represents all 'moving' objects in the game, most notably monsters, though knight
which is a specific type of MOB (playable) inherits from MOB as they share characteristics.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The armor rating of the mobprotected int
The amount of damage the MOB has takenprotected DiceType
the type of damage die used if the mob successfully strikes the targetprotected int
The hitModifier of the MOB.protected int
the maxHP of the mobprivate final String
Name value is set on creation and cannot be changed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDamage
(int damage) Adds damage to the mobs overall damage.copy()
Copies the mob to a new mob.int
getArmor()
Gets the armor attribute value, often between 8-20 for a D20 system, but not fixed.int
Gets the amount of damage the MOB has taken.Gets the Damage Die Type.int
A whole number of any int value to apply when making 'hit roles'.int
getHP()
Essentially returns the current HPs of the MOB.int
getMaxHP()
Gets the maximum hit points attribute.getName()
Returns the generic name of the MOBvoid
Resets the damage taken to 0.toString()
Builds a MOB Card for easy printing of the stats.
-
Field Details
-
name
Name value is set on creation and cannot be changed. -
hitModifier
protected int hitModifierThe hitModifier of the MOB. Required for the Attributes implementation -
armor
protected int armorThe armor rating of the mob -
maxHP
protected int maxHPthe maxHP of the mob -
damage
protected int damageThe amount of damage the MOB has taken -
damageDie
the type of damage die used if the mob successfully strikes the target
-
-
Constructor Details
-
MOB
The basic constructor for the mob. Most of these attributes never change, once set- Parameters:
name
- name of the mobhp
- maxHP of the mobarmor
- armor of the mobhitModifier
- hitModifier of the MOBdamageDie
- damageDie
-
-
Method Details
-
getHitModifier
public int getHitModifier()Description copied from interface:Attributes
A whole number of any int value to apply when making 'hit roles'.- Specified by:
getHitModifier
in interfaceAttributes
- Returns:
- whole number value of the modifier
-
getArmor
public int getArmor()Description copied from interface:Attributes
Gets the armor attribute value, often between 8-20 for a D20 system, but not fixed. Also called "armor class/AC".- Specified by:
getArmor
in interfaceAttributes
- Returns:
- whole number value of the armor stat
-
getMaxHP
public int getMaxHP()Description copied from interface:Attributes
Gets the maximum hit points attribute. While HP can go over max, they should always be reset to maxHP. Essentially maxHP is fixed, and remaining HP is modified either up or down and calculated when needed.- Specified by:
getMaxHP
in interfaceAttributes
- Returns:
- whole number value of the HP
-
getDamage
public int getDamage()Gets the amount of damage the MOB has taken. Rarely used outside of the class itself. Instead it is better to use getHP()- Returns:
- the amount of damage the MOB has taken
-
getName
Returns the generic name of the MOB- Returns:
- the name of the MOB
-
addDamage
public void addDamage(int damage) Adds damage to the mobs overall damage.- Parameters:
damage
- the amount to add in whole numbers
-
getHP
public int getHP()Essentially returns the current HPs of the MOB. Taking the the maxHP, and subtracting the damage done, gives the current HP of the mob.- Returns:
- the whole number value of the current hit points.
-
resetDamage
public void resetDamage()Resets the damage taken to 0. -
getDamageDie
Description copied from interface:Attributes
Gets the Damage Die Type.- Specified by:
getDamageDie
in interfaceAttributes
- Returns:
- a DiceType often ranging from D4-D12
- See Also:
-
toString
Builds a MOB Card for easy printing of the stats. The game does not currently specify the specifics of this card, nor is it tested. It is here to help with your own testing, and for the final game run. We used the following formatreturn "+============================+\n" + String.format("| %-27s|%n", getName()) + "| |\n" + String.format("| Health: %-10d |%n", getHP()) + String.format("| Power: %-6s Armor: %-4d|%n", getDamageDie().toString(), getArmor()) + "| |\n" + "+============================+";
-
copy
Copies the mob to a new mob. Does not care about any damage taken. When copying simply construct a new version of the mob using the values of this mob as the parameters for the new MOBs constructor, and return that. Do not overthink it, this can be a single line (or 2 line) method!- Returns:
- a copy/new MOB object
-