Class ZoneManager
java.lang.Object
model.game.ZoneManager
Shrinking Zone system. Every 8 rounds the safe zone shrinks by 1 cell.
Players standing on lava take 10 HP damage every round.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intCurrent radius of the safe zone (starts at 5, i.e.private static final intNumber of rounds before the zone shrinks by 1 cell.private static final intAmount of HP a player loses per round when standing on lava. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a ZoneManager with the initial radius set to half the map size. -
Method Summary
Modifier and TypeMethodDescriptionbooleanapplyZoneDamage(Player p1, Player p2, MapGrid map) Applies zone damage to any player standing on lava.private voidConverts all cells outside the safe zone to lava and removes any items or goblins on those cells.intintbooleanisOutsideZone(int row, int col) Checks whether a cell is outside the safe zone using Chebyshev distance from the map centre.booleanonRoundEnd(int round, MapGrid map) Called at the end of every round to check whether the zone should shrink.
-
Field Details
-
SHRINK_INTERVAL
private static final int SHRINK_INTERVALNumber of rounds before the zone shrinks by 1 cell. For example, with SHRINK_INTERVAL = 8, the zone shrinks on rounds 8, 16, 24, ...- See Also:
-
ZONE_DAMAGE
private static final int ZONE_DAMAGEAmount of HP a player loses per round when standing on lava. Applied at the end of every round via applyZoneDamage().- See Also:
-
currentRadius
private int currentRadiusCurrent radius of the safe zone (starts at 5, i.e. half the map size).
-
-
Constructor Details
-
ZoneManager
public ZoneManager()Creates a ZoneManager with the initial radius set to half the map size.
-
-
Method Details
-
onRoundEnd
Called at the end of every round to check whether the zone should shrink. If so, the radius is decremented and newly exposed cells are converted to lava.- Parameters:
round- Current round numbermap- Map whose cells will be updated- Returns:
trueif the zone shrank this round
-
convertNewlyExposedCellsToLava
Converts all cells outside the safe zone to lava and removes any items or goblins on those cells.- Parameters:
map- Map to update
-
isOutsideZone
public boolean isOutsideZone(int row, int col) Checks whether a cell is outside the safe zone using Chebyshev distance from the map centre.- Parameters:
row- Row of the cellcol- Column of the cell- Returns:
trueif the cell is outside the safe zone
-
applyZoneDamage
-
getCurrentRadius
public int getCurrentRadius()- Returns:
- Current safe zone radius
-
getZoneDamage
public int getZoneDamage()- Returns:
- Damage per round when standing on lava
-