Skip to content

Unify MHQ Faction and FactionRecord and use yaml faction data files #6735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from

Conversation

SJuliez
Copy link
Member

@SJuliez SJuliez commented Mar 20, 2025

This PR together with MML and MHQ PRs aims to unify the faction data of MHQ and MM on the MM side to make it available everywhere and use individual yaml files instead of a single huge xml file.

  • For now, the old classes are preserved and still used; they only get their data from the new Faction2 class (the best name I could come up with) instead of loading it from factions.xml (=2 separate and different files in MHQ and MM)
  • FactionRecord also loads complicated era-based RAT data from other files, this is unchanged; it doesnt seem useful to place this inside the yamls as this would make the yamls unwieldy
  • Factions2 reads its data from the data/universe/factions and data/universe/commands folders. These need to be replicated in MML and MHQ so long as we dont have a unified data repo.
  • "commands" are the subfactions (those with a dot in the name), e.g. the Hesperus Guards; in other words, combat groups rather than political entities; sorting their yaml data in their own folder is purely for cleanliness, it doesnt matter where which yaml file is. In the future, it's possible that additional commands data will make separate classes (in addition to separate yamls) better, but for now it's still good
  • data is also read from the user directory, if available, so [userdir]/data/universe/factions or /commands; factions there will be added; if they have the same key as a canon faction, they replace the original
  • "startingplanet" has been renamed "capital" as it was used for that purpose only

This is pretty hefty for review, but when filtering out the .yml files, it's only a handful of classes. Ideally, the whole thing should have no visible effect in MM, MML or MHQ except fix a bug with MML faction selection which omitted a bunch of factions.

@IllianiBird
Copy link
Collaborator

Thank you so much for doing this, Juli. As someone who works with factions more than a little, I just wanted to say how appreciated this work is.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.74%. Comparing base (964546d) to head (cc3fdb1).
Report is 5 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6735      +/-   ##
============================================
+ Coverage     30.70%   30.74%   +0.04%     
- Complexity    17579    17596      +17     
============================================
  Files          2979     2986       +7     
  Lines        291298   291473     +175     
  Branches      50715    50731      +16     
