Package megamek.common.board
Class Board
java.lang.Object
megamek.common.board.Board
- All Implemented Interfaces:
- Serializable
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final Stringprotected Vector<BoardListener>static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddBoardListener(BoardListener listener) Adds the specified board listener to receive board events from this board.voidaddDeploymentZone(int zoneId, HexArea hexArea) Adds a deployment zone with the given ID and the hexes described by the given HexArea to this board, replacing the previously present zone of that ID, if there had been one.voidaddInfernoTo(Coords coords, Inferno round, int hits) Record that the given coordinates have received a hit from an inferno.voidaddSpecialHexDisplay(Coords coords, SpecialHexDisplay shd) Adds the given SHD at the given coords to this board.voidaddSpecialHexDisplay(Coords coords, SpecialHexDisplay shd, boolean fireEvent) Adds the given SHD at the given coords to this board.voidAdd the given tag string to the board's tags list.static booleanboardIsSize(File filepath, BoardDimensions size) Checks if a board file is the specified size.voidvoidcollapseBuilding(Vector<Coords> coords) Collapse a vector of building hexes.voidcollapseBuilding(Coords coords) The given building hex has collapsed.voidcollapseBuilding(Building bldg) The given building has collapsed.booleancontains(int x, int y) Determines whether this Board "contains" the specified Coords.booleancontains(BoardLocation location) Determines whether this Board "contains" the specified location.booleanDetermines whether this Board "contains" the specified Coords.booleanstatic BoardcreateEmptyBoard(int width, int height) static intdecodeCustomDeploymentZoneID(int zoneID) Use this method to convert a deployment zone ID as represented in the UI zone selectors (e.g.embeddedBoardPosition(int boardId) static intencodeCustomDeploymentZoneID(int zoneID) Use this method to convert a deployment zone ID as stored in the board to a number suitable for representation in the UI zone selectors (e.g.exitsAsIntList(int exits) Gets every annotation on the map.Gets the annotations associated with a hex.intgetBuildingAt(Coords coords) Get the building at the given coordinates.getCustomDeploymentZone(int zoneID) Gets all the coordinates in the given custom deployment zoneGets the IDs of all custom deployment zones defined for this board.Gets the description of the map.intgetEmbeddedBoardAt(Coords coords) intintgetHex(int x, int y) Determines if this Board contains the (x, y) Coords, and if so, returns the Hex at that position.Returns the Hex at the given Coords, both of which may be null.getHexes(Collection<Coords> coords) Returns a list of Hexes at the given coords.getHexInDir(int x, int y, int dir) Gets the hex in the specified direction from the specified starting coordinates.getHexInDir(Coords c, int dir) Get an enumeration of all coordinates with infernos still burning.intintintgetOppositeEdge(int cardinalEdge) Determine the opposite edge from the given edge Returns START_NONE for non-cardinal edges (North, South, West, East)booleanGet the current value of the "road auto-exit" option.static BoardDimensionsInspect specified board file and return its dimensions.static BoardgetSkyBoard(int width, int height) Returns a new atmospheric (low altitude) board with no terrain (sky map) of the given size.static BoardgetSpaceBoard(int width, int height) Returns a new space board of the given size.getSpecialHexDisplay(Coords coords) getTags()Inspects the given board file and returns a set of its tags.intgetWidth()protected voidinitializeAll(List<String> errors) Initialize all hexesvoidRebuilds automatic terrains for the whole board, such as incline highlighting.voidinitializeAround(int x, int y) Initialize a hex and the hexes around itvoidinitializeHex(int x, int y) Initializes a hex in its surroundings.static intIntListAsExits(List<Integer> list) Given a list of integers, returns them in a bit-packed form.booleanisGround()booleanbooleanisInfernoBurning(Coords coords) Determine if the given coordinates has a burning inferno.booleanisLegalDeployment(Coords c, int zoneType, int startingWidth, int startingOffset, int startingAnyNWx, int startingAnyNWy, int startingAnySEx, int startingAnySEy) Can an object be deployed at these coordinates, given a starting zone, width of starting zone and offset from edge of board?booleanisLegalDeployment(Coords c, Player p) Can the given player deploy at these coordinates?booleanisLegalDeployment(Coords c, Entity e) Can the given entity be deployed at these coordinatesbooleanbooleanisOnBoardEdge(Coords coords) booleanisSky()booleanisSpace()booleanisValid()static booleanbooleanvoidLoad board data from a file.voidload(InputStream is) Loads this board from an InputStreamvoidload(InputStream is, List<String> errors, boolean continueLoadOnError) voidvoidCreates a new data set for the board, with the specified dimensions and data; notifies listeners that a new data set has been created.voidprocessBoardEvent(BoardEvent event) Fires a board event which typically leads to theBoardViewand minimap being redrawn.voidremoveBoardListener(BoardListener listener) Removes the specified board listener.voidremoveBombIconsFrom(Coords coords) voidremoveInfernoFrom(Coords coords) Extinguish inferno at the target hex.voidremoveSpecialHexDisplay(Coords coords, SpecialHexDisplay shd) Removes the given SHD from the given coords.voidremoveSpecialHexDisplay(Coords coords, SpecialHexDisplay shd, boolean fireEvent) Removes the given SHD from the given coords.voidRemoves the given tag string from the board's tags list.voidResets the "intermediate" deployment zones associated with this board, in case the deployment zones changevoidResets the Min and Max elevations to their default values.voidsave(OutputStream os) Writes data for the board, as text to the OutputStreamvoidsetAnnotations(Coords c, Collection<String> a) Sets annotations on a given hex.voidsetBoardId(int boardId) Sets the board's ID.voidsetBoardType(BoardType boardType) voidsetBridgeCF(int value) Set the CF of bridgesvoidSets the description of the map.voidsetEmbeddedBoard(int boardId, Coords coords) Sets the given board ID as an embedded board at the given coords of this board.voidsetEnclosingBoard(int enclosingBoardId) voidDetermines if this Board contains the (x, y) Coords, and if so, sets the specified Hex into that position and initializes it.voidSets the hex into the location specified by the Coords.voidsetHexes(Map<BoardLocation, Hex> changedHexes) Copies in the given hexes, overwriting any affected hexes that are on this board.voidsetMapName(String mapName) voidvoidsetRoadsAutoExit(boolean value) Set the value of the "road auto-exit" option.voidSets this board's specialHexes to a new set.voidSets a tileset theme for all hexes of the board.voidsetType(int t) toString()voidupdateBuilding(Building receivedBuilding) Update a locally stored building with CF and other values from a building received from the server.
- 
Field Details- 
BOARD_REQUEST_ROTATION- See Also:
 
