Items structure - UQcsse3200/2024-studio-1 GitHub Wiki

Structure of associated item classes and how they work together

DeployableItemFactory Class

  • The DeployableItemFactory is responsible for creating instances of deployable entities. It contains methods like createBearTrap(), createTargetDummy(), and createRingFire(), each of which sets up the components necessary for the specific item.
  • Entity Creation: Each method in this class returns an Entity, which is the core object representing in-game items and characters. The Entity is composed of different components that define its behavior and appearance.

CollectibleFactory Class

When a new collectible entity needs to be created, the CollectibleFactory is called with a specification. Depending on the type (item, buff, melee, or ranged) it will call either the ItemFactory or WeaponFactory to create the appropriate CollectibleItem. Once a 'Collectible' is created, CollectibleFactory can be used to compose an 'Entity' with the 'Collectible' previously created.

ItemFactory Class

Creates 'Collectible' items that are either a 'UsableItem' or a 'BuffItem'. A usable item is an item that can be stored in the inventory and used for later purposes whereas a buff item is an item that provides an immediate effect to the player upon pickup.

Collectible Interface

An interface implemented by various items that can be picked up and used in the game.

UsableItem Class

Implements the 'Collectible' interface and represents items that can be stored in the players inventory (e.g., 'MedKit', 'Bandage', 'ShieldPotion','BearTrap').

BuffItem Class

Implementes the 'Collectible' interface and represents items that apply effects to the player immediately upon pickup (e.g., EnergyDrink, Syringe, Heart, DivinePotion)

Medkit, Bandage, ShieldPotion Classes

All of these classes extend the 'UsableItem' class and each of these classes apply specific effects to the player.

EnergyDrink, Syringe, Heart, DivinePotion Class

This class extends the 'BuffItem' class and gives the player a specific buff.

UML diagram

UML

Sequence diagram

The sequence diagram are created using https://plantuml.com/

Medkit

Screenshot 2024-10-02 123625

Bandage

Screenshot 2024-10-02 123803

Syringe

Screenshot 2024-10-02 124021

Heart

Screenshot 2024-10-02 124201

Divine Potion

Screenshot 2024-10-02 124327

Bear Trap

Screenshot 2024-10-16 110947

Damage Buff (effect() method)

Sequence diagram

Energy Drink (effect() method)

Energy sequence

Shield Potion('apply()' method)

image

Reroll ('apply()' method)

Werewolf Fang ('effect()' method)