Skip to content
PHONGNGYUEN1 edited this page Sep 9, 2024 · 40 revisions

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 and quantity. 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

Concrete subclasses (actual in-game items) include various Food classes and the healing potion class. Food classes include:

Player interaction

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 using ChatOverlay to inform user can pick up the certain item in range using key command "P". This is all handled in ItemProximityTask and ItemFactory

image

UML Diagram

image

Clone this wiki locally