-
Notifications
You must be signed in to change notification settings - Fork 1
Items
All existing items are subclasses of the Abstract Item class which manages the item's properties and provides players special effects to improve their game performance i.e. improve their stats and restore their health and hunger when convenient. Items will represent in-game items a player can hold in their inventory or around the map. Here is an overview of how the Items are structured:
-
AbstractItems: The abstract class with variables and methods to supply information about the items. This includes the item's
name
,itemCode
,limit
andquantity
. These fields will be used to differentiate each item and categorise them in the Inventory -
ConsumableItem: A class that overrides AbstrcatItems to implement the generic functionality of the function
useItems
, This class is for expendable items and are used to improve players' stat performance. -
TimedUsedItem: Overides methods from the ConsumableClass to implement temporary effects towards player's stats. This class introduces a field
effectAmount
- the amount to be applied towards their designated player stat. - ItemProximityTask - This is the list of actions the player must take to pick up an item on the map. It detects when a player is in proximity to the item
-
ConsumedException: Throws an error if the item has no
quantity
left to use the item. - ItemUsageContext: This class is used to keep track of the items usage activity through the game
Another important concept to understand when using items and implementing new items is the ItemUsageContext class (essentially a wrapper around all possible inputs required to use an item). Please read through that page before attempting to use/add any new concrete items.
Other abstract subclasses of Abstract Item include Consumable Items
The test plan is as follows: Creation: Ensures the items have been created with the correct fields Interaction: Ensures the items can be picked up on the map and interact with the Inventory Display. They can also interact with the player stats to apply their effects to their stat.
Concrete subclasses (actual in-game items) include various Food classes and the healing potion class. Food classes include:
Potions classes include:
- Health Potion
- Defense Potion
- Attack Potion
- Speed Potion
The expected interaction between the player and items is that when a user comes in a certain range (2.0f) of the item the functionality @pickUpItem
can be activated which is also displayed as a pop-up dialogue to inform the user can pick up the certain item in range using key command "P". This is all handled in ItemProximityTask
and ItemFactory
This diagram represents the overview of the Items and their action in the game and their interaction with the display and player stats