- 
BOARD_NONEpublic static final int BOARD_NONE- See Also:
 
- 
BOARD_NAME_UNNAMED- See Also:
 
- 
START_NONEpublic static final int START_NONE- See Also:
 
- 
START_ANYpublic static final int START_ANY- See Also:
 
- 
START_NWpublic static final int START_NW- See Also:
 
- 
START_Npublic static final int START_N- See Also:
 
- 
START_NEpublic static final int START_NE- See Also:
 
- 
START_Epublic static final int START_E- See Also:
 
- 
START_SEpublic static final int START_SE- See Also:
 
- 
START_Spublic static final int START_S- See Also:
 
- 
START_SWpublic static final int START_SW- See Also:
 
- 
START_Wpublic static final int START_W- See Also:
 
- 
START_EDGEpublic static final int START_EDGE- See Also:
 
- 
START_CENTERpublic static final int START_CENTER- See Also:
 
- 
NUM_ZONESpublic static final int NUM_ZONES- See Also:
 
- 
NUM_ZONES_X2public static final int NUM_ZONES_X2- See Also:
 
- 
DEFAULT_BOARD_HEIGHTpublic static final int DEFAULT_BOARD_HEIGHT- See Also:
 
- 
DEFAULT_BOARD_WIDTHpublic static final int DEFAULT_BOARD_WIDTH- See Also:
 
