-
Notifications
You must be signed in to change notification settings - Fork 1
Consumable Item
Consumable Items is a subclass of Abstract Item class. Consumable items represent items in game that have limited amount of uses. Other classes such as Potions, Artefacts and Food will be subclasses of this class.
-
The ConsumableItem class represents the subclass from Abstract Item. Consumable items represent items in the game that have a limited amount of uses. Other classes such as Potions, Artefacts and Food will be subclasses of this class.
-
Unlike other infintie use items, Consumable items will have a limited quantity of uses which is decreased for every time the item is used (i.e. there are 3 potions and potions are used 3 times, thus, the quantity of potions is now 0 and the player can no longer use the item until they acquire more).
-
For managing the quantity, the function useItem has been modified to update the quantity count for each call. The effects for each consumable item will be later implemented in its subclasses.
Other subclasses of Consumable Items include:
This class overrides the useItem function by subtracting the quantity for each function call.
@Override
public void useItem(ItemUsageContext context) {
if (super.isEmpty()) {
throw new ConsumedException();
}
this.quantity--;
}
Items can be deemed consumable if they have a quantity greater than 0.