Class PlayerModifier
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.player.PlayerModifier
Self-sufficient player modifier handler for temporarily or permanently modifying player
statistics.
Takes in the
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkModifier
(String target, float value, boolean scaling, int expiry) Public function to check if there is an already existing modifier with matching parametersvoid
create()
Creation function to gather all necessary components for PlayerModified component to function.boolean
createModifier
(String target, float value, boolean scaling, int expiry) Public function for creating player modifiers.Public facing function to get CombatStatsComponent of the modifier system.float
getModified
(String target) Public function to return current modified value of a desired target.Public facing function to get modifier array for custom inspection.Public facing function to get PlayerActions of the modifier system.float
getReference
(String target) Public function to return current reference value of a desired target.void
update()
Triggers on frame update.Methods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Field Details
-
MOVESPEED
- See Also:
-
DMGREDUCTION
- See Also:
-
MANAREGEN
- See Also:
-
MANAMAX
- See Also:
-
STAMINAREGEN
- See Also:
-
STAMINAMAX
- See Also:
-
STAMINA
- See Also:
-
HEALTH
- See Also:
-
DMGRETURN
- See Also:
-
-
Constructor Details
-
PlayerModifier
public PlayerModifier()
-
-
Method Details
-
create
public void create()Creation function to gather all necessary components for PlayerModified component to function. Gathers all parent components and necessary stat variables within them. This function cannot yet be covered by Junit tests. -
update
public void update()Triggers on frame update. Searches through all modifiers present in ArrayList, and handles based on current system time and expiry time. -
getModifiers
Public facing function to get modifier array for custom inspection.- Returns:
- List of modifiers
-
getCombatStatsComponent
Public facing function to get CombatStatsComponent of the modifier system.- Returns:
- CombatStatsComponent of the modifier system
-
getPlayerActions
Public facing function to get PlayerActions of the modifier system.- Returns:
- PlayerActions of the modifier system
-
createModifier
Public function for creating player modifiers. Users will specify the target statistic, the value of increase, a boolean for additive (false) or multiplicative (true) modifiers, and the modifier length in milliseconds i.e. 1second = 1000ms (0 if the modifier is intended to be permanent). Modifiers are handled by the PlayerModifier update() override.- Parameters:
target
- Desired player statistic.value
- The value of the increasescaling
- Boolean flag to indicate if the increase value is multiplicative or additiveexpiry
- Expiry time (milliseconds) of modifier, 0 if permanent- Returns:
- True on success, false otherwise
-
checkModifier
Public function to check if there is an already existing modifier with matching parameters- Parameters:
target
- Desired player statistic.value
- The value of the increasescaling
- Boolean flag to indicate if the increase value is multiplicative or additiveexpiry
- Expiry time (milliseconds) of modifier, 0 if permanent- Returns:
- True if modifier exists, false otherwise
-
getModified
Public function to return current modified value of a desired target.- Parameters:
target
- Desired player statistic.- Returns:
- Float value of the desired modified target statistic, else -1 on fail.
-
getReference
Public function to return current reference value of a desired target.- Parameters:
target
- Desired player statistic.- Returns:
- Float value of the desired reference target statistic, else -1 on fail.
-