Buff items - UQcsse3200/2024-studio-1 GitHub Wiki

Overview

Compared to UsableItems, a buff item is not added to the inventory and thus, cannot be used at any time by the player. Instead, buff items immediately apply an effect upon pickup. The buff items impact the player in various ways, such as the speed of the player, the player's total damage, or creating a pet for the player.

Key features of buff items

  • The type: Buff items have the type Type.BUFF_ITEM
  • Picking up a buff item: The pickup method of the buff item is different from the UsableItems, as such, the effect() method of the item is immediately called in the pickup() method of the item.
  • The specification: The specification of a buff item differs from UsableItems, where it includes "buff:" plus the buff item specification (eg. "buff:damagebuff")

Relevant Classes

  • BuffItem.java: An abstract class for all BuffItems
  • ItemPickupComponent.java: Calls the pickup() method of the buff item

Energy drink class usage and details

Energy drink creation

  • When creating an energydrink, you must also specify what kind of speed power you would like it to have. This is either high, medium or low...
CollectibleFactory collectibleFactory = new CollectibleFactory()
Entity collectible = collectibleFactory.createCollectibleEntity("buff:energydrink:high")
//Creates an energy drink with "High" speed

Relevant classes

  • EnergyDrink.java: The class for an energy drink
  • PlayerActions.java: Contains methods responsible for updating and obtaining the player's speed. These methods also help in updating the UI showing the player's speed.
  • PlayerStatsDisplay: Contains methods that update the speed UI

Important features

  • The "speedType" of an energy drink: An energy drink has three different speed types, including "low", "medium" and "high".
  • The effect of the energy drink: Refer to effect() of the EnnergyDrink class Depending on the speedType of this specific energy drink, the associated 'speed' vector is added to the player's current speed.
  • Setting the speed depending on the type of energy drink: Refer to setScalar() of the EnergyDrink class. This method is called when the effect() method is called. It sets the specific speed effect based on the 'speedType' parameter that was obtained previously from the specification.
  • Different icons: Refer to setIcon() of the EnergyDrink class. This method is called when an EnergyDrink class is first initialized. It sets the icon of this energy drink based on the 'speedType' parameter that was obtained previously from the specification. As such, a "low" powered energy drink is blue, "medium" is purple and "high" is red.

Testing

This item is tested in EnergyDrinkTest.java

Damge buff item class usage and details

Damage buff item creation

  • The damage buff item is created using...
CollectibleFactory collectibleFactory = new CollectibleFactory()
Entity collectible = collectibleFactory.createCollectibleEntity("buff:damagebuff")
//Creates a new damage buff item

Relevant classes

  • DamageBuff.java: The class for a damage buff item

Important features

  • The effect method: Refer to the effect() method of the DamageBuff class. Applies the effect to the player that increases total damage

DamageBuff

Testing

This item is currently tested in DamageBuffTest.java

Tombstone item class usage and details

Tombstone item creation

  • The tombstone item is created using...
CollectibleFactory collectibleFactory = new CollectibleFactory()
Entity collectible = collectibleFactory.createCollectibleEntity("buff:tombstone")
//Creates a new tombstone buff item

Relevant classes

Important features

  • Effect of this item: Refer to effect() method. This method is called when the tombstone item is initialised. This method selects a random number then accesses the randomPetGenerator() to declare the pet. This specification creates the entity of the pet in the PetFactory.java which is then spawned by the effect() method. This can be seen below:

Testing

Heart item class usage and details

Relevant classes

Heart.java: The class for the Heart item, which increases the player's max health by a specified amount, up to a limit, and fully restores current health when picked up.

CombatStatsComponent.java: Manages the player's health. The Heart item uses this component to get and set the player's current and maximum health.

Important features

Effect of this item: The effect() method in the Heart class increases the player's maximum health by a specified amount, up to a set limit. It also restores the player's current health to the new maximum value after the increase.

Screenshot 2024-10-02 120631

Testing

This item is tested in HeartTest.java

Divine Potion item class usage and details

Relevant classes

DivinePotion.java: The class for the Divine Potion item, which boosts the player's speed, increases health by a set amount, and ensures the health and the speed does not exceed the maximum health and the maximum speed limit respectively.

CombatStatsComponent.java: Manages the player's health. The DivinePotion item uses this component to set the player's health.

PlayerActions.java: Controls the player's movement and speed. The Divine Potion interacts with this component to apply a speed boost and manage speed constraints.

Important features

Effect of this item: The effect() method in the Divine Potion class increases the player's health by a fixed amount using the Boost() method and applies a speed boost using the speed() method.

Screenshot 2024-10-02 121622

Boost():Increases the player's current health by a fixed amount, up to their maximum health limit.

Screenshot 2024-10-02 121748

speed():Applies a speed boost to the player, ensuring the speed doesn't exceed the maximum allowed limit.

image

Testing

This item is tested in DivinePotionTest.java