Package mekhq.campaign.personnel.ranks
Class AutomaticRankAssigner
java.lang.Object
mekhq.campaign.personnel.ranks.AutomaticRankAssigner
Utility class responsible for automatically assigning ranks to personnel. It can apply a faction's rank system and
select a valid rank for an individual, or assign missing ranks across a
Unit's crew.
When assigning a unit's crew, rank assignment follows a hierarchy: the unit commander receives the highest rank index, squad leaders (if applicable) receive an intermediate rank, and remaining crew members are assigned the next available rank below the leaders. Clan and ComStar/Word of Blake factions use simplified, flat rank assignments rather than the standard graduated system.
Only crew members who do not already hold a rank are affected; existing ranks are always preserved.
- Since:
- 0.51.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassignAscendingRank(Person person, int startIndex) Assigns the lowest valid rank to the given person, starting from the specified index and ascending until a valid rank is found orRank.RO_MAXis reached.static voidassignRanks(Campaign campaign, Unit unit, Faction faction) Assigns ranks to all unranked crew members of the givenUnit, respecting faction-specific rules and distributing ranks by experience level.static voidassignRankSystemFromFaction(Person person, int rankLevel)
-
Constructor Details
-
AutomaticRankAssigner
public AutomaticRankAssigner()
-
-
Method Details
-
assignRanks
Assigns ranks to all unranked crew members of the givenUnit, respecting faction-specific rules and distributing ranks by experience level.The assignment process proceeds as follows:
- The crew is sorted in descending order of experience so that more experienced personnel receive higher ranks.
- The unit commander is always assigned
COMMANDER_RANK_INDEX. - For Clan factions, conventional infantry members receive
CLAN_RANK; non-military-caste members receive no rank. - For ComStar and Word of Blake factions, every crew member receives
COMSTAR_RANK(Acolyte). - For all other factions, a number of crew members equal to the squad leader count (or 1, if not a conventional infantry unit) receive a leader-level rank, and the remaining crew receive the next rank below.
Personnel who already hold a rank are skipped entirely.
-
assignAscendingRank
Assigns the lowest valid rank to the given person, starting from the specified index and ascending until a valid rank is found orRank.RO_MAXis reached.- Parameters:
person- thePersonto assign a rank to; must not benullstartIndex- the rank value to begin searching from (inclusive)- Since:
- 0.51.0
-
assignRankSystemFromFaction
-