Class PlayerModifier

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.player.PlayerModifier

public class PlayerModifier extends Component
Self-sufficient player modifier handler for temporarily or permanently modifying player statistics. Takes in the
  • Field Details

  • 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.
      Overrides:
      create in class Component
    • 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.
      Overrides:
      update in class Component
    • getModifiers

      public List<PlayerModifier.Modifier> getModifiers()
      Public facing function to get modifier array for custom inspection.
      Returns:
      List of modifiers
    • getCombatStatsComponent

      public CombatStatsComponent getCombatStatsComponent()
      Public facing function to get CombatStatsComponent of the modifier system.
      Returns:
      CombatStatsComponent of the modifier system
    • getPlayerActions

      public PlayerActions getPlayerActions()
      Public facing function to get PlayerActions of the modifier system.
      Returns:
      PlayerActions of the modifier system
    • createModifier

      public boolean createModifier(String target, float value, boolean scaling, int expiry)
      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 increase
      scaling - Boolean flag to indicate if the increase value is multiplicative or additive
      expiry - Expiry time (milliseconds) of modifier, 0 if permanent
      Returns:
      True on success, false otherwise
    • checkModifier

      public boolean checkModifier(String target, float value, boolean scaling, int expiry)
      Public function to check if there is an already existing modifier with matching parameters
      Parameters:
      target - Desired player statistic.
      value - The value of the increase
      scaling - Boolean flag to indicate if the increase value is multiplicative or additive
      expiry - Expiry time (milliseconds) of modifier, 0 if permanent
      Returns:
      True if modifier exists, false otherwise
    • getModified

      public float getModified(String target)
      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 float getReference(String target)
      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.