Class WoodsClearingTracker
- All Implemented Interfaces:
Serializable
Per TM pp.241-243, a chainsaw or dual saw can clear a path through wooded hexes. Instead of using the Terrain Factor damage system, a saw takes 2 turns to reduce a wooded hex one level (heavy to light, light to rough). Two units clearing the same hex can reduce this to 1 turn.
Work accumulates per-hex and persists even if no entity works the hex for a round (a partially cut tree stays partially cut). Work only progresses when at least one entity actively declares clearing in a given round.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of work turns needed when 2+ saws are working the same hex.static final intNumber of work turns needed to clear a hex with a single saw. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all clearing operations.voiddeclareClearing(int entityId, BoardLocation targetHex) Registers an entity as clearing a specific hex this round.Returns all entity IDs currently involved in clearing operations (this round or last round).getClearingTarget(int entityId) Returns the hex that a given entity is clearing this round, or null if not clearing.Returns a map of hex locations to the number of turns remaining to complete clearing.booleanChecks if a hex already has accumulated clearing work (partially cut).booleanisClearingThisRound(int entityId) Checks if an entity is currently declared as clearing this round.Processes the round transition for all clearing operations.voidremoveStaleEntries(Function<BoardLocation, Hex> hexLookup) Removes tracker entries for hexes that no longer contain woods or jungle.booleanwasClearingLastRound(int entityId) Checks if an entity declared clearing in the previous round (used for firing penalty).
-
Field Details
-
TURNS_REQUIRED_SINGLE
public static final int TURNS_REQUIRED_SINGLENumber of work turns needed to clear a hex with a single saw.- See Also:
-
TURNS_REQUIRED_MULTI
public static final int TURNS_REQUIRED_MULTINumber of work turns needed when 2+ saws are working the same hex.- See Also:
-
-
Constructor Details
-
WoodsClearingTracker
public WoodsClearingTracker()
-
-
Method Details
-
declareClearing
Registers an entity as clearing a specific hex this round.- Parameters:
entityId- the ID of the entity performing clearingtargetHex- the hex being cleared
-
processNewRound
Processes the round transition for all clearing operations.For each hex that had contributors this round, increments accumulated work. A hex completes when accumulated work reaches the required threshold (2 turns for single unit, 1 turn for 2+ units). Hexes with no contributors this round retain their accumulated work (a partially cut tree stays partially cut) but do not progress.
- Returns:
- list of hex locations that have completed clearing (ready for terrain reduction)
-
wasClearingLastRound
public boolean wasClearingLastRound(int entityId) Checks if an entity declared clearing in the previous round (used for firing penalty).- Parameters:
entityId- the entity ID to check- Returns:
- true if the entity was clearing last round and should have the running/flank penalty
-
hasAccumulatedWork
Checks if a hex already has accumulated clearing work (partially cut).- Parameters:
hex- the hex to check- Returns:
- true if the hex has any accumulated work from prior turns
-
isClearingThisRound
public boolean isClearingThisRound(int entityId) Checks if an entity is currently declared as clearing this round.- Parameters:
entityId- the entity ID to check- Returns:
- true if the entity declared clearing this round
-
getClearingTarget
Returns the hex that a given entity is clearing this round, or null if not clearing.- Parameters:
entityId- the entity ID to check- Returns:
- the BoardLocation being cleared, or null
-
getAllClearingEntities
Returns all entity IDs currently involved in clearing operations (this round or last round).- Returns:
- set of entity IDs involved in clearing
-
getTurnsRemainingPerHex
Returns a map of hex locations to the number of turns remaining to complete clearing. Accounts for the number of contributors this round when calculating remaining turns.- Returns:
- map of hex locations to turns remaining (1 or 2 typically)
-
removeStaleEntries
Removes tracker entries for hexes that no longer contain woods or jungle. This handles cases where fire or other effects removed the woods before the saw clearing completed.- Parameters:
hexLookup- a function that returns the Hex at a given BoardLocation, or null
-
clear
public void clear()Removes all clearing operations. Used when resetting the game state.
-