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

    • playerWeapon

      public Entity playerWeapon
  • Constructor Details

    • CombatStatsComponent

      public CombatStatsComponent(int health, int baseAttack, int stamina, int mana)
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • 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
    • reduceHealth

      public void reduceHealth(int health)
    • 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(CombatStatsComponent attacker)
      Reduce entity health due to an attack. Decreases by the damage reduction multiplier. If the attacker is a player, checks if the player has any weapon equipped, and use the damage of the weapon instead of the player's base attack damage.
      Parameters:
      attacker - Attacking entity combatstats component
    • getStamina

      public int getStamina()
      Returns the entity's stamina.
      Returns:
      entity's stamina
    • setStamina

      public void setStamina(int stamina)
      Sets the entity's stamina. Stamina has a minimum bound of 0 and a maximum bound of the max stamina.
      Parameters:
      stamina - stamina
    • addStamina

      public void addStamina(int stamina)
      Adds to the player's stamina. The amount added can be negative.
      Parameters:
      stamina - stamina to add
    • getMaxStamina

      public int getMaxStamina()
      Gets the player's maximum stamina.
      Returns:
      maxStamina player's maximum stamina.
    • setMaxStamina

      public void setMaxStamina(int maxStamina)
      Sets the entity's maximum stamina. Max stamina has a minimum bound of 0.
      Parameters:
      maxStamina - player's maximum stamina.
    • setStaminaRegenerationRate

      public void setStaminaRegenerationRate(int staminaRegenerationRate)
      Sets the entity's stamina regeneration rate.
      Parameters:
      staminaRegenerationRate - entity's stamina regeneration rate
    • getStaminaRegenerationRate

      public int getStaminaRegenerationRate()
      Gets the entity's stamina regeneration rate.
      Returns:
      staminaRegenerationRate entity's stamina regeneration rate
    • getMana

      public int getMana()
      Returns the entity's mana.
      Returns:
      entity's mana
    • setMana

      public void setMana(int mana)
      Sets the entity's mana. Stamina has a minimum bound of 0 and a maximum bound of the max mana.
      Parameters:
      mana - mana
    • addMana

      public void addMana(int mana)
      Adds to the player's mana. The amount added can be negative.
      Parameters:
      mana - mana to add
    • getMaxMana

      public int getMaxMana()
      Gets the player's maximum mana
      Returns:
      maxMana player's maximum mana.
    • setMaxMana

      public void setMaxMana(int maxMana)
      Sets the entity's maximum mana. Max mana has a minimum bound of 0.
      Parameters:
      maxMana - player's maximum mana.
    • setManaRegenerationRate

      public void setManaRegenerationRate(int manaRegenerationRate)
      Sets the entity's RegenerationRate regeneration rate.
      Parameters:
      manaRegenerationRate - entity's stamina regeneration rate
    • getManaRegenerationRate

      public int getManaRegenerationRate()
      Gets the entity's mana regeneration rate.
      Returns:
      manaRegenerationRate entity's mana regeneration rate
    • checkMana

      public boolean checkMana(int mana)
      check whether the mana is enough
      Parameters:
      mana -
      Returns:
    • checkStamina

      public boolean checkStamina(int stamina)
      check whether the stamina is enough
      Parameters:
      stamina -
      Returns:
    • setDamageReduction

      public void setDamageReduction(float damageReduction)
      Sets the entity's damage reduction. Damage reduction damage has a minimum bound of 0.
      Parameters:
      damageReduction - Attack damage
    • getDamageReduction

      public float getDamageReduction()
      Returns the current damageReduction stat.
      Returns:
      The float value of damageReduction.
    • getDamageReturn

      public float getDamageReturn()
      Returns the current damageReturn stat.
      Returns:
      The float value of damageReturn.
    • setDamageReturn

      public void setDamageReturn(float damageReturn)
      Sets the entity's damage return. Damage reduction damage has a minimum bound of 0.
      Parameters:
      damageReturn -
    • dropWeapon

      public void dropWeapon()
      If the current entity is a player, then the function is called on a key press and drops a weapon on the map only if the player is equipped with a weapon. If the current entity is an enemy, then the function is called when the enemy is dead and a weapon is dropped below the enemy.
    • dropMaterial

      public void dropMaterial()
      Method that picks a random material on the map to drop once an enemy is killed. 20% change of gold 10% chance of silver 10% chance of rubber 10% chance of platinum 10% chance of iron 10% chance of wood 10% chance of steel