Class Fortune

Object
Fortune
All Implemented Interfaces:
Attributes

public class Fortune extends Object implements 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
    Modifier and Type
    Field
    Description
    private final int
    value of the armor bonus
    private final DiceType
    the damage dice modifier.
    private final int
    value of the hitModifier
    private final int
    bonus to apply to HP.
    private final String
    name of the fortune
  • Constructor Summary

    Constructors
    Constructor
    Description
    Fortune(String name, int hpBonus, int armor, int hitModifier)
    Basic constructor assuming no DamageDice replacement
    Fortune(String name, int hpBonus, int armor, int hitModifier, DiceType type)
    Constructor with a damage dice replacement by DiceType type
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return the amount of bonus to the knights armor
    Returns the replacement damage dice for the knight.
    int
    Returns the the bonus to the knights hit modifier.
    int
    return the amount of bonus to the knights maxHP
    returns the name of the fortune card - often named after the knightly virtues.
    Returns a nicely formatted String value of the fortune.

    Methods inherited from class Object

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

    • name

      private final String name
      name of the fortune
    • armor

      private final int armor
      value of the armor bonus
    • hpBonus

      private final int hpBonus
      bonus to apply to HP. Just a stored int value in this class
    • hitModifier

      private final int hitModifier
      value of the hitModifier
    • dtype

      private final DiceType dtype
      the damage dice modifier. May be null!
  • Constructor Details

    • Fortune

      public Fortune(String name, int hpBonus, int armor, int hitModifier)
      Basic constructor assuming no DamageDice replacement
      Parameters:
      name - name of fortune card
      hpBonus - hp bonus
      armor - armor bonus
      hitModifier - to hit bonus
    • Fortune

      public Fortune(String name, int hpBonus, int armor, int hitModifier, DiceType type)
      Constructor with a damage dice replacement by DiceType type
      Parameters:
      name - name of fortune card
      hpBonus - hp bonus
      armor - armor bonus
      hitModifier - to hit bonus
      type - the damage dice replacement value
  • Method Details

    • getArmor

      public int getArmor()
      Return the amount of bonus to the knights armor
      Specified by:
      getArmor in interface Attributes
      Returns:
      whole number value
    • getMaxHP

      public int getMaxHP()
      return the amount of bonus to the knights maxHP
      Specified by:
      getMaxHP in interface Attributes
      Returns:
      whole number value
    • getDamageDie

      public DiceType getDamageDie()
      Returns the replacement damage dice for the knight.
      Specified by:
      getDamageDie in interface Attributes
      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 interface Attributes
      Returns:
      whole number value
    • getName

      public String getName()
      returns the name of the fortune card - often named after the knightly virtues.
      Returns:
      Name of the knight card
    • toString

      public String 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 ToString
      
              return "+======================+\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() : "-") +
                      "+======================+";
       
      Overrides:
      toString in class Object
      Returns:
      String value of the fortune