Class LanceRoles

java.lang.Object
megamek.common.orders.LanceRoles

public final class LanceRoles extends Object
Finding and defaulting lance roles: which lances on a side are convoys an escort can guard, and the edge a new convoy leaves by.
  • Method Details

    • convoyChoices

      public static List<LanceRoles.ConvoyChoice> convoyChoices(Game game, Player side, int excludeForceId)
      The lances an escort can be given: every other lance on the side with a bot's units, convoys first. One that is not a convoy yet becomes one when an escort is given it, so roles can be set in any order (HammerGS, 2026-10-03). Escort lances are left out.
      Parameters:
      game - the game
      side - a player of the side
      excludeForceId - a lance to leave out - the escort itself - or -1
      Returns:
      the lances, convoys first, each group in force order
    • unitsOf

      public static List<Entity> unitsOf(Game game, int forceId)
      Returns:
      a lance's units still in the game, deployed or not
    • defaultExitEdge

      public static OffBoardDirection defaultExitEdge(@Nullable Entity unit)
      The edge a new convoy leaves by: the one opposite where its units deploy - deploy south, exit north (HammerGS, 2026-10-02). North when the deployment is not along an edge.
      Parameters:
      unit - one of the convoy's units, or null
      Returns:
      the edge
    • effectiveRole

      @Nullable public static LanceRole effectiveRole(Entity unit)
      The role of a unit's lance: its own, else that of a unit of the same owner in the same lance, so a unit added to a convoy or escort lance later joins it (HammerGS, 2026-10-03). This looks through every unit in the game; the bot, which asks for every move it scores, keeps its own table a phase instead.
      Parameters:
      unit - a unit
      Returns:
      the role, or null for none
    • roleOf

      @Nullable public static LanceRole roleOf(List<Entity> units)
      Parameters:
      units - a lance's units
      Returns:
      the role its units share, or the first one found; null when none has a role