Class BulldozerRules

java.lang.Object
megamek.common.units.BulldozerRules

public final class BulldozerRules extends Object
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 Details

    • BACKHOE_CLEAR_TURN_PENALTY

      public static final int BACKHOE_CLEAR_TURN_PENALTY
      Extra 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_TURNS
      A rubble clear is capped at this many turns regardless of structure type (wall/ultra treated as hardened).
      See Also:
  • Method Details

    • canBackhoeClearRubble

      public static boolean canBackhoeClearRubble(Entity entity, Game game)
      Parameters:
      entity - the unit to check (a vehicle or a Mek)
      game - the game, for the optional-rule checks
      Returns:
      true if 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 (see BACKHOE_CLEAR_TURN_PENALTY).
    • canClearRubble

      public static boolean canClearRubble(Entity entity, Game game)
      Parameters:
      entity - the unit to check
      game - the game, for the optional-rule checks
      Returns:
      true if 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

      public static int extraClearingTurns(Entity entity, Game game)
      Parameters:
      entity - the clearing unit
      game - 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

      public static int totalClearingTurns(Entity entity, @Nullable Hex hex, Game game)
      Parameters:
      entity - the clearing unit
      hex - the rubble hex, or null
      game - 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

      public static String clearingToolName(Entity entity)
      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, or null when legal.
      Parameters:
      entity - the unit attempting to clear rubble
      hex - the hex the clearing would take place in (the unit's final hex), or null
      game - the game, for the optional-rule check
      Returns:
      a human-readable reason the clear is illegal, or null if it is legal
    • hasClearableRubble

      public static boolean hasClearableRubble(@Nullable Hex hex)
      Parameters:
      hex - the hex to test, or null
      Returns:
      true if the hex exists and holds rubble a bulldozer could clear
    • isInOrAdjacentToClearableRubble

      public static boolean isInOrAdjacentToClearableRubble(Entity entity, Game game)
      Parameters:
      entity - the vehicle to check
      game - the game, for board access
      Returns:
      true if 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

      public static Optional<Report> 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. Other results - and locations with no working bulldozer - leave it intact.
      Parameters:
      tank - the vehicle whose location took damage
      location - the location that took damage
      Returns:
      a Report describing the destroyed bulldozer if it was destroyed, otherwise empty