Class HealingPotion
java.lang.Object
com.csse3200.game.inventory.items.AbstractItem
com.csse3200.game.inventory.items.ConsumableItem
com.csse3200.game.inventory.items.potions.HealingPotion
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:
-
Field Summary
Fields inherited from class com.csse3200.game.inventory.items.AbstractItem
description, itemCode, limit, name, onlyCombatItem, onlyMapItem, quantity
-
Constructor Summary
ConstructorsConstructorDescriptionHealingPotion
(int quantity) Constructs a newHealingPotion
with the specified quantity and a default healing effect. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the effect amount of health potionvoid
useItem
(ItemUsageContext context) Uses the potion by healing the player a certain amount.Methods inherited from class com.csse3200.game.inventory.items.AbstractItem
add, getDescription, getItemCode, getLimit, getName, getQuantity, getTexturePath, isEmpty, numAddable, onlyCombatItem, onlyMapItem, setDescription, setTexturePath
-
Constructor Details
-
HealingPotion
public HealingPotion(int quantity) Constructs a newHealingPotion
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
Uses the potion by healing the player a certain amount.- Overrides:
useItem
in classConsumableItem
- Parameters:
context
- the context in which the item is used (contains a player entity)
-