Class BoardHelper

java.lang.Object
megamek.common.board.BoardHelper

public final class BoardHelper extends Object
  • Method Details

    • enclosingBoardId

      public static int enclosingBoardId(Game game, BoardLocation boardLocation)
    • enclosingBoard

      @Deprecated(since="0.51.0", forRemoval=true) @Nullable public static Board enclosingBoard(Game game, BoardLocation boardLocation)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • enclosingBoard

      @Nullable public static Board enclosingBoard(Game game, int boardId)
    • enclosingBoard

      @Nullable public static Board enclosingBoard(Game game, Board board)
    • positionOnEnclosingBoard

      @Deprecated(since="0.51.0", forRemoval=true) @Nullable public static Coords positionOnEnclosingBoard(Game game, Board board)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • positionOnEnclosingBoard

      @Nullable public static Coords positionOnEnclosingBoard(Game game, int boardId)
    • onDifferentGroundMaps

      public static boolean onDifferentGroundMaps(Game game, Entity attacker, Targetable target)
    • isBoardEdge

      @Deprecated(since="0.51.0", forRemoval=true) public static boolean isBoardEdge(Board board, Coords coords)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • topEdge

      @Deprecated(since="0.51.0", forRemoval=true) public static List<Coords> topEdge(Board board)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • bottomEdge

      @Deprecated(since="0.51.0", forRemoval=true) public static List<Coords> bottomEdge(Board board)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • leftEdge

      @Deprecated(since="0.51.0", forRemoval=true) public static List<Coords> leftEdge(Board board)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • rightEdge

      @Deprecated(since="0.51.0", forRemoval=true) public static List<Coords> rightEdge(Board board)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • coordsLine

      public static List<Coords> coordsLine(Board board, Coords hexToCross, int facing)
      Returns the hexes of a straight line that has the given direction (facing) on the given Board and crosses the hex at the given hexToCross position. If the board is null or does not contain hexToCross, an empty list is returned. The coords are ordered so that each next hex lies in the given facing direction from the previous (e.g., if facing is 3 = south, the first hex in the resulting line will be on the northern board edge and the last hex on the southern board edge.)
      Parameters:
      board - The Board on which the line is located; its size determines that start and end of the line
      hexToCross - Coords that the line crosses
      facing - The direction of the line; also determines the order of the coords
      Returns:
      A Coords list forming a straight line across the board
    • coordsRow

      public static List<Coords> coordsRow(Board board, int y)
    • coordsColumn

      public static List<Coords> coordsColumn(Board board, int x)
    • isAtmosphericRow

      public static boolean isAtmosphericRow(Game game, Board board, Coords coords)
      Returns true when the given Coords is a hex of the atmospheric rows 1-4 (or 1-7 with very high atmosphere conditions) on a high-altitude map, false otherwise. Returns false for ground row hexes and for hexes of the space-atmosphere interface. Also returns false when planetary conditions indicate the atmosphere is "vacuum".
      Parameters:
      coords - The position on the board to test
      Returns:
      True for hexes of the atmospheric rows on a high-altitude map
    • isAtmosphericRow

      public static boolean isAtmosphericRow(Game game, Board board, int x)
      Returns true when the given X position is a hex of the atmospheric rows 1-4 (or 1-7 with very high atmosphere conditions) on a high-altitude map, false otherwise. Returns false for ground row hexes and for hexes of the space-atmosphere interface. Also returns false when planetary conditions indicate the atmosphere is "vacuum".
      Parameters:
      x - The X position on the board to test (Coords.getX())
      Returns:
      True for hexes of the atmospheric rows on a high-altitude map
    • isAtmosphericRow

      public static boolean isAtmosphericRow(Game game, BoardLocation boardLocation)
      Returns true when the given BoardLocation indicates a hex of the atmospheric rows 1-4 (or 1-7 with very high atmosphere conditions) on a high-altitude map, false otherwise. Returns false for ground row hexes and for hexes of the space-atmosphere interface. Also returns false when planetary conditions indicate the atmosphere is "vacuum".
      Parameters:
      boardLocation - The location to test
      Returns:
      True for hexes of the atmospheric rows on a high-altitude map
    • isBelowSpaceAtmosphereInterface

      public static boolean isBelowSpaceAtmosphereInterface(Game game, Board board, Coords coords)
      Returns true when the given Coords is a hex of the atmospheric rows 1-4 or the ground row on a high-altitude map, false if it is in the space/atmosphere interface or in true space. Returns false for all hexes if this board is not a high-altitude board or when planetary conditions indicate the atmosphere is "vacuum".
      Parameters:
      coords - The position on the board to test
      Returns:
      true for hexes of atmospheric rows 1-4 and the ground row on a high-altitude map
    • atmosphericRowNumber

      @Deprecated(since="0.51.0", forRemoval=true) public static int atmosphericRowNumber(Game game, Board board, Coords coords)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the number of the atmospheric row (i.e. 1 to 4 or 1 to 7 for very high atmosphere) of the given Coords on a high-altitude map (see TW p.79). For coords not in an atmospheric row or not on a high-altitude map, returns -1.
      Parameters:
      coords - The position on the board to test
      Returns:
      The number of the atmospheric row on a high-altitude map
    • effectiveAtmosphericRowNumber

      public static int effectiveAtmosphericRowNumber(Game game, Board board, Coords coords)
      Returns the number of the coords' atmospheric row (i.e. 1 to 4 or 1 to 7 for very high atmosphere) that is to be effectively used for rule purposes on a high-altitude map (see TW p.79). This takes into account atmosphere density, see Trace Atmosphere, TO:AR, p.52; in these conditions, it is not equal to atmosphericRowNumber(Game, Board, Coords). For coords not in an atmospheric row or not on a high-altitude map, returns -1.
      Parameters:
      coords - The position on the board to test
      Returns:
      The effective number of the atmospheric row on a high-altitude map
    • effectiveAtmosphericRowNumber

      public static int effectiveAtmosphericRowNumber(Game game, Board board, int x)
      Returns the number of the X position's atmospheric row (i.e. 1 to 4 or 1 to 7 for very high atmosphere) that is to be effectively used for rule purposes on a high-altitude map (see TW p.79). This takes into account atmosphere density, see Trace Atmosphere, TO:AR, p.52; in these conditions, it is not equal to atmosphericRowNumber(Game, Board, Coords). For coords not in an atmospheric row or not on a high-altitude map, returns -1.
      Parameters:
      x - The X position on the board to test (Coords.getX())
      Returns:
      The effective number of the atmospheric row on a high-altitude map
    • isSpaceAtmosphereInterface

      public static boolean isSpaceAtmosphereInterface(Game game, Board board, Coords coords)
      Returns true when the given Coords is a hex of the space-atmosphere interface on a high-altitude map, false otherwise.
      Parameters:
      coords - The position on the board to test
      Returns:
      true for hexes of the space-atmosphere interface on a high-atmosphere map
    • isGroundRowHex

      public static boolean isGroundRowHex(Board board, Coords coords)
      Returns true when the given Coords is a ground row hex on a high-atmospheric map, i.e. the lowermost row of hexes. Returns false for atmospheric and ground maps as well as for a space map that is not high-altitude. This is true for ground row hexes even if planetary conditions indicate the atmosphere is "vacuum".
      Parameters:
      coords - The position on the board to test
      Returns:
      true for the ground row hexes on a high atmospheric map
    • isGroundRowHex

      public static boolean isGroundRowHex(Board board, int x)
      Returns true when the given X position is a ground row hex on a high-atmospheric map, i.e. the lowermost row of hexes. Returns false for atmospheric and ground maps as well as for a space map that is not high-altitude. This is true for ground row hexes even if planetary conditions indicate the atmosphere is "vacuum".
      Parameters:
      x - The X position on the board to test
      Returns:
      true for the ground row hexes on a high atmospheric map
    • isTrueSpaceHex

      public static boolean isTrueSpaceHex(Game game, Board board, Coords coords)
      Returns true when the given Coords is a hex that is true space on a high-altitude map, i.e. beyond the space-atmosphere interface, or for any hex of a space map that is not a high-altitude map. Returns false for ground, atmospheric row and space-atmosphere interface hexes as well as for any hex of atmospheric and ground maps.
      Parameters:
      coords - The position on the board to test
      Returns:
      true for true space hexes on a space map
    • spaceAtmosphereInterfacePosition

      public static int spaceAtmosphereInterfacePosition(@Nullable Game game)
      Returns:
      The coordinate of the space-atmosphere interface in the given game (i.e., for the atmospheric pressure). Returns -1 for vacuum, 8 in very high atmospheric pressure and 5 otherwise. When game is null, the standard value of 5 is returned. When comparing with Coords (x, y), compare with the x value.
    • highAltAtmosphereRowRangeIncrease

      public static int highAltAtmosphereRowRangeIncrease(Game game)
    • highAltSpaceAtmosphereRangeIncrease

      public static int highAltSpaceAtmosphereRangeIncrease(Game game)
    • crossesSpaceAtmosphereInterface

      public static boolean crossesSpaceAtmosphereInterface(Game game, Board board, Coords position1, Coords position2)
      Returns true when a path between the two given positions on the given board crosses the space/atmosphere interface and the board is actually a high-altitude map. Returns false when the board is not a high-altitude board or when one or both positions are on the space/atmosphere interface or both positions are in ground row/atmospheric hexes or both positions are in true space.
      Parameters:
      game - The game
      board - The board to check
      position1 - The first position
      position2 - The second position
      Returns:
      True when a path between the two positions crosses the space/atmosphere interface