Class FormationNamer

java.lang.Object
mekhq.campaign.universe.commandGeneration.ratgen.FormationNamer

public class FormationNamer extends Object
Produces unique, player-parseable names for the Formation nodes the Command Generator mirrors into the campaign TO&E.

A generated formation name has two parts, and only one of them belongs to this class:

  • Flavour - "Battle Lance", "Assault Cluster", "Trinary [Battle]", "IV-alpha". Produced by the faction ruleset, carries canon meaning, and is preserved verbatim. This class never invents flavour.
  • Designator - "Alpha", "First", "1". Purely positional, and the part the ruleset cannot express because it depends on where a formation sits among its siblings.

Which designator each echelon takes is declared per faction in the ruleset's <formationNaming> element and resolved through Ruleset.findNamingTier(int), so Inner Sphere companies take the player's chosen alphabet, Clan galaxies take Greek letters, and ComStar Level IV formations keep the ruleset's name untouched. In particular, a ComStar Greek suffix denotes branch specialisation rather than sequence position - "IV-alpha" and "IV-beta" are different kinds of formation - so those names are never advanced or prefixed.

Naming happens per sibling group, not per formation. nameSiblings(java.util.List<mekhq.campaign.universe.commandGeneration.ratgen.FormationNamer.FormationRequest>, java.lang.String) receives every formation that shares a parent and names them together, which is what allows designator sequences to restart under each parent ("Alpha, Beta, Gamma" in every battalion rather than running A-to-Z across a regiment) and what lets a collision be resolved consistently for the whole group instead of leaving the first sibling bare and suffixing the second.

Uniqueness comes from qualification rather than counters. A tier declaring qualifyWith="parent" prefixes its parent's designator, giving "1/Alpha Company" and "1/Alpha-1 Battle Lance"; the numeric counter fallback ("... (2)") exists only for names that cannot be qualified, and a name reaching a player with one indicates a ruleset data gap.

  • Constructor Details

  • Method Details

    • setAlwaysNumberRegiments

      public void setAlwaysNumberRegiments(boolean alwaysNumberRegiments)
      Overrides the faction convention at regiment level so regiments take a numeric ordinal - "1st Mek Regiment", "2nd Mek Regiment" - instead of the selected naming alphabet. Because each unit type counts as its own arm, an armor regiment alongside two Mek regiments is "1st Armor Regiment" rather than "3rd".

      Keyed on FormationLevel.REGIMENT rather than on an echelon number, so it applies to Inner Sphere and Periphery regiments without catching the Clan Cluster or ComStar Level IV that share their echelon number.

      Parameters:
      alwaysNumberRegiments - the player's "Always number regiments" selection
    • nameSiblings

      public List<FormationNamer.NamedFormation> nameSiblings(List<FormationNamer.FormationRequest> siblings, @Nullable String parentDesignator)
      Names every formation sharing one parent, in tree order.

      Designator sequences restart with each call, which is what makes company letters restart in each battalion. Candidates whose resulting name is already taken are skipped, so a second generator run adding a fourth company to an existing battalion continues that battalion's sequence rather than colliding with it.

      Parameters:
      siblings - the formations sharing a parent, in the order they appear in the tree
      parentDesignator - the enclosing formation's designator, or null at the top of the command
      Returns:
      one FormationNamer.NamedFormation per request, in the same order