Package megamek.common.units
Class BulldozerRules
java.lang.Object
megamek.common.units.BulldozerRules
Static helpers for bulldozer (TacOps) rules that would otherwise add logic to large server classes. Keeps the
resolution code in one focused place; callers (e.g. the damage manager) invoke a single method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intExtra turns a backhoe takes vs a bulldozer to clear a rubble hex (unofficial rule).static final intA rubble clear is capped at this many turns regardless of structure type (wall/ultra treated as hardened). -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanBackhoeClearRubble(Entity entity, Game game) static booleancanClearRubble(Entity entity, Game game) static StringclearingToolName(Entity entity) static intclearingTurnsFor(int rubbleLevel) static StringclearRubbleIllegalReason(Entity entity, Hex hex, Game game) Checks whether a vehicle may declare a Clear Rubble action ending in the given hex (TacOps): it must be a vehicle with a working bulldozer (or, with the unofficial rule, a backhoe), the relevant optional rule(s) must be enabled, and the hex must hold rubble.static intextraClearingTurns(Entity entity, Game game) static booleanhasClearableRubble(Hex hex) static booleanisInOrAdjacentToClearableRubble(Entity entity, Game game) rollDestructionFromLocationDamage(Tank tank, int location) Resolves the bulldozer destruction check after a vehicle location takes damage (TacOps): if the location mounts a working bulldozer, rolls 2D6 and, on a result of 2, destroys that bulldozer.static inttotalClearingTurns(Entity entity, Hex hex, Game game)
-
Field Details
-
BACKHOE_CLEAR_TURN_PENALTY
public static final int BACKHOE_CLEAR_TURN_PENALTYExtra turns a backhoe takes vs a bulldozer to clear a rubble hex (unofficial rule).- See Also:
-
MAX_CLEAR_TURNS
public static final int MAX_CLEAR_TURNSA rubble clear is capped at this many turns regardless of structure type (wall/ultra treated as hardened).- See Also:
-
-
Method Details
-
canBackhoeClearRubble
- Parameters:
entity- the unit to check (a vehicle or a Mek)game- the game, for the optional-rule checks- Returns:
trueif this unit clears rubble using a backhoe under the unofficial rule: it has a working backhoe, no bulldozer to use instead, and both the TacOps Bulldozers and the unofficial backhoe rules are enabled. Clearing with a backhoe is slower (seeBACKHOE_CLEAR_TURN_PENALTY).
-
canClearRubble
- Parameters:
entity- the unit to checkgame- the game, for the optional-rule checks- Returns:
trueif the unit may currently clear rubble - a vehicle with a working bulldozer (with the TacOps Bulldozers rule on), or with a working backhoe (with the unofficial backhoe rule on).
-
extraClearingTurns
- Parameters:
entity- the clearing unitgame- the game, for the optional-rule checks- Returns:
- the extra turns this vehicle's clearing takes because it uses a backhoe rather than a bulldozer
(unofficial:
BACKHOE_CLEAR_TURN_PENALTY), or 0 when clearing with a bulldozer
-
clearingTurnsFor
public static int clearingTurnsFor(int rubbleLevel) - Parameters:
rubbleLevel- the RUBBLE terrain level (structure type: 1 light .. 6 ultra)- Returns:
- the base turns a bulldozer needs to clear that rubble (2/4/8/16 by structure type, capped at 16). TacOps.
-
totalClearingTurns
- Parameters:
entity- the clearing unithex- the rubble hex, ornullgame- the game, for the optional-rule checks- Returns:
- the total turns this unit needs to clear the hex - the base time plus any backhoe penalty - or 0 when the hex holds no rubble
-
clearingToolName
- Parameters:
entity- the clearing unit- Returns:
- the localized name of the tool the unit clears rubble with (its bulldozer, or otherwise its backhoe), for reports and prompts
-
clearRubbleIllegalReason
@Nullable public static String clearRubbleIllegalReason(Entity entity, @Nullable Hex hex, Game game) Checks whether a vehicle may declare a Clear Rubble action ending in the given hex (TacOps): it must be a vehicle with a working bulldozer (or, with the unofficial rule, a backhoe), the relevant optional rule(s) must be enabled, and the hex must hold rubble. Returns the specific reason it is illegal so the caller can log it, ornullwhen legal.- Parameters:
entity- the unit attempting to clear rubblehex- the hex the clearing would take place in (the unit's final hex), ornullgame- the game, for the optional-rule check- Returns:
- a human-readable reason the clear is illegal, or
nullif it is legal
-
hasClearableRubble
- Parameters:
hex- the hex to test, ornull- Returns:
trueif the hex exists and holds rubble a bulldozer could clear
-
isInOrAdjacentToClearableRubble
- Parameters:
entity- the vehicle to checkgame- the game, for board access- Returns:
trueif the vehicle occupies a rubble hex or is adjacent to one, so a bulldozer could drive in and clear it (TacOps). Used to gate the Clear Rubble button.
-
rollDestructionFromLocationDamage
Resolves the bulldozer destruction check after a vehicle location takes damage (TacOps): if the location mounts a working bulldozer, rolls 2D6 and, on a result of 2, destroys that bulldozer. Other results - and locations with no working bulldozer - leave it intact.- Parameters:
tank- the vehicle whose location took damagelocation- the location that took damage- Returns:
- a
Reportdescribing the destroyed bulldozer if it was destroyed, otherwise empty
-