Package megamek.common.universe
Class Ranks
java.lang.Object
megamek.common.universe.Ranks
Lightweight loader for
data/universe/ranks.xml. Surfaces faction-specific officer titles to MegaMek consumers
that need to display them without depending on the full MekHQ rank-system stack.
The integer rank value used by the ratgen pipeline (CrewDescriptor.getRank()) is the same scheme MekHQ
stores on Persons, so a lookup by (rankSystemIndex, rankInt) returns the canonical short title — e.g.
(8, 34) → "Tai-i" for a DCMS Captain-equivalent.
The lookup is lazy and fault-tolerant: callers should fall back to a generic prefix when the loader returns empty (the data file is optional from MegaMek's perspective — it is canonically owned by mm-data).
-
Method Summary
Modifier and TypeMethodDescriptiongetByRatgenIndex(int ratgenIndex) static RanksresolveRankName(Integer ratgenIndex, int rankInt) Convenience accessor combininggetByRatgenIndex(int)withRankSystem.nameAt(int).
-
Method Details
-
getInstance
-
getByCode
- Parameters:
code- A rank-system code from ranks.xml, e.g. "LAAF" or "DCMS".- Returns:
- The matching rank system, or empty if none.
-
getByRatgenIndex
- Parameters:
ratgenIndex- The integer the ratgen ruleset stores in<rankSystem>(0-17 in the current data).- Returns:
- The matching rank system, or empty if the index is unknown or unmapped (e.g. RANK_CUSTOM).
-
resolveRankName
Convenience accessor combininggetByRatgenIndex(int)withRankSystem.nameAt(int).- Parameters:
ratgenIndex- The ratgen rank-system integer; toleratesnullso callers can passfd.getRankSystem()directly.rankInt- The zero-based rank index.- Returns:
- The short title (e.g. "Tai-i"), or empty if the system or rank cannot be resolved.
-