============================================
+ Hits          89436    89619     +183     
+ Misses       195160   195149      -11     
- Partials       6702     6705       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if (!ratingLevels.isEmpty()) {
pw.println("\t\t<ratingLevels>" + StringEscapeUtils.escapeXml10(String.join(",", ratingLevels))
+ "</ratingLevels>");
public void saveIfChanged() throws IOException {

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
return tags;
}

public List<FactionRecord.DateRange> getYearsActive() {

Check notice

Code scanning / CodeQL

Exposing internal representation Note

getYearsActive exposes the internal representation stored in field yearsActive. The value may be modified
after this call to getYearsActive
.
getYearsActive exposes the internal representation stored in field yearsActive. The value may be modified
after this call to getYearsActive
.
@HammerGS HammerGS added Data Hammertime. For New Dev Cycle This PR should be merged at the beginning of a dev cycle labels Mar 20, 2025
@AaronGullickson
Copy link
Member

Are any of the faction codes in MHQ actually different? Because all of the planetary data depends on these....

@SJuliez
Copy link
Member Author

SJuliez commented Mar 21, 2025

The faction codes are generally equal aside from some MHQ factions that are missing in the RATs and vice versa and a very small number of, well, data bugs, e.g. we have three versions of the Tamar Pact with different codes.

@rjhancock
Copy link
Collaborator

Taking a quick glance, the era mods might be an issue. Which mod works with which era? Needs labels.

@SuperStucco
Copy link
Collaborator

Don't suppose you could update the Bandit Caste (BAN code) to include the full range of equipment ratings? While under-equipped - top-rated Bandit Caste is certainly not the same as top-rated Clan forces - there should still be a range of availability from the Society-derived forces fielded by The Jaguar and Tanite/ex-Burrock forces to the dregs that are barely getting by.
As it stands they are coded for 'Solahma' only, which also kind of conflicts with the availability XMLs which provide two levels.

@AaronGullickson
Copy link
Member

The faction codes are generally equal aside from some MHQ factions that are missing in the RATs and vice versa and a very small number of, well, data bugs, e.g. we have three versions of the Tamar Pact with different codes.

Whoops meant to quote reply and I edited above. If you are editing the factions, we should ensure these are not in use by planetary systems.

@HammerGS HammerGS removed the For New Dev Cycle This PR should be merged at the beginning of a dev cycle label Apr 26, 2025
@HammerGS HammerGS requested a review from Copilot May 14, 2025 21:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces individual YAML files under megamek/data/universe/commands to represent each subfaction (command) with their metadata (key, name, active years, rating levels, fallback factions).

  • Adds new YAML definitions for 20 commands, replacing the old XML-based setup.
  • Aligns the fallback faction data retrieval with the new Faction2 class mechanism.

Reviewed Changes

Copilot reviewed 372 out of 372 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
megamek/data/universe/commands/CC.TG.yml Add Tikonov Guards command YAML
megamek/data/universe/commands/CC.SSB.yml Add Sarna Sabres Brigade command YAML
megamek/data/universe/commands/CC.SIS.yml Add St Ives Sentinels command YAML
megamek/data/universe/commands/CC.SIJ.yml Add St Ives Janissaries command YAML
megamek/data/universe/commands/CC.SIAC.yml Add St Ives Armored Cavalry YAML
megamek/data/universe/commands/CC.SD.yml Add Sian Lancers command YAML
megamek/data/universe/commands/CC.MAC.yml Add McCarron's Armored Cavalry YAML
megamek/data/universe/commands/CC.LL.yml Add Liao Lancers command YAML
megamek/data/universe/commands/CC.LG.yml Add Liao Guards command YAML
megamek/data/universe/commands/CC.LCC.yml Add Liao Cháng-Chéng command YAML
megamek/data/universe/commands/CC.DC.yml Add Death Commandos command YAML
megamek/data/universe/commands/CC.CRC.yml Add Confederation Reserve Cavalry
megamek/data/universe/commands/CC.CR.yml Add Chesterton Regulars command YAML
megamek/data/universe/commands/CC.CHO.yml Add Citizens' Honored command YAML
megamek/data/universe/commands/CC.CHG.yml Add Capellan Home Guard command YAML
megamek/data/universe/commands/CC.CH.yml Add Capellan Hussars command YAML
megamek/data/universe/commands/CC.CDF.yml Add Capellan Defense Force command
megamek/data/universe/commands/CC.CC.yml Add Capellan Chargers command YAML
megamek/data/universe/commands/CC.CB.yml Add Capellan Brigade command YAML
megamek/data/universe/commands/CC.AH.yml Add Andurien Hussars command YAML
Comments suppressed due to low confidence (1)

megamek/data/universe/commands/CC.LCC.yml:2

  • [nitpick] The name uses accented characters (Cháng-Chéng) while other entries use plain ASCII. Consider normalizing to Liao Chang-Cheng for consistency.
name: Liao Cháng-Chéng

yearsActive:
- start: 2367
end: 2823
- start: 3113
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second yearsActive entry has only a start date. If this period is meant to be open-ended, add a comment or document that convention; otherwise specify an end date for clarity.

Suggested change
- start: 3113
- start: 3113 # Open-ended period, ongoing

Copilot uses AI. Check for mistakes.

@HammerGS
Copy link
Member

Hi @SJuliez

You seem to be on a break but their is interest in merging this if its ready to go, can you advise?

Cheers
Hammer

@AaronGullickson
Copy link
Member

Well, there are conflicts so no merge at the moment. Also, I need to make some changes to factions for the big SMACK project (which I have not been able to find time for). I don't think that will likely affect this much as it is mostly about removing unused factions but its probably worth checking.

SJuliez added 10 commits June 13, 2025 21:55
# Conflicts:
#	megamek/src/megamek/client/ratgenerator/RATGenerator.java
#	megamek/src/megamek/client/ui/dialogs/randomArmy/ForceGeneratorOptionsView.java
#	megamek/src/megamek/client/ui/dialogs/randomArmy/RandomArmyDialog.java
@SJuliez SJuliez mentioned this pull request Jun 15, 2025
@SJuliez
Copy link
Member Author

SJuliez commented Jun 15, 2025

Replaced by #7246

@SJuliez SJuliez closed this Jun 15, 2025
rjhancock added a commit that referenced this pull request Jun 18, 2025
See the description and discussion in #6735, this PR replaces the old
one and does not include the data; comes in separate PR.
I wanted to have the data separate so it's easier to review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Hammertime.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants