Class BoardUtilities

java.lang.Object
megamek.common.util.BoardUtilities

public class BoardUtilities extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static void
    addCliffs(Board board, int modifier)
     
    static void
    addCraters(Board board, int minRadius, int maxRadius, int minCraters, int maxCraters)
    add a crater to the board
    static void
    addRiver(Board board, Map<Hex,Point> reverseHex)
    Adds a River to the map (if the map is at least 5x5 hexes big).
    static void
    addWeatherConditions(Board board, Weather weatherCond, Wind windCond)
     
    static Board
    combine(int width, int height, int sheetWidth, int sheetHeight, List<Board> boards, List<Boolean> isRotated, int medium)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static Board
    combine(int width, int height, int sheetWidth, int sheetHeight, Board[] boards, int medium)
    Combines one or more boards into one huge mega board!
    static Board
    combine(int width, int height, int sheetWidth, int sheetHeight, Board[] boards, int medium, int columnPaddingWidth)
    Combines one or more boards into one huge mega board!
    static Board
    combine(int width, int height, int sheetWidth, int sheetHeight, Board[] boards, List<Boolean> isRotated, int medium)
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected static void
    copyBoardInto(Hex[] dest, int destWidth, int x, int y, Board copied)
    Copies the data of another board into given array of Hexes, offset by the specified x and y.
    static int
    craterProfile(int distanceFromCenter, int fullRadius, int maxDepth)
     
    protected static void
    cutSteps(int hilliness, int width, int height, int[][] elevationMap)
    one of the landscape generation algorithms
    Figures out the "opposite" edge for the given entity.
    protected static void
    diagMid(Point p, int d1, int d2, int delta, int size, int[][] elevationMap)
    calculates the diagonal middle points with new values
    static void
    flip(Board board, boolean horiz, boolean vert)
    Flips the board around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West).
    static void
    generateElevation(int hilliness, int width, int height, int range, int invertProb, int invertNegative, int[][] elevationMap, int algorithm)
    Generates the elevations
    static void
    generateMountain(Board board, int width, Coords centre, int height, int capStyle)
     
    static Board
    Generates a Random Board
    static int
     
    Figures out the "closest" edge for the given entity on the entity's game board
    protected static void
    markRect(int x1, int x2, int inc, int[][] elevationMap, int height)
    Helper function for the map generator increased a heightmap by a given value
    protected static void
    markSides(Point p1, Point p2, int upperInc, int lowerInc, int[][] elevationMap, int height)
    Helper function for map generator increases all of one side and decreased on other side
    protected static int
    middleValue(int a, int b, int c, int delta)
    calculates the arithmetic medium of 3 values and add random value in range of delta.
    protected static int
    middleValue(int a, int b, int c, int d, int delta)
    calculates the arithmetic medium of 4 values and add random value in range of delta.
    protected static void
    midPoint(int hilliness, int width, int height, int[][] elevationMap)
    midpoint algorithm for landscape generation
    protected static void
    midPointStep(double fractionalDim, int size, int delta, int[][] elevationMap, int step, boolean newBorder)
    Helper function for landscape generation
    protected static void
    placeFoliage(Board board, int terrainType, int probMore, int minHexes, int maxHexes, Map<Hex,Point> reverseHex, boolean exclusive)
    Places randomly some connected foliage.
    protected static void
    placeSomeTerrain(Board board, int terrainType, int probMore, int probUltra, int minHexes, int maxHexes, Map<Hex,Point> reverseHex, boolean exclusive)
    Places randomly some connected terrain.
    protected static void
    placeSomeTerrain(Board board, int terrainType, int probMore, int minHexes, int maxHexes, Map<Hex,Point> reverseHex, boolean exclusive)
    Overload that places some connected terrain with no chance of "ultra" version
    protected static void
    postProcessDeepFreeze(Hex[] hexSet, int modifier)
    Converts water hexes to ice hexes.
    protected static void
    postProcessDrought(Hex[] hexSet, int modifier)
    Dries up all bodies of water by 1-3 levels.
    protected static void
    postProcessFlood(Hex[] hexSet, int modifier)
    Flood negative hex levels Shoreline / salt marshes effect Works best with more elevation
    protected static void
    postProcessForestFire(Hex[] hexSet, int modifier)
    Burning woods, with chance to be burnt down already

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BoardUtilities

      public BoardUtilities()
  • Method Details

    • getAmountElevationGenerators

      public static int getAmountElevationGenerators()
      Returns:
      how many elevation generator algorithms there are; three built-in
    • combine

      @Deprecated(since="0.50.06", forRemoval=true) public static Board combine(int width, int height, int sheetWidth, int sheetHeight, List<Board> boards, List<Boolean> isRotated, int medium)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Combines one or more boards into one huge mega board!
      Parameters:
      width - the width of each individual board, before the combine
      height - the height of each individual board, before the combine
      sheetWidth - how many sheets wide the combined map is
      sheetHeight - how many sheets tall the combined map is
      boards - a list of the boards to be combined
      isRotated - Flag that determines if any of the maps are rotated
      medium - Sets the medium the map is in (i.e., ground, atmosphere, space)
    • combine

      public static Board combine(int width, int height, int sheetWidth, int sheetHeight, Board[] boards, int medium)
      Combines one or more boards into one huge mega board!
      Parameters:
      width - the width of each individual board, before the combine
      height - the height of each individual board, before the combine
      sheetWidth - how many sheets wide the combined map is
      sheetHeight - how many sheets tall the combined map is
      boards - an array of the boards to be combined
      medium - Sets the medium the map is in (i.e., ground, atmosphere, space)
    • combine

      @Deprecated(since="0.50.06", forRemoval=true) public static Board combine(int width, int height, int sheetWidth, int sheetHeight, Board[] boards, List<Boolean> isRotated, int medium)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Combines one or more boards into one huge mega board!
      Parameters:
      width - the width of each individual board, before the combine
      height - the height of each individual board, before the combine
      sheetWidth - how many sheets wide the combined map is
      sheetHeight - how many sheets tall the combined map is
      boards - an array of the boards to be combined
      isRotated - Flag that determines if any of the maps are rotated
      medium - Sets the medium the map is in (i.e., ground, atmosphere, space)
    • combine

      public static Board combine(int width, int height, int sheetWidth, int sheetHeight, Board[] boards, int medium, int columnPaddingWidth)
      Combines one or more boards into one huge mega board!
      Parameters:
      width - the width of each individual board, before the combine
      height - the height of each individual board, before the combine
      sheetWidth - how many sheets wide the combined map is
      sheetHeight - how many sheets tall the combined map is
      boards - an array of the boards to be combined
      medium - Sets the medium the map is in (i.e., ground, atmosphere, space)
      columnPaddingWidth - Sets the padding width for the combined map
    • copyBoardInto

      protected static void copyBoardInto(Hex[] dest, int destWidth, int x, int y, Board copied)
      Copies the data of another board into given array of Hexes, offset by the specified x and y.
    • generateRandom

      public static Board generateRandom(MapSettings mapSettings)
      Generates a Random Board
      Parameters:
      mapSettings - The parameters for random board creation.
    • placeSomeTerrain

      protected static void placeSomeTerrain(Board board, int terrainType, int probMore, int minHexes, int maxHexes, Map<Hex,Point> reverseHex, boolean exclusive)
      Overload that places some connected terrain with no chance of "ultra" version
    • placeSomeTerrain

      protected static void placeSomeTerrain(Board board, int terrainType, int probMore, int probUltra, int minHexes, int maxHexes, Map<Hex,Point> reverseHex, boolean exclusive)
      Places randomly some connected terrain.
      Parameters:
      board - The board the terrain goes on.
      terrainType - The type of terrain to place Terrains.
      maxHexes - Maximum number of hexes this terrain can cover.
      exclusive - Set TRUE if this terrain cannot be combined with any other terrain types.
    • placeFoliage

      protected static void placeFoliage(Board board, int terrainType, int probMore, int minHexes, int maxHexes, Map<Hex,Point> reverseHex, boolean exclusive)
      Places randomly some connected foliage.
      Parameters:
      board - The board the terrain goes on.
      terrainType - The type of terrain to place Terrains.
      maxHexes - Maximum number of hexes this terrain can cover.
      exclusive - Set TRUE if this terrain cannot be combined with any other terrain types.
    • addCraters

      public static void addCraters(Board board, int minRadius, int maxRadius, int minCraters, int maxCraters)
      add a crater to the board
    • craterProfile

      public static int craterProfile(int distanceFromCenter, int fullRadius, int maxDepth)
    • addRiver

      public static void addRiver(Board board, Map<Hex,Point> reverseHex)
      Adds a River to the map (if the map is at least 5x5 hexes big). The river has a width of 1-3 hexes (everything else is no more a river). The river goes from one border to another. Nor Params, no results.
    • postProcessFlood

      protected static void postProcessFlood(Hex[] hexSet, int modifier)
      Flood negative hex levels Shoreline / salt marshes effect Works best with more elevation
    • postProcessDeepFreeze

      protected static void postProcessDeepFreeze(Hex[] hexSet, int modifier)
      Converts water hexes to ice hexes. Works best with snow and ice themes.
    • postProcessForestFire

      protected static void postProcessForestFire(Hex[] hexSet, int modifier)
      Burning woods, with chance to be burnt down already
    • postProcessDrought

      protected static void postProcessDrought(Hex[] hexSet, int modifier)
      Dries up all bodies of water by 1-3 levels. dried up water becomes swamp then rough
    • addCliffs

      protected static void addCliffs(Board board, int modifier)
    • addWeatherConditions

      public static void addWeatherConditions(Board board, Weather weatherCond, Wind windCond)
    • generateElevation

      public static void generateElevation(int hilliness, int width, int height, int range, int invertProb, int invertNegative, int[][] elevationMap, int algorithm)
      Generates the elevations
      Parameters:
      hilliness - The Hilliness
      width - The Width of the map.
      height - The Height of the map.
      range - Max difference between highest and lowest level.
      invertProb - Probability for the inversion of the map (0..100)
      invertNegative - If 1, invert negative hexes, else do nothing
      elevationMap - here is the result stored
    • generateMountain

      public static void generateMountain(Board board, int width, Coords centre, int height, int capStyle)
    • flip

      public static void flip(Board board, boolean horiz, boolean vert)
      Flips the board around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West). The dimensions of the board will remain the same, but the terrain of the hexes will be switched.
      Parameters:
      horiz - - a boolean value that, if true, indicates that the board is being flipped North-for-South.
      vert - - a boolean value that, if true, indicates that the board is being flipped East-for-West.
    • cutSteps

      protected static void cutSteps(int hilliness, int width, int height, int[][] elevationMap)
      one of the landscape generation algorithms
    • markRect

      protected static void markRect(int x1, int x2, int inc, int[][] elevationMap, int height)
      Helper function for the map generator increased a heightmap by a given value
    • markSides

      protected static void markSides(Point p1, Point p2, int upperInc, int lowerInc, int[][] elevationMap, int height)
      Helper function for map generator increases all of one side and decreased on other side
    • midPoint

      protected static void midPoint(int hilliness, int width, int height, int[][] elevationMap)
      midpoint algorithm for landscape generation
    • midPointStep

      protected static void midPointStep(double fractionalDim, int size, int delta, int[][] elevationMap, int step, boolean newBorder)
      Helper function for landscape generation
    • diagMid

      protected static void diagMid(Point p, int d1, int d2, int delta, int size, int[][] elevationMap)
      calculates the diagonal middle points with new values
      Parameters:
      p - Starting point.
    • middleValue

      protected static int middleValue(int a, int b, int c, int delta)
      calculates the arithmetic medium of 3 values and add random value in range of delta.
    • middleValue

      protected static int middleValue(int a, int b, int c, int d, int delta)
      calculates the arithmetic medium of 4 values and add random value in range of delta.
    • getClosestEdge

      public static CardinalEdge getClosestEdge(Entity entity)
      Figures out the "closest" edge for the given entity on the entity's game board
      Parameters:
      entity - Entity to evaluate
      Returns:
      the Board.START_ constant representing the "closest" edge
    • determineOppositeEdge

      public static CardinalEdge determineOppositeEdge(Entity entity)
      Figures out the "opposite" edge for the given entity.
      Parameters:
      entity - Entity to evaluate
      Returns:
      the Board.START_ constant representing the "opposite" edge