Class FormationNamer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne formation awaiting a name.static final recordThe name chosen for a formation, plus the designator its children should be qualified with.static interfaceLooks up the naming rule for an echelon. -
Constructor Summary
ConstructorsConstructorDescriptionFormationNamer(ForceNamingMethod namingMethod, Collection<String> existingNames) FormationNamer(ForceNamingMethod namingMethod, Collection<String> existingNames, FormationNamer.NamingTierResolver tierResolver) -
Method Summary
Modifier and TypeMethodDescriptionnameSiblings(List<FormationNamer.FormationRequest> siblings, String parentDesignator) Names every formation sharing one parent, in tree order.voidsetAlwaysNumberRegiments(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.
-
Constructor Details
-
FormationNamer
- Parameters:
namingMethod- the alphabet style selected on the Setup tab;nullfalls back toForceNamingMethod.CCB_1943existingNames- every formation name already present in the campaign TO&E, so a second generator run does not reuse names the first one took (may be empty)
-
FormationNamer
public FormationNamer(@Nullable ForceNamingMethod namingMethod, Collection<String> existingNames, FormationNamer.NamingTierResolver tierResolver) - Parameters:
namingMethod- the alphabet style selected on the Setup tab;nullfalls back toForceNamingMethod.CCB_1943existingNames- every formation name already present in the campaign TO&EtierResolver- supplies the per-echelon naming rule; production callers use theFormationNamer(ForceNamingMethod, Collection)constructor, which reads the faction rulesets
-
-
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.REGIMENTrather 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 treeparentDesignator- the enclosing formation's designator, ornullat the top of the command- Returns:
- one
FormationNamer.NamedFormationper request, in the same order
-