Class AttackMove

java.lang.Object
com.csse3200.game.components.combat.move.CombatMove
com.csse3200.game.components.combat.move.AttackMove

public class AttackMove extends CombatMove
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.
  • Constructor Details

    • AttackMove

      public AttackMove(String moveName, int hungerCost)
      Constructor for the AttackMove.
      Parameters:
      moveName - the name of the move.
      hungerCost - the amount of hunger required to perform the move.
  • Method Details

    • execute

      public CombatMove.StatsChange[] execute(CombatStatsComponent attackerStats)
      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 class CombatMove
      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 class CombatMove
      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 class CombatMove
      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 class CombatMove
      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.