- 
boardListeners
- 
MAX_DEPLOYMENT_ZONE_NUMBERpublic static final int MAX_DEPLOYMENT_ZONE_NUMBER- See Also:
 
 
- 
- 
Constructor Details- 
Boardpublic Board()Creates a new board with zero as its width and height parameters.
- 
Boardpublic Board(int width, int height) Creates a new board of the specified dimensions. All hexes in the board will be null until otherwise set.- Parameters:
- width- the width dimension.
- height- the height dimension.
 
- 
BoardCreates a new board of the specified dimensions and specified hex data. Note that the number of Hexes given should be equal to width * height to avoid null Hexes in the board.- Parameters:
- width- the width dimension
- height- the height dimension
- data- the Hexes of the new board
 
 
- 
- 
Method Details- 
getSkyBoardReturns a new atmospheric (low altitude) board with no terrain (sky map) of the given size.- Parameters:
- width- the width of the board
- height- the height of the board
- Returns:
- the new board, ready to be used
 
- 
getSpaceBoardReturns a new space board of the given size.- Parameters:
- width- the width of the board
- height- the height of the board
- Returns:
- the new board, ready to be used
 
- 
getHeightpublic int getHeight()- Returns:
- Map height in hexes
 
- 
getWidthpublic int getWidth()- Returns:
- Map width in hexes
 
- 
getCenter
- 
newDataCreates a new data set for the board, with the specified dimensions and data; notifies listeners that a new data set has been created.- Parameters:
- width- the width dimension.
- height- the height dimension.
- data- new hex data appropriate for the board.
- errors- A buffer for storing error messages, if any. This is allowed to be null.
 
- 
getHexDetermines if this Board contains the (x, y) Coords, and if so, returns the Hex at that position.- Parameters:
- x- the x Coords.
- y- the y Coords.
- Returns:
- the Hex, if this Board contains the (x, y) location; null otherwise.
 
- 
getHexInDir- Parameters:
- c- starting coordinates
- dir- direction
- Returns:
- the hex in the specified direction from the specified starting coordinates.
 
- 
getHexInDirGets the hex in the specified direction from the specified starting coordinates. This avoids calls to Coords.translated, and thus, object construction.- Parameters:
- x- starting x coordinate
- y- starting y coordinate
- dir- direction
- Returns:
- the hex in the specified direction from the specified starting coordinates.
 
- 
initializeAllInitialize all hexes
- 
initializeAroundpublic void initializeAround(int x, int y) Initialize a hex and the hexes around it
- 
initializeHexpublic void initializeHex(int x, int y) Initializes a hex in its surroundings. Currently, sets the connects parameter appropriately to the surrounding hexes. If a surrounding hex is off the board, it checks the hex opposite the missing hex.
- 
initializeAllAutomaticTerrainpublic void initializeAllAutomaticTerrain()Rebuilds automatic terrains for the whole board, such as incline highlighting. Also fires a BOARD_CHANGED_ALL_HEXES event.
- 
containspublic boolean contains(int x, int y) Determines whether this Board "contains" the specified Coords.- Parameters:
- x- the x Coords.
- y- the y Coords.
- Returns:
- trueif the board contains the specified coords
 
- 
containsDetermines whether this Board "contains" the specified Coords.- Parameters:
- coords- the Coords.
- Returns:
- trueif the board contains the specified coords
 
- 
containsDetermines whether this Board "contains" the specified location. True only when the board IDs match and the coords of the location are within the borders of the board.- Parameters:
- location- the location to test
- Returns:
- true if the board contains the specified location
 
- 
getHexReturns the Hex at the given Coords, both of which may be null.- Parameters:
- coords- the Coords to look for the Hex
- Returns:
- the Hex at the specified Coords, or null if there is not a hex there
 
