Class AttackMove
java.lang.Object
com.csse3200.game.components.combat.move.CombatMove
com.csse3200.game.components.combat.move.AttackMove
Represents an attack move in combat. This class handles the execution of the attack and the
damage calculation based on various factors such as hunger, status effects, and the target's defense.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.csse3200.game.components.combat.move.CombatMove
CombatMove.StatsChange
-
Field Summary
Fields inherited from class com.csse3200.game.components.combat.move.CombatMove
hungerCost, moveName
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute
(CombatStatsComponent attackerStats) Execute the attack with only the attacker stats.execute
(CombatStatsComponent attackerStats, CombatStatsComponent targetStats) Execute the attack move, applying damage to the target.execute
(CombatStatsComponent attackerStats, CombatStatsComponent targetStats, boolean targetIsGuarded) Execute the attack move, applying damage to the target while accounting for whether the target is guarded.execute
(CombatStatsComponent attackerStats, CombatStatsComponent targetStats, boolean targetIsGuarded, int numHitsLanded) Execute the attack move, applying damage to the target with the option of multiple hits and adjusting damage for guarded targets.Methods inherited from class com.csse3200.game.components.combat.move.CombatMove
getHungerCost, getMoveName
-
Constructor Details
-
AttackMove
Constructor for the AttackMove.- Parameters:
moveName
- the name of the move.hungerCost
- the amount of hunger required to perform the move.
-
-
Method Details
-
execute
Execute the attack with only the attacker stats. Logs an error as more arguments are required for this method to be functional.- Specified by:
execute
in classCombatMove
- Parameters:
attackerStats
- combat stats of the attacker.- Returns:
- an empty array of
CombatMove.StatsChange
since this method cannot perform a valid attack.
-
execute
public CombatMove.StatsChange[] execute(CombatStatsComponent attackerStats, CombatStatsComponent targetStats) Execute the attack move, applying damage to the target.- Specified by:
execute
in classCombatMove
- Parameters:
attackerStats
- combat stats of the attacker.targetStats
- combat stats of the target.- Returns:
- an array of
CombatMove.StatsChange
representing the changes to combat stats resulting from the move, such as health or hunger adjustments.
-
execute
public CombatMove.StatsChange[] execute(CombatStatsComponent attackerStats, CombatStatsComponent targetStats, boolean targetIsGuarded) Execute the attack move, applying damage to the target while accounting for whether the target is guarded.- Specified by:
execute
in classCombatMove
- Parameters:
attackerStats
- combat stats of the attacker.targetStats
- combat stats of the target.targetIsGuarded
- true if the target is guarding, reducing the damage inflicted.- Returns:
- an array of
CombatMove.StatsChange
representing the changes to combat stats resulting from the move, such as health or hunger adjustments.
-
execute
public CombatMove.StatsChange[] execute(CombatStatsComponent attackerStats, CombatStatsComponent targetStats, boolean targetIsGuarded, int numHitsLanded) Execute the attack move, applying damage to the target with the option of multiple hits and adjusting damage for guarded targets.- Specified by:
execute
in classCombatMove
- Parameters:
attackerStats
- combat stats of the attacker.targetStats
- combat stats of the target.targetIsGuarded
- true if the target is guarding, reducing the damage inflicted.numHitsLanded
- the number of hits that successfully land during a multi-hit attack.- Returns:
- an array of
CombatMove.StatsChange
representing the changes to combat stats resulting from the move, such as health or hunger adjustments.
-