Package com.csse3200.game.components
Class CombatStatsComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.CombatStatsComponent
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 Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCombatStatsComponent
(int health, int baseAttack) CombatStatsComponent
(int health, int baseAttack, int gold) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGold
(int gold) Adds to the player's gold.void
addHealth
(int health) Adds to the player's health.int
Returns the entity's base attack damage.int
getGold()
Returns the entity's gold.int
Returns the entity's health.void
hit
(CombatStatsComponent attacker) isDead()
Returns true if the entity's has 0 health, otherwise false.void
setBaseAttack
(int attack) Sets the entity's attack damage.void
setGold
(int gold) Sets the entity's gold.void
setHealth
(int health) Sets the entity's health.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack) -
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack, int gold)
-
-
Method Details
-
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
-
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
-
setGold
public void setGold(int gold) Sets the entity's gold. Gold has a minimum bound of 0.- Parameters:
gold
- gold
-
addGold
public void addGold(int gold) Adds to the player's gold. The amount added can be negative.- Parameters:
gold
- gold to add
-
getGold
public int getGold()Returns the entity's gold.- Returns:
- entity's gold
-