Class ZoneManager

java.lang.Object
model.game.ZoneManager

public class ZoneManager extends Object
Shrinking Zone system. Every 8 rounds the safe zone shrinks by 1 cell. Players standing on lava take 10 HP damage every round.
  • Field Details

    • SHRINK_INTERVAL

      private static final int SHRINK_INTERVAL
      Number 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_DAMAGE
      Amount 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 currentRadius
      Current 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

      public boolean onRoundEnd(int round, MapGrid map)
      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 number
      map - Map whose cells will be updated
      Returns:
      true if the zone shrank this round
    • convertNewlyExposedCellsToLava

      private void convertNewlyExposedCellsToLava(MapGrid map)
      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 cell
      col - Column of the cell
      Returns:
      true if the cell is outside the safe zone
    • applyZoneDamage

      public boolean applyZoneDamage(Player p1, Player p2, MapGrid map)
      Applies zone damage to any player standing on lava.
      Parameters:
      p1 - Player 1
      p2 - Player 2
      map - Current map
      Returns:
      true if at least one player took damage
    • getCurrentRadius

      public int getCurrentRadius()
      Returns:
      Current safe zone radius
    • getZoneDamage

      public int getZoneDamage()
      Returns:
      Damage per round when standing on lava