Class UnitReroller

java.lang.Object
megamek.client.ratgenerator.UnitReroller

public final class UnitReroller extends Object
Swaps one unit in a generated force for another, leaving the rest of its formation alone.

A player who does not want the Locust a lance rolled can ask for another unit in its place without rolling the whole lance again. The new unit is drawn for the same slot: the same unit type, weight class, movement mode and role, from the same faction table. It is never the design being replaced. If the formation has rules - a Recon lance that needs fast units, say - the new unit must leave the formation still meeting them. When nothing does, the slot keeps the unit it had.

A formation that fields one design in every slot - an artillery battery, a company of one model - is no exception. Only the unit picked is swapped, so it no longer matches its formation-mates, which keep the design they share. The player asked for that unit to go, and redrawing the whole formation is what Change Formation is for.

The pilot stays: the slot's commander is put in the new unit. The slot is also brought back into the force if it had been struck out, since striking a unit out and rerolling it both say the player did not want that unit.

  • Method Details

    • whyNotRerollable

      @Nullable public static UnitReroller.Refusal whyNotRerollable(ForceDescriptor slot)
      Says whether a node can be rerolled as a single unit.
      Parameters:
      slot - the node the player picked
      Returns:
      why it cannot, or null when it can
    • reroll

      @Nullable public static UnitReroller.Outcome reroll(ForceDescriptor slot)
      Replaces the unit in one slot with another drawn for the same slot.
      Parameters:
      slot - the node holding the unit to replace
      Returns:
      what was done, or null when the slot cannot be rerolled or nothing else fits it; the slot is left exactly as it was in that case