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.
  • Constructor Details

    • CombatStatsComponent

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

      public CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed)
    • CombatStatsComponent

      public CombatStatsComponent(int troops, int health, int baseAttack, int baseDefence, float landSpeed, int range)
  • Method Details

    • update

      public void update()
      Description copied from class: Component
      Called once per frame of the game, and should be used for most component logic. Not called if component is disabled.
      Overrides:
      update in class Component
    • getRange

      public int getRange()
      Returns the attack range for unit
      Returns:
      entity's attack range
    • setRange

      public void setRange(int range)
      Sets the attack range for a unit
      Parameters:
      range - attack for unit
    • getTroops

      public int getTroops()
      Returns number of troops the unit has
      Returns:
      entity's troop count
    • setTroops

      public void setTroops(int troops)
      Sets the number of troops the unit has
      Parameters:
      troops - number of troops to set.
    • getLandSpeed

      public float getLandSpeed()
      Returns the land movement speed of the unit
      Returns:
      land movement speed of unit
    • setLandSpeed

      public void setLandSpeed(float landSpeed)
      Sets the land movement speed of unit
      Parameters:
      landSpeed - land movement speed to set
    • isDead

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

      public Boolean isMaxHealth()
    • getHealth

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

      public int getMaxHealth()
      Get's the entity's maximum health.
      Returns:
      entity's maximum health
    • setHealth

      public void setHealth(int health)
      Sets the entity's health. Health has a minimum bound of 0.
      Parameters:
      health - health
    • setMaxHealth

      public void setMaxHealth(int maxHealth)
      Sets the entity's maximum health. Maximum Health must be greater than or equal to 0.
      Parameters:
      maxHealth - Maximum health an entity can have
    • addHealth

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

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

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

      public void setBaseDefence(int defence)
      Sets the entity's defence from attacks. Defence has a minimum bound of 0.
      Parameters:
      defence - Attack defence
    • getBaseDefence

      public int getBaseDefence()
      Returns the entity's base defence.
      Returns:
      base defence
    • hit

      public void hit(CombatStatsComponent attacker)
      Manages the entity being hit by an attacking enemy. Combatant takes damage equal to the attacker's attack less this entity's defence, with a minimum bound of 1.
      Parameters:
      attacker - The Combat Stats of an attacking entity
    • decreaseHealth

      public void decreaseHealth(int damage)