Package com.deco2800.game.components
Class CombatStatsComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCombatStatsComponent
(int health, int baseAttack) CombatStatsComponent
(int health, int baseAttack, int defense) CombatStatsComponent
(int health, int baseAttack, int defense, int level) Combat Stats Component with extra parameter level to enable levelling up of entitiesCombatStatsComponent
(int health, int baseAttack, int defense, int level, int maxHealth) Combat Stats Component with maxHealth parameter to enable increase of maxHealth with each level upgrade independent to current health (For crystal) Implements baseAttack, defense which are no use to crystal as constructor with 3 parameters is already present -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttack
(int attackPower) void
addHealth
(int health) Adds to the player's health.int
int
Returns the entity's base attack damage.int
int
Returns the base health of the entityint
int
Returns the entity's health.int
getLevel()
int
void
hit
(CombatStatsComponent attacker) isDead()
Returns true if the entity's has 0 health, otherwise false.void
killEntity
(String entityName) Triggers listener events when certain entities should be killed.void
void
setAttackMultiplier
(int multiplier) void
setBaseAttack
(int attack) Sets the entity's attack damage.void
setBaseDefense
(int defense) void
setHealth
(int health) Sets the entity's health.void
setInvincibility
(Boolean state) void
setLevel
(int level) void
setMaxHealth
(int maxHealth) Sets the entity's maximum health.Methods inherited from class com.deco2800.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Field Details
-
CRYSTAL
- See Also:
-
PLAYER
- See Also:
-
-
Constructor Details
-
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack) -
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack, int defense) -
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack, int defense, int level) Combat Stats Component with extra parameter level to enable levelling up of entities -
CombatStatsComponent
public CombatStatsComponent(int health, int baseAttack, int defense, int level, int maxHealth) Combat Stats Component with maxHealth parameter to enable increase of maxHealth with each level upgrade independent to current health (For crystal) Implements baseAttack, defense which are no use to crystal as constructor with 3 parameters is already present
-
-
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
-
getLevel
public int getLevel() -
setHealth
public void setHealth(int health) Sets the entity's health. Health must be greater than 0. If the health value to be set exceeds the entities maximum health, it is capped at the maxHealth value. If the health value is 0 or less, the entity is killed.- Parameters:
health
- health
-
killEntity
Triggers listener events when certain entities should be killed. Each entity can be handled separately.- Parameters:
entityName
- the name of the entity to kill
-
setLevel
public void setLevel(int level) -
setMaxHealth
public void setMaxHealth(int maxHealth) Sets the entity's maximum health. Maximum health has a minimum bound of 0.- Parameters:
maxHealth
- maxHealth
-
addHealth
public void addHealth(int health) Adds to the player's health. The amount added can be negative.- Parameters:
health
- health to add
-
setAttackMultiplier
public void setAttackMultiplier(int multiplier) -
getAttackMultiplier
public int getAttackMultiplier() -
getBaseAttack
public int getBaseAttack()Returns the entity's base attack damage.- Returns:
- base attack damage
-
getCurrentAttack
public int getCurrentAttack() -
addAttack
public void addAttack(int attackPower) -
revertAttack
public void revertAttack() -
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
-
setInvincibility
-
setBaseDefense
public void setBaseDefense(int defense) -
getBaseDefense
public int getBaseDefense() -
getBaseHealth
public int getBaseHealth()Returns the base health of the entity- Returns:
- int
-
getMaxHealth
public int getMaxHealth()
-