Class Fortune
Object
Fortune
- All Implemented Interfaces:
Attributes
Fortunes are bonuses that can be applied to knights before they go on quests.
As the bonus can apply to any attribute, they implement the Attributes interface.
Fortunes are immutable, meaning all values are final. Every value in this class
just 'stores' the values. No logic is performed (aka, set the values and get them only)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getArmor()
Return the amount of bonus to the knights armorReturns the replacement damage dice for the knight.int
Returns the the bonus to the knights hit modifier.int
getMaxHP()
return the amount of bonus to the knights maxHPgetName()
returns the name of the fortune card - often named after the knightly virtues.toString()
Returns a nicely formatted String value of the fortune.
-
Field Details
-
name
name of the fortune -
armor
private final int armorvalue of the armor bonus -
hpBonus
private final int hpBonusbonus to apply to HP. Just a stored int value in this class -
hitModifier
private final int hitModifiervalue of the hitModifier -
dtype
the damage dice modifier. May be null!
-
-
Constructor Details
-
Fortune
Basic constructor assuming no DamageDice replacement- Parameters:
name
- name of fortune cardhpBonus
- hp bonusarmor
- armor bonushitModifier
- to hit bonus
-
Fortune
Constructor with a damage dice replacement by DiceType type- Parameters:
name
- name of fortune cardhpBonus
- hp bonusarmor
- armor bonushitModifier
- to hit bonustype
- the damage dice replacement value
-
-
Method Details
-
getArmor
public int getArmor()Return the amount of bonus to the knights armor- Specified by:
getArmor
in interfaceAttributes
- Returns:
- whole number value
-
getMaxHP
public int getMaxHP()return the amount of bonus to the knights maxHP- Specified by:
getMaxHP
in interfaceAttributes
- Returns:
- whole number value
-
getDamageDie
Returns the replacement damage dice for the knight.- Specified by:
getDamageDie
in interfaceAttributes
- Returns:
- DiceType of the knight damage die
- See Also:
-
getHitModifier
public int getHitModifier()Returns the the bonus to the knights hit modifier.- Specified by:
getHitModifier
in interfaceAttributes
- Returns:
- whole number value
-
getName
returns the name of the fortune card - often named after the knightly virtues.- Returns:
- Name of the knight card
-
toString
Returns a nicely formatted String value of the fortune. Examples look like:+======================+ |Nobility | |HP Bonus: +10| |AC Bonus: +1| |Hit Bonus: +1| |Damage Adj: -| +======================+
Spacing is -22s for the name, 12s for the HP Bonus, 12s for the AC bonus, 11s for the hit bonus and 10s for the damage adj. Note: AC is Armor Use the following output for ToStringreturn "+======================+\n" + String.format("|%-22s|%n", getName()) + String.format("|HP Bonus: %12s|%n", "+" + getMaxHP()) + String.format("|AC Bonus: %12s|%n", "+" + getArmor()) + String.format("|Hit Bonus: %11s|%n", "+" + getHitModifier()) + String.format("|Damage Adj: %10s|%n", getDamageDie() != null ? getDamageDie() : "-") + "+======================+";
-