Class HealingPotion


public class HealingPotion extends ConsumableItem
The HealingPotion class represents a specific type of potion that heals a player or game entity.

This class extends the TimedUseItem abstract class and provides an implementation of the method to apply its healing effects. A healing potion contains one or more objects that determine how much health is restored when the potion is used.

When a is created, it is initialized with a specific quantity (number of uses) and a list of effects. method is responsible for iterating through these effects and applying them when the potion is consumed.

The HealingPotion is typically used in the context of gameplay where players consume the potion to restore health. The specific effects of the potion are defined by theinstances passed to the constructor.

See Also:
  • Constructor Details

    • HealingPotion

      public HealingPotion(int quantity)
      Constructs a new HealingPotion with the specified quantity and a default healing effect.
      Parameters:
      quantity - the number of uses this potion has
  • Method Details

    • getEffectAmount

      public int getEffectAmount()
      Returns the effect amount of health potion
      Returns:
      the effect amount
    • useItem

      public void useItem(ItemUsageContext context)
      Uses the potion by healing the player a certain amount.
      Overrides:
      useItem in class ConsumableItem
      Parameters:
      context - the context in which the item is used (contains a player entity)