Package megamek.common.util
Class BoardUtilities
java.lang.Object
megamek.common.util.BoardUtilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidstatic voidaddCraters(Board board, int minRadius, int maxRadius, int minCraters, int maxCraters) add a crater to the boardstatic voidAdds a River to the map (if the map is at least 5x5 hexes big).static voidaddWeatherConditions(Board board, Weather weatherCond, Wind windCond) static Boardcombine(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 BoardCombines one or more boards into one huge mega board!static Boardcombine(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 Boardcombine(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 voidcopyBoardInto(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 intcraterProfile(int distanceFromCenter, int fullRadius, int maxDepth) protected static voidcutSteps(int hilliness, int width, int height, int[][] elevationMap) one of the landscape generation algorithmsstatic CardinalEdgedetermineOppositeEdge(Entity entity) Figures out the "opposite" edge for the given entity.protected static voidcalculates the diagonal middle points with new valuesstatic voidFlips the board around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West).static voidgenerateElevation(int hilliness, int width, int height, int range, int invertProb, int invertNegative, int[][] elevationMap, int algorithm) Generates the elevationsstatic voidgenerateMountain(Board board, int width, Coords centre, int height, int capStyle) static BoardgenerateRandom(MapSettings mapSettings) Generates a Random Boardstatic intstatic CardinalEdgegetClosestEdge(Entity entity) Figures out the "closest" edge for the given entity on the entity's game boardprotected static voidmarkRect(int x1, int x2, int inc, int[][] elevationMap, int height) Helper function for the map generator increased a heightmap by a given valueprotected static voidHelper function for map generator increases all of one side and decreased on other sideprotected static intmiddleValue(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 intmiddleValue(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 voidmidPoint(int hilliness, int width, int height, int[][] elevationMap) midpoint algorithm for landscape generationprotected static voidmidPointStep(double fractionalDim, int size, int delta, int[][] elevationMap, int step, boolean newBorder) Helper function for landscape generationprotected static voidplaceFoliage(Board board, int terrainType, int probMore, int minHexes, int maxHexes, Map<Hex, Point> reverseHex, boolean exclusive) Places randomly some connected foliage.protected static voidplaceSomeTerrain(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 voidplaceSomeTerrain(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" versionprotected static voidpostProcessDeepFreeze(Hex[] hexSet, int modifier) Converts water hexes to ice hexes.protected static voidpostProcessDrought(Hex[] hexSet, int modifier) Dries up all bodies of water by 1-3 levels.protected static voidpostProcessFlood(Hex[] hexSet, int modifier) Flood negative hex levels Shoreline / salt marshes effect Works best with more elevationprotected static voidpostProcessForestFire(Hex[] hexSet, int modifier) Burning woods, with chance to be burnt down already
-
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 combineheight- the height of each individual board, before the combinesheetWidth- how many sheets wide the combined map issheetHeight- how many sheets tall the combined map isboards- a list of the boards to be combinedisRotated- Flag that determines if any of the maps are rotatedmedium- 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 combineheight- the height of each individual board, before the combinesheetWidth- how many sheets wide the combined map issheetHeight- how many sheets tall the combined map isboards- an array of the boards to be combinedmedium- 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 combineheight- the height of each individual board, before the combinesheetWidth- how many sheets wide the combined map issheetHeight- how many sheets tall the combined map isboards- an array of the boards to be combinedisRotated- Flag that determines if any of the maps are rotatedmedium- 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 combineheight- the height of each individual board, before the combinesheetWidth- how many sheets wide the combined map issheetHeight- how many sheets tall the combined map isboards- an array of the boards to be combinedmedium- Sets the medium the map is in (i.e., ground, atmosphere, space)columnPaddingWidth- Sets the padding width for the combined map
-
copyBoardInto
Copies the data of another board into given array of Hexes, offset by the specified x and y. -
generateRandom
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 placeTerrains.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 placeTerrains.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
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
Flood negative hex levels Shoreline / salt marshes effect Works best with more elevation -
postProcessDeepFreeze
Converts water hexes to ice hexes. Works best with snow and ice themes. -
postProcessForestFire
Burning woods, with chance to be burnt down already -
postProcessDrought
Dries up all bodies of water by 1-3 levels. dried up water becomes swamp then rough -
addCliffs
-
addWeatherConditions
-
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 Hillinesswidth- 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 nothingelevationMap- here is the result stored
-
generateMountain
-
flip
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- - abooleanvalue that, iftrue, indicates that the board is being flipped North-for-South.vert- - abooleanvalue that, iftrue, 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
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
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
Figures out the "opposite" edge for the given entity.- Parameters:
entity- Entity to evaluate- Returns:
- the Board.START_ constant representing the "opposite" edge
-
combine(int, int, int, int, Board[], int)