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

    • CombatStatsComponent

      public CombatStatsComponent(int health)
      Construct a combat Stats Component (Health + Attack System)
      Parameters:
      health - initial health (values < 0 are clamped to 0)
  • Method Details

    • isDead

      public Boolean isDead()
      Checks whether this entity is dead.

      An entity is considered dead if its health is less than or equal to zero.

      Returns:
      true if the entity has 0 or less health, false otherwise
    • getHealth

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

      public void takeDamage(int damage)
    • setHealth

      public void setHealth(int health)
      Sets the entity's health. Health is always clamped between 0 and maxHealth.
      Parameters:
      health - new health value
    • addHealth

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

      public void setMaxHealth(int maxHealth)
      Sets the entity's Max Health. Max Health has a minimum bound of 0.
      Parameters:
      maxHealth - the maximum health that an entity can have
    • getMaxHealth

      public int getMaxHealth()
      Sets the entity's maximum health
      Returns:
      the entity's maximum health (never negative)
    • upgradeMaxHealth

      public void upgradeMaxHealth()

      Doubles player maximum health when player interacts with a HealthBench. Only applied once.