Class DefensePotion


public class DefensePotion extends TimedUseItem
The DefensePotion class represents a specific type of potion that temporarily increases the defense a player.

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

When a is created, it is initialized with a specific quantity (number of uses)

The DefensePotion is typically used in the context of gameplay where players consume the potion to temporarily increase defense. The specific effects of the potion are defined by the instances passed to the constructor.

See Also:
  • Constructor Details

    • DefensePotion

      public DefensePotion(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

    • useItem

      public void useItem(ItemUsageContext context)
      Uses the potion by applying its effects and decreasing its number of uses. If no uses are left, the potion is marked as empty.
      Overrides:
      useItem in class TimedUseItem
      Parameters:
      context - the context in which the item is used (contains a Player to use on)
    • update

      public void update(ItemUsageContext context)
      Updates the potion state, checking if the effect duration has elapsed.
      Specified by:
      update in class TimedUseItem
      Parameters:
      context - the context in which the item is used (contains a Player to use on)