Class HexEditHandler
The change is tried on a copy of the hex first and only kept if the result is a hex the game considers valid, so an edit can never leave the board in a state the rest of the engine does not expect - rapids outside water, for instance, or a woods level that does not exist.
Changing the depth of water in a hex that units are standing in is refused. There is no rule for what happens to a unit when the ground beneath it floods, and inventing one here would be a house rule; that is being decided separately.
Status and known limits
Note for anyone picking this up: the gamemaster terrain tools are a first, deliberately simple pass. They work,
but they have had little testing and the validation is thin - see HexEditValidator for
what is and is not checked, and for the TODO that goes with it. Both modifying terrain and changing it want more
testing than they have had.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPassed as the terrain level to remove a terrain rather than add it. -
Method Summary
Modifier and TypeMethodDescriptionapplyHexEdit(HexEditSpec spec, String gamemasterName) Applies a gamemaster's edit to every hex it names, or to none of them.Clears every terrain from one hex, leaving bare ground at the hex's own level.setTerrain(Coords coords, int boardId, int terrainType, int terrainLevel, String gamemasterName) Sets one terrain in one hex to the given level, removing that terrain when the level isREMOVE_TERRAIN_LEVEL.setTerrainFactor(Coords coords, int boardId, int terrainType, int terrainFactor, String gamemasterName) Sets how much punishment a terrain in one hex can still take, leaving what the terrain is alone.
-
Field Details
-
REMOVE_TERRAIN_LEVEL
public static final int REMOVE_TERRAIN_LEVELPassed as the terrain level to remove a terrain rather than add it.- See Also:
-
-
Method Details
-
setTerrain
public String setTerrain(Coords coords, int boardId, int terrainType, int terrainLevel, String gamemasterName) Sets one terrain in one hex to the given level, removing that terrain when the level isREMOVE_TERRAIN_LEVEL.- Parameters:
coords- The hex to changeboardId- The board the hex is onterrainType- The terrain to set, fromTerrainsterrainLevel- The level to set it to, orREMOVE_TERRAIN_LEVELto remove itgamemasterName- The name of the gamemaster making the change, for the report- Returns:
- A description of why the edit was refused, or
nullwhen it was applied
-
applyHexEdit
Applies a gamemaster's edit to every hex it names, or to none of them.Each hex is checked first and the whole edit is refused if any one of them would end up invalid. A gamemaster flooding a valley wants the valley flooded or a reason why not; half a valley flooded, with the hexes that failed left dry among the ones that worked, is the worst of both.
- Parameters:
spec- The hexes to change and the terrain they should end up holdinggamemasterName- The name of the gamemaster making the change, for the report- Returns:
- A description of why the edit was refused, or
nullwhen it was applied
-
setTerrainFactor
public String setTerrainFactor(Coords coords, int boardId, int terrainType, int terrainFactor, String gamemasterName) Sets how much punishment a terrain in one hex can still take, leaving what the terrain is alone. Woods that have been shelled but not yet flattened are the usual case: the hex is still light woods, but there is less of it left to burn or blast away.- Parameters:
coords- The hex holding the terrainboardId- The board the hex is onterrainType- The terrain to weaken or restore, fromTerrainsterrainFactor- The terrain factor to leave it atgamemasterName- The name of the gamemaster making the change, for the report- Returns:
- A description of why the edit was refused, or
nullwhen it was applied
-
clearHex
Clears every terrain from one hex, leaving bare ground at the hex's own level.- Parameters:
coords- The hex to clearboardId- The board the hex is ongamemasterName- The name of the gamemaster making the change, for the report- Returns:
- A description of why the edit was refused, or
nullwhen it was applied
-