- 
getHexesReturns a list of Hexes at the given coords. The list will never be null but may be empty depending on the given Coords collection. If the given Coords collection is null, the returned list will be empty.- Parameters:
- coords- the Coords to query
- Returns:
- the Hexes at the specified Coords
 
- 
setHexDetermines if this Board contains the (x, y) Coords, and if so, sets the specified Hex into that position and initializes it.- Parameters:
- x- the x Coords.
- y- the y Coords.
- hex- the hex to be set into position.
 
- 
setHexesCopies in the given hexes, overwriting any affected hexes that are on this board. For simplicity, this method ignoresBoardLocation's that are not on this board, i.e., it can be called without first filtering the locations for board ID.- Parameters:
- changedHexes- A map of locations and hexes; the locations need not all (or any) match this board
 
- 
setHexSets the hex into the location specified by the Coords.- Parameters:
- c- the Coords.
- hex- the hex to be set into position.
 
- 
boardIsSizeChecks if a board file is the specified size.- Parameters:
- filepath- The path to the board file.
- size- The dimensions of the board to test.
- Returns:
- trueif the dimensions match.
 
- 
getSizeInspect specified board file and return its dimensions.- Parameters:
- filepath- The path to the board file.
- Returns:
- A BoardDimensionsobject containing the dimension.
 
- 
getTagsInspects the given board file and returns a set of its tags.
- 
isValid
- 
isLegalDeploymentCan the given player deploy at these coordinates?
- 
isLegalDeploymentCan the given entity be deployed at these coordinates
- 
isLegalDeploymentpublic boolean isLegalDeployment(Coords c, int zoneType, int startingWidth, int startingOffset, int startingAnyNWx, int startingAnyNWy, int startingAnySEx, int startingAnySEy) Can an object be deployed at these coordinates, given a starting zone, width of starting zone and offset from edge of board?
- 
getOppositeEdgepublic int getOppositeEdge(int cardinalEdge) Determine the opposite edge from the given edge Returns START_NONE for non-cardinal edges (North, South, West, East)- Parameters:
- cardinalEdge- The edge to return the opposite of
- Returns:
- Constant representing the opposite edge
 
- 
loadLoad board data from a file.- Parameters:
- filepath- The path to the file.
 
- 
loadLoads this board from an InputStream
- 
load
- 
load
- 
isValidpublic boolean isValid()
- 
isValid
- 
saveWrites data for the board, as text to the OutputStream
- 
addInfernoToRecord that the given coordinates have received a hit from an inferno.- Parameters:
- coords- the- Coordsof the hit.
- round- the kind of round that hit the hex.
- hits- the- intnumber of rounds that hit
- Throws:
- IllegalArgumentException- if the hits number is negative
 
- 
removeInfernoFromExtinguish inferno at the target hex.- Parameters:
- coords- the- Coordsof the hit.
 
- 
removeBombIconsFrom
- 
clearBombIconspublic void clearBombIcons()
- 
isInfernoBurningDetermine if the given coordinates has a burning inferno.- Parameters:
- coords- - the- Coordsbeing checked.
- Returns:
- trueif those coordinates have a burning inferno round.- falseif no inferno has hit those coordinates or if it has burned out.
 
- 
getInfernoBurningCoordsGet an enumeration of all coordinates with infernos still burning.- Returns:
- an EnumerationofCoordsthat have infernos still burning.
 
- 
getBuildings- Returns:
- an EnumerationofBuildings on the Board
 
- 
getBuildingsVector- Returns:
- the Vector of all the board's buildings
 
- 
getBuildingAtGet the building at the given coordinates.- Parameters:
- coords- the- Coordsbeing examined.
- Returns:
- a Buildingobject, if there is one at the given coordinates, otherwise anullwill be returned.
 
- 
collapseBuildingCollapse a vector of building hexes.- Parameters:
- coords- the- Vectorof- Coordsobjects to be collapsed.
 
- 
collapseBuildingThe given building hex has collapsed. Remove it from the board and replace it with rubble.- Parameters:
- coords- the- Buildingthat has collapsed.
 
