Skip to content
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

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
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 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 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 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 unfortunately pretty hefty. Ideally, the whole thing should have no visible effect in MM, MML or MHQ.

@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 29.34%. Comparing base (95af77b) to head (702d1c8).
Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##             master    #6735    +/-   ##
==========================================
  Coverage     29.33%   29.34%            
- Complexity    15600    15631    +31     
==========================================
  Files          2864     2870     +6     
  Lines        279533   279745   +212     
  Branches      49326    49351    +25     
==========================================
+ Hits          82004    82080    +76     
- Misses       191975   192106   +131     
- Partials       5554     5559     +5     

☔ 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'.
}
// As a temporary measure, the RAT Generator factions are populated from the new unified factions
// list instead of using that directly.
var yamlFactions = Factions2.getInstance();

Check warning

Code scanning / CodeQL

Potential input resource leak Warning

This FileInputStream is not always closed on method exit.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Hammertime. For New Dev Cycle This PR should be merged at the beginning of a dev cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants