Class ConsumableItem

All Implemented Interfaces:
EquipListener, TurnListener, UseListener, Stackable<StackableItem>, Killer, Cloneable, Comparable<ConsumableItem>, Iterable<String>, Serializable
Direct Known Subclasses:
Drink, Food, StatusHealer

public class ConsumableItem extends StackableItem implements Comparable<ConsumableItem>
Represents everything that can be consumed by RPentity. Including food, poison, antidote, ... Note: this class has a natural ordering that is inconsistent with equals.
  • Field Details

    • feeder

      protected final Feeder feeder
  • Constructor Details

    • ConsumableItem

      public ConsumableItem(String name, String clazz, String subclass, Map<String,​String> attributes)
    • ConsumableItem

      public ConsumableItem(ConsumableItem item)
      copy constructor.
      Parameters:
      item - item to copy
  • Method Details

    • put

      public void put(String attribute, double value)
      Description copied from class: Attributes
      This method set the value of an attribute
      Overrides:
      put in class Attributes
      Parameters:
      attribute - the attribute to be set.
      value - the value we want to set.
    • put

      public void put(String attribute, int value)
      Description copied from class: Attributes
      This method set the value of an attribute
      Overrides:
      put in class Attributes
      Parameters:
      attribute - the attribute to be set.
      value - the value we want to set.
    • put

      public void put(String attribute, String value)
      Description copied from class: Attributes
      This method set the value of an attribute
      Overrides:
      put in class Attributes
      Parameters:
      attribute - the attribute to be set.
      value - the value we want to set.
    • getAmount

      public int getAmount()
    • getFrecuency

      public int getFrecuency()
    • getRegen

      public int getRegen()
    • consume

      public int consume()
      Consumes a part of this item.
      Returns:
      The amount that has been consumed
    • consumed

      public boolean consumed()
      Checks whether this item has already been fully consumed.
      Returns:
      true iff this item has been consumed
    • onUsed

      public boolean onUsed(RPEntity user)
      Verifies item is near to player. if so splits one single item of and calls consumeItem of the player.
      Specified by:
      onUsed in interface UseListener
      Overrides:
      onUsed in class Item
      Parameters:
      user - the eating player
      Returns:
      true if consumption can be started
    • compareTo

      public int compareTo(ConsumableItem other)
      Specified by:
      compareTo in interface Comparable<ConsumableItem>
    • getImmunizations

      public Set<StatusType> getImmunizations()