- 
collapseBuildingThe given building has collapsed. Remove it from the board and replace it with rubble.- Parameters:
- bldg- the- Buildingthat has collapsed.
 
- 
updateBuildingUpdate a locally stored building with CF and other values from a building received from the server.- Parameters:
- receivedBuilding- The Building received from the server
 
- 
getRoadsAutoExitpublic boolean getRoadsAutoExit()Get the current value of the "road auto-exit" option.- Returns:
- trueif roads should automatically exit onto all adjacent pavement hexes.- falseotherwise.
 
- 
setRoadsAutoExitpublic void setRoadsAutoExit(boolean value) Set the value of the "road auto-exit" option.- Parameters:
- value- The value to set for the option;- trueif roads should automatically exit onto all adjacent pavement hexes.- falseotherwise.
 
- 
addBoardListenerAdds the specified board listener to receive board events from this board.- Parameters:
- listener- the board listener.
 
- 
removeBoardListenerRemoves the specified board listener.- Parameters:
- listener- the board listener.
 
- 
processBoardEventFires a board event which typically leads to theBoardViewand minimap being redrawn. This is public as the boards and minimaps show some data that is not part of the Board class and Board has no way of knowing when a change happens. An example of this is arty auto hexes which are stored in the player class
- 
getInfernos- Returns:
- an HashtableofInfernoTrackerson the board.
 
- 
setBridgeCFpublic void setBridgeCF(int value) Set the CF of bridges- Parameters:
- value- The value to set the bridge CF to.
 
- 
setRandomBasementsOffpublic void setRandomBasementsOff()
- 
getSpecialHexDisplay- Returns:
- Special events that should be marked on hexes, such as artillery fire as well as notes players can leave manually on hexes. Always returns at least an empty list, never null.
 
- 
addSpecialHexDisplayAdds the given SHD at the given coords to this board. An event can be fired for this board change (this should not be done on the Server).- Parameters:
- coords- The position of the SHD on this board
- shd- The SpecialHexDisplay to add
- fireEvent- When true, a BoardEvent is fired for the affected coords
 
- 
addSpecialHexDisplayAdds the given SHD at the given coords to this board. This method does not fire an event for the change.- Parameters:
- coords- The position of the SHD on this board
- shd- The SpecialHexDisplay to add
 
- 
removeSpecialHexDisplayRemoves the given SHD from the given coords.- Parameters:
- coords- The position of the SHD on this board
- shd- The SpecialHexDisplay to remove
 
- 
removeSpecialHexDisplayRemoves the given SHD from the given coords.- Parameters:
- coords- The position of the SHD on this board
- shd- The SpecialHexDisplay to remove
 
- 
getSpecialHexDisplayTable
- 
setSpecialHexDisplayTableSets this board's specialHexes to a new set. This method should be used by the client when receiving an update from the server.- Parameters:
- shd- The new map of SpecialHexDisplays
 
- 
setTypepublic void setType(int t) 
- 
getMaxElevationpublic int getMaxElevation()- Returns:
- the highest elevation hex on the board.
 
- 
getMinElevationpublic int getMinElevation()- Returns:
- the lowest elevation hex on the board.
 
- 
resetStoredElevationpublic void resetStoredElevation()Resets the Min and Max elevations to their default values.
- 
containsBridgespublic boolean containsBridges()
- 
getDescriptionGets the description of the map.- Returns:
- The description of the map, if one exists, otherwise null.
 
- 
setDescriptionSets the description of the map.- Parameters:
- s- The description of the map; may be null.
 
- 
getAnnotationsGets every annotation on the map.- Returns:
- A read-only map of per-hex annotations.
 
- 
getAnnotationsGets the annotations associated with a hex.- Parameters:
- c- Coordinates of the hex.
- Returns:
- A collection of annotations for the hex.
 
- 
setAnnotationsSets annotations on a given hex.- Parameters:
- c- Coordinates of the hex to apply the annotations to.
- a- A collection of annotations to assign to the hex. This may be null.
 
