Class CombatStatsComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.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. health: the current health of the entity baseAttack: the base attack of the entity fullHealth: the full health of the entity state: the current state of the entity (full health above 66%, half health above 33%, low health below 33%) drops: the items that the entity drops when it dies closeRangeAbilities: the Melee abilities (close range) of the entity longRangeAbilities: the Projectile abilities (long range) of the entity
  • Constructor Details

  • 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
    • setHealth

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

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

      public int getMaxHealth()
      Returns the entity's fullHealth value (note that this does not influence the ability to set its actual health)
      Returns:
      The entity's fullHealth variable
    • setMaxHealth

      public void setMaxHealth(int newMaxHealth)
      Sets the entity's fullHealth variable. Intended for when the entity's maximum health must be changed after creation, like upgrading a turret's HP.
      Parameters:
      newMaxHealth - The new value fullHealth should be set to
    • 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
    • hit

      public void hit(Integer damage)
      Decrease the health of the entity based on the damage provided.
    • hit

      public void hit(CombatStatsComponent attacker)
    • pickRandom

      public int pickRandom(ArrayList pickFrom)
      Picks a random number from range 0 to the size of the list provided.
    • drop

      public Currency drop()
    • longRangeAttack

      public ProjectileConfig longRangeAttack()
      If there are long range attacks provided, return a random one, else return null
    • withinRange

      public ArrayList<Melee> withinRange(Entity target)
      Check if the target is within range of any of the close range attacks. Return a list of close range attacks which can be used
    • getWeapon

      public Weapon getWeapon(Entity target)
      Return a close range attack if the target is within range, else return a long range attack
    • changeState

      public void changeState()
      Change the state of the enemy based on the health
    • getState

      public String getState()
      Return the state of the enemy fullHealth: above 66% of full health midHealth: above 33% of full health lowHealth: below 33% of full health
    • updateHealth

      public void updateHealth(int setTo)
      Update the health of the enemy. Used in WaveFactory to increase difficulty of enemies