Class DefensePotion
java.lang.Object
com.csse3200.game.inventory.items.AbstractItem
com.csse3200.game.inventory.items.ConsumableItem
com.csse3200.game.inventory.items.TimedUseItem
com.csse3200.game.inventory.items.potions.DefensePotion
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:
-
Field Summary
Fields inherited from class com.csse3200.game.inventory.items.TimedUseItem
effectAmount, effectStartTime, gameTime, warn
Fields inherited from class com.csse3200.game.inventory.items.AbstractItem
description, itemCode, limit, name, onlyCombatItem, onlyMapItem, quantity
-
Constructor Summary
ConstructorsConstructorDescriptionDefensePotion
(int quantity) Constructs a newHealingPotion
with the specified quantity and a default healing effect. -
Method Summary
Modifier and TypeMethodDescriptionvoid
update
(ItemUsageContext context) Updates the potion state, checking if the effect duration has elapsed.void
useItem
(ItemUsageContext context) Uses the potion by applying its effects and decreasing its number of uses.Methods inherited from class com.csse3200.game.inventory.items.TimedUseItem
getDuration, getGameTime, getWarning
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
-
DefensePotion
public DefensePotion(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
-
useItem
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 classTimedUseItem
- Parameters:
context
- the context in which the item is used (contains a Player to use on)
-
update
Updates the potion state, checking if the effect duration has elapsed.- Specified by:
update
in classTimedUseItem
- Parameters:
context
- the context in which the item is used (contains a Player to use on)
-