- 
setThemeSets a tileset theme for all hexes of the board. Passing null as newTheme resets the theme to the theme specified in the board file.
- 
isOnBoardEdge- Returns:
- true when the given Coordscoords is on the edge of the board.
 
- 
createEmptyBoard
- 
addTagAdd the given tag string to the board's tags list.
- 
removeTagRemoves the given tag string from the board's tags list.
- 
getTags- Returns:
- the board's tags list. The list is unmodifiable. Use addTag and removeTag to change it.
 
- 
getBoardName- Returns:
- The name of this map; this is meant to be displayed in the GUI.
 
- 
setMapName
- 
exitsAsIntList- Returns:
- Given an "exits" value, returns it in a list form. (i.e. exits value of 4 returns {3}, exit value of 5 returns {1, 3}
 
- 
IntListAsExitsGiven a list of integers, returns them in a bit-packed form.
- 
addDeploymentZoneAdds a deployment zone with the given ID and the hexes described by the given HexArea to this board, replacing the previously present zone of that ID, if there had been one. Note that the zone ID can be outside those reachable by board files; e.g. the zone ID can be 1000. Note however that zone IDs in the range of 0 to 50 should be avoided as they'll overwrite terrain deployment zones.- Parameters:
- zoneId- The zone Id
- hexArea- The hexes comprising this deployment zone
 
- 
resetDeploymentZonespublic void resetDeploymentZones()Resets the "intermediate" deployment zones associated with this board, in case the deployment zones change
- 
getCustomDeploymentZonesGets the IDs of all custom deployment zones defined for this board.
- 
getCustomDeploymentZoneGets all the coordinates in the given custom deployment zone
- 
decodeCustomDeploymentZoneIDpublic static int decodeCustomDeploymentZoneID(int zoneID) Use this method to convert a deployment zone ID as represented in the UI zone selectors (e.g. in the PlayerSettingsDialog) to a deployment zone ID as stored in the board.
- 
encodeCustomDeploymentZoneIDpublic static int encodeCustomDeploymentZoneID(int zoneID) Use this method to convert a deployment zone ID as stored in the board to a number suitable for representation in the UI zone selectors (e.g. PlayerSettingsDialog)
- 
setBoardIdpublic void setBoardId(int boardId) Sets the board's ID. Within an MM game, the ID must be unique. To preserve "normal" games, 0 is the default.
- 
getBoardIdpublic int getBoardId()
- 
setEnclosingBoardpublic void setEnclosingBoard(int enclosingBoardId) 
- 
getEnclosingBoardIdpublic int getEnclosingBoardId()- Returns:
- The ID of the enclosing board of this board, or -1 if it has no enclosing board.
 
- 
setEmbeddedBoardSets the given board ID as an embedded board at the given coords of this board. The board ID is not checked nor the board type. The coords are checked against the size of this board.- Parameters:
- boardId- The board ID to embed
- coords- The location to place the given board
- Throws:
- IllegalArgumentException- When this board does not contain the given coords
 
- 
embeddedBoardCoords
- 
embeddedBoardPosition
- 
getEmbeddedBoardAt
- 
getEmbeddedBoardHexes
- 
isGroundpublic boolean isGround()
- 
isLowAltitudepublic boolean isLowAltitude()- Returns:
- True if this board is a low altitude (a.k.a. atmospheric) board, either with terrain or without terrain ("sky").
 
- 
isSkypublic boolean isSky()- Returns:
- True if this board is a low altitude (a.k.a. atmospheric) board without terrain ("sky").
 
- 
isSpacepublic boolean isSpace()- Returns:
- True if this board is a space board, either close to a planet with some atmospheric hexes ("high altitude") or in deeper space.
 
- 
isHighAltitudepublic boolean isHighAltitude()- Returns:
- True if this board is a high altitude board, i.e. a space board close to a planet with some atmospheric hexes.
 
- 
setBoardType
- 
getBoardType
- 
toString
 
-