Class CombatStatsComponent

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.CombatStatsComponent

public class CombatStatsComponent extends Component
Component used to store information related to combat such as health, attack, etc. Any entities which engage it combat should have an instance of this class registered. This class can be extended for more specific combat needs.
  • Field Details

  • Constructor Details

    • CombatStatsComponent

      public CombatStatsComponent(int health, int baseAttack)
    • CombatStatsComponent

      public CombatStatsComponent(int health, int baseAttack, int defense)
    • CombatStatsComponent

      public CombatStatsComponent(int health, int baseAttack, int defense, int level)
      Combat Stats Component with extra parameter level to enable levelling up of entities
    • CombatStatsComponent

      public CombatStatsComponent(int health, int baseAttack, int defense, int level, int maxHealth)
      Combat Stats Component with maxHealth parameter to enable increase of maxHealth with each level upgrade independent to current health (For crystal) Implements baseAttack, defense which are no use to crystal as constructor with 3 parameters is already present
  • Method Details

    • isDead

      public Boolean isDead()
      Returns true if the entity's has 0 health, otherwise false.
      Returns:
      is player dead
    • getHealth

      public int getHealth()
      Returns the entity's health.
      Returns:
      entity's health
    • getLevel

      public int getLevel()
    • setHealth

      public void setHealth(int health)
      Sets the entity's health. Health must be greater than 0. If the health value to be set exceeds the entities maximum health, it is capped at the maxHealth value. If the health value is 0 or less, the entity is killed.
      Parameters:
      health - health
    • killEntity

      public void killEntity(String entityName)
      Triggers listener events when certain entities should be killed. Each entity can be handled separately.
      Parameters:
      entityName - the name of the entity to kill
    • setLevel

      public void setLevel(int level)
    • setMaxHealth

      public void setMaxHealth(int maxHealth)
      Sets the entity's maximum health. Maximum health has a minimum bound of 0.
      Parameters:
      maxHealth - maxHealth
    • addHealth

      public void addHealth(int health)
      Adds to the player's health. The amount added can be negative.
      Parameters:
      health - health to add
    • setAttackMultiplier

      public void setAttackMultiplier(int multiplier)
    • getAttackMultiplier

      public int getAttackMultiplier()
    • getBaseAttack

      public int getBaseAttack()
      Returns the entity's base attack damage.
      Returns:
      base attack damage
    • getCurrentAttack

      public int getCurrentAttack()
    • addAttack

      public void addAttack(int attackPower)
    • revertAttack

      public void revertAttack()
    • setBaseAttack

      public void setBaseAttack(int attack)
      Sets the entity's attack damage. Attack damage has a minimum bound of 0.
      Parameters:
      attack - Attack damage
    • hit

      public void hit(CombatStatsComponent attacker)
    • setInvincibility

      public void setInvincibility(Boolean state)
    • setBaseDefense

      public void setBaseDefense(int defense)
    • getBaseDefense

      public int getBaseDefense()
    • getBaseHealth

      public int getBaseHealth()
      Returns the base health of the entity
      Returns:
      int
    • getMaxHealth

      public int getMaxHealth()