Package com.csse3200.game.effects
Class AreaEffect
java.lang.Object
com.csse3200.game.effects.Effect
com.csse3200.game.effects.AreaEffect
An
Effect
that applies multiple inner effects to all valid entities
within a certain radius of a central entity.
AreaEffect
is typically used for area-of-effect (AoE) items,
such as explosions, healing zones, or buffs/debuffs that impact
multiple nearby entities at once.
Validation rules:
- The effect list cannot be
null
or empty. - Inner effects cannot contain
null
values. - Nested
AreaEffect
s are not allowed (to prevent infinite recursion). - Radius must be strictly positive.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Applies this area effect to all entities within range of the given center entity.Gets the list of inner effects that this area effect applies.int
Gets the radius of the area in which this effect applies.
-
Field Details
-
effects
The list of effects to apply to each entity within the area. -
radius
public int radiusThe radius of the area (in world units).
-
-
Constructor Details
-
AreaEffect
Creates a newAreaEffect
.- Parameters:
effects
- list of effects to apply to entities in rangeradius
- radius of the effect area (must be positive)- Throws:
IllegalArgumentException
- if arguments are invalid (see validation rules)
-
-
Method Details
-
getEffects
Gets the list of inner effects that this area effect applies.- Returns:
- list of effects
-
getRadius
public int getRadius()Gets the radius of the area in which this effect applies.- Returns:
- radius of the effect
-
apply
Applies this area effect to all entities within range of the given center entity.Entities are affected if:
- They are within the radius (distance calculated from their center positions).
- They have a
CombatStatsComponent
. - They are not the player (identified by
PlayerActions
).
-