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 intThe armor rating of the mobprotected intThe amount of damage the MOB has takenprotected DiceTypethe type of damage die used if the mob successfully strikes the targetprotected intThe hitModifier of the MOB.protected intthe maxHP of the mobprivate final StringName value is set on creation and cannot be changed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDamage(int damage) Adds damage to the mobs overall damage.copy()Copies the mob to a new mob.intgetArmor()Gets the armor attribute value, often between 8-20 for a D20 system, but not fixed.intGets the amount of damage the MOB has taken.Gets the Damage Die Type.intA whole number of any int value to apply when making 'hit roles'.intgetHP()Essentially returns the current HPs of the MOB.intgetMaxHP()Gets the maximum hit points attribute.getName()Returns the generic name of the MOBvoidResets 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:AttributesA whole number of any int value to apply when making 'hit roles'.- Specified by:
getHitModifierin interfaceAttributes- Returns:
- whole number value of the modifier
-
getArmor
public int getArmor()Description copied from interface:AttributesGets the armor attribute value, often between 8-20 for a D20 system, but not fixed. Also called "armor class/AC".- Specified by:
getArmorin interfaceAttributes- Returns:
- whole number value of the armor stat
-
getMaxHP
public int getMaxHP()Description copied from interface:AttributesGets 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:
getMaxHPin 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:AttributesGets the Damage Die Type.- Specified by:
getDamageDiein 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
-