Class TomeItem

java.lang.Object
model.item.Item
model.item.TomeItem
All Implemented Interfaces:
Applicable

public class TomeItem extends Item
Reward granted after defeating a Goblin; randomly boosts one of 3 stats for the winner. The boost is permanent (base values are also adjusted) and is not reset after battle.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    Attack bonus applied when ATTACK is rolled.
    private static final int
    Defense bonus applied when DEFENSE is rolled.
    private static final int
    HP bonus applied when MAX_HP is rolled.
    private final StatType
    Stat that was randomly selected when this object was created.
    private static final Random
    Shared random instance used to select which stat to boost.

    Fields inherited from class model.item.Item

    name
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a TomeItem and immediately randomly selects the stat to boost.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(Entity target)
    Applies the randomly chosen stat boost to the entity and updates base values as well, making the boost permanent and not subject to battle resets.
    Returns the stat type that was randomly selected.
    Returns a description of the stat boost for display in the UI.

    Methods inherited from class model.item.Item

    getName

    Methods inherited from class java.lang.Object

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

    • RANDOM

      private static final Random RANDOM
      Shared random instance used to select which stat to boost.
    • BONUS_AMOUNT_HP

      private static final int BONUS_AMOUNT_HP
      HP bonus applied when MAX_HP is rolled.
      See Also:
    • BONUS_AMOUNT_ATK

      private static final int BONUS_AMOUNT_ATK
      Attack bonus applied when ATTACK is rolled.
      See Also:
    • BONUS_AMOUNT_DEF

      private static final int BONUS_AMOUNT_DEF
      Defense bonus applied when DEFENSE is rolled.
      See Also:
    • boostedStat

      private final StatType boostedStat
      Stat that was randomly selected when this object was created.
  • Constructor Details

    • TomeItem

      public TomeItem()
      Creates a TomeItem and immediately randomly selects the stat to boost.
  • Method Details

    • apply

      public void apply(Entity target)
      Applies the randomly chosen stat boost to the entity and updates base values as well, making the boost permanent and not subject to battle resets.
      Specified by:
      apply in interface Applicable
      Specified by:
      apply in class Item
      Parameters:
      target - Entity to receive the stat boost
    • getEffectDescription

      public String getEffectDescription()
      Returns a description of the stat boost for display in the UI.
      Specified by:
      getEffectDescription in interface Applicable
      Specified by:
      getEffectDescription in class Item
      Returns:
      Description of the boosted stat
    • getBoostedStat

      public StatType getBoostedStat()
      Returns the stat type that was randomly selected.
      Returns:
      The StatType to be boosted