Class HealthEffect

java.lang.Object
com.csse3200.game.effects.Effect
com.csse3200.game.effects.HealthEffect

public class HealthEffect extends Effect
An Effect that modifies an entity's health by applying damage or healing.

The effect decreases the target entity's health by the specified damage amount when applied. A negative damage value can be used to heal the entity instead.

  • Constructor Details

    • HealthEffect

      public HealthEffect(int damage)
      Creates a new health effect.
      Parameters:
      damage - the amount of health to subtract from the target entity; use negative values to heal
  • Method Details

    • apply

      public boolean apply(Entity entity)
      Applies the health effect to the given entity.

      If the entity has a CombatStatsComponent, its health is reduced by damage. Otherwise, the effect has no impact.

      Specified by:
      apply in class Effect
      Parameters:
      entity - the entity receiving the effect
      Returns:
      true if the effect was applied, false if the entity had no combat stats