Skip to content

Commit 5498524

Browse files
authored
Merge pull request #7210 from SJuliez/export-factions-to-yaml-without-data
Faction data as yml
2 parents ad2deb2 + 3474275 commit 5498524

File tree

14 files changed

+189
-2887
lines changed

14 files changed

+189
-2887
lines changed

MekHQ/data/universe/factions.xml

Lines changed: 0 additions & 2364 deletions
This file was deleted.

MekHQ/src/mekhq/campaign/force/CombatTeam.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,10 @@ public static int getStandardForceSize(Faction faction) {
119119
* @return The standard force size, at the provided formation level, for the provided faction
120120
*/
121121
public static int getStandardForceSize(Faction faction, int formationLevelDepth) {
122-
int formationSize;
123-
if (faction.isClan() || faction.isMarianHegemony()) {
124-
formationSize = STAR_SIZE;
125-
} else if (faction.isComStarOrWoB()) {
126-
formationSize = LEVEL_II_SIZE;
127-
} else {
128-
formationSize = LANCE_SIZE;
129-
}
130-
131-
if (formationLevelDepth == LANCE.getDepth()) {
132-
return formationSize;
122+
int formationSize = faction.getFormationBaseSize();
123+
for (int i = 1; i <= formationLevelDepth; i++) {
124+
formationSize *= faction.getFormationGrouping();
133125
}
134-
135-
if (faction.isComStarOrWoB()) {
136-
formationSize *= (int) Math.pow(6, formationLevelDepth);
137-
} else {
138-
formationSize *= (int) Math.pow(3, formationLevelDepth);
139-
}
140-
141126
return formationSize;
142127
}
143128

MekHQ/src/mekhq/campaign/market/contractMarket/CamOpsContractMarket.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
import megamek.common.Compute;
5050
import megamek.common.enums.SkillLevel;
51+
import megamek.common.universe.FactionTag;
5152
import megamek.logging.MMLogger;
5253
import mekhq.MekHQ;
5354
import mekhq.campaign.Campaign;
@@ -63,7 +64,6 @@
6364
import mekhq.campaign.rating.CamOpsReputation.ReputationController;
6465
import mekhq.campaign.rating.IUnitRating;
6566
import mekhq.campaign.universe.Faction;
66-
import mekhq.campaign.universe.Faction.Tag;
6767
import mekhq.campaign.universe.Factions;
6868
import mekhq.campaign.universe.enums.HiringHallLevel;
6969

@@ -307,7 +307,7 @@ protected void rollCommandClause(final Contract contract, final int modifier, bo
307307
}
308308

309309
private Faction determineEmployer(Campaign campaign, int ratingMod, HiringHallModifiers hiringHallModifiers) {
310-
Collection<Tag> employerTags;
310+
Collection<FactionTag> employerTags;
311311
int roll = Compute.d6(2) + ratingMod + hiringHallModifiers.employersMod;
312312
if (roll < 6) {
313313
// Roll again on the independent employers column
@@ -319,19 +319,19 @@ private Faction determineEmployer(Campaign campaign, int ratingMod, HiringHallMo
319319
return getRandomEmployer(campaign, employerTags);
320320
}
321321

322-
private Faction getRandomEmployer(Campaign campaign, Collection<Tag> employerTags) {
322+
private Faction getRandomEmployer(Campaign campaign, Collection<FactionTag> employerTags) {
323323
Collection<Faction> factions = Factions.getInstance().getActiveFactions(campaign.getLocalDate());
324324
List<Faction> filtered = new ArrayList<>();
325325
for (Faction faction : factions) {
326326
// Clans only hire units within their own clan
327327
if (faction.isClan() && !faction.equals(campaign.getFaction())) {
328328
continue;
329329
}
330-
for (Tag employerTag : employerTags) {
330+
for (FactionTag employerTag : employerTags) {
331331
if (!faction.is(employerTag)) {
332332
// The SMALL tag has to be converted to independent for now, since for some reason
333333
// independent is coded as a string.
334-
if (employerTag == Tag.SMALL && faction.isIndependent()) {
334+
if (employerTag == FactionTag.SMALL && faction.isIndependent()) {
335335
continue;
336336
}
337337
break;
@@ -343,40 +343,40 @@ private Faction getRandomEmployer(Campaign campaign, Collection<Tag> employerTag
343343
return filtered.get(rand.nextInt(filtered.size()));
344344
}
345345

346-
private Collection<Tag> getEmployerTags(Campaign campaign, int roll, boolean independent) {
347-
Collection<Tag> tags = new ArrayList<>();
346+
private Collection<FactionTag> getEmployerTags(Campaign campaign, int roll, boolean independent) {
347+
Collection<FactionTag> tags = new ArrayList<>();
348348
if (independent) {
349-
tags.add(Tag.SMALL);
349+
tags.add(FactionTag.SMALL);
350350
if (roll < 4) {
351-
tags.add(Tag.NOBLE);
351+
tags.add(FactionTag.NOBLE);
352352
} else if (roll < 6) {
353-
tags.add(Tag.PLANETARY_GOVERNMENT);
353+
tags.add(FactionTag.PLANETARY_GOVERNMENT);
354354
} else if (roll == 6) {
355-
tags.add(Tag.MERC);
355+
tags.add(FactionTag.MERC);
356356
} else if (roll < 9) {
357-
tags.add(Tag.PERIPHERY);
358-
tags.add(Tag.MAJOR);
357+
tags.add(FactionTag.PERIPHERY);
358+
tags.add(FactionTag.MAJOR);
359359
} else if (roll < 11) {
360-
tags.add(Tag.PERIPHERY);
361-
tags.add(Tag.MINOR);
360+
tags.add(FactionTag.PERIPHERY);
361+
tags.add(FactionTag.MINOR);
362362
} else {
363-
tags.add(Tag.CORPORATION);
363+
tags.add(FactionTag.CORPORATION);
364364
}
365365
} else {
366366
if (roll < 6) {
367-
tags.add(Tag.SMALL);
367+
tags.add(FactionTag.SMALL);
368368
} else if (roll < 8) {
369-
tags.add(Tag.MINOR);
369+
tags.add(FactionTag.MINOR);
370370
} else if (roll < 11) {
371-
tags.add(Tag.MAJOR);
371+
tags.add(FactionTag.MAJOR);
372372
} else {
373373
if (Factions.getInstance()
374374
.getActiveFactions(campaign.getLocalDate())
375375
.stream()
376376
.anyMatch(Faction::isSuperPower)) {
377-
tags.add(Tag.SUPER);
377+
tags.add(FactionTag.SUPER);
378378
} else {
379-
tags.add(Tag.MAJOR);
379+
tags.add(FactionTag.MAJOR);
380380
}
381381
}
382382
}

MekHQ/src/mekhq/campaign/mission/AtBContract.java

Lines changed: 8 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -345,95 +345,16 @@ public static Camouflage pickRandomCamouflage(int currentYear, String factionCod
345345
}
346346

347347
/**
348-
* Retrieves the directory for the camouflage of a faction based on the current year and faction code.
348+
* Returns the directory for the camouflages of a faction based on the year and faction code.
349349
*
350-
* @param currentYear The current year in the game.
351-
* @param factionCode The code representing the faction.
352-
*
353-
* @return The directory for the camouflage of the faction.
350+
* @param year The year
351+
* @param factionCode The code representing the faction, e.g. FS or HL
352+
* @return The directory under data/images/camo for the camouflages of the faction
354353
*/
355-
private static String getCamouflageDirectory(int currentYear, String factionCode) {
356-
return switch (factionCode) {
357-
case "ARC" -> "Aurigan Coalition";
358-
case "CDP" -> "Calderon Protectorate";
359-
case "CC" -> "Capellan Confederation";
360-
case "CIR" -> "Circinus Federation";
361-
case "CS" -> "ComStar";
362-
case "DC" -> "Draconis Combine";
363-
case "CF" -> "Federated Commonwealth";
364-
case "FS" -> "Federated Suns";
365-
case "FVC" -> "Filtvelt Coalition";
366-
case "FRR" -> "Free Rasalhague Republic";
367-
case "FWL" -> "Free Worlds League";
368-
case "FR" -> "Fronc Reaches";
369-
case "HL" -> "Hanseatic League";
370-
case "LL" -> "Lothian League";
371-
case "LA" -> "Lyran Commonwealth";
372-
case "MOC" -> "Magistracy of Canopus";
373-
case "MH" -> "Marian Hegemony";
374-
case "MERC" -> "Mercs";
375-
case "OA" -> "Outworlds Alliance";
376-
case "PIR" -> "Pirates";
377-
case "ROS" -> "Republic of the Sphere";
378-
case "SL" -> "Star League Defense Force";
379-
case "TC" -> "Taurian Concordat";
380-
case "WOB" -> "Word of Blake";
381-
case "Root" -> "";
382-
default -> {
383-
Faction faction = Factions.getInstance().getFaction(factionCode);
384-
385-
if (faction.isClan()) {
386-
yield getClanCamouflageDirectory(currentYear, factionCode);
387-
} else {
388-
yield "Standard Camouflage";
389-
}
390-
}
391-
};
392-
}
393-
394-
/**
395-
* Retrieves the directory for the camouflage of a clan faction based on the current year and faction code.
396-
*
397-
* @param currentYear The current year in the game.
398-
* @param factionCode The code representing the faction.
399-
*
400-
* @return The directory for the camouflage of the clan faction.
401-
*/
402-
private static String getClanCamouflageDirectory(int currentYear, String factionCode) {
403-
final String ROOT_DIRECTORY = "Clans/";
404-
405-
return switch (factionCode) {
406-
case "CBS" -> ROOT_DIRECTORY + "Blood Spirit";
407-
case "CB" -> ROOT_DIRECTORY + "Burrock";
408-
case "CCC" -> ROOT_DIRECTORY + "Cloud Cobra";
409-
case "CCO" -> ROOT_DIRECTORY + "Coyote";
410-
case "CDS" -> {
411-
if (currentYear < 3100) {
412-
yield ROOT_DIRECTORY + "Diamond Shark";
413-
} else {
414-
yield ROOT_DIRECTORY + "Sea Fox (Dark Age)";
415-
}
416-
}
417-
case "CFM" -> ROOT_DIRECTORY + "Fire Mandrill";
418-
case "CGB", "RD" -> ROOT_DIRECTORY + "Ghost Bear";
419-
case "CGS" -> ROOT_DIRECTORY + "Goliath Scorpion";
420-
case "CHH" -> ROOT_DIRECTORY + "Hell's Horses";
421-
case "CIH" -> ROOT_DIRECTORY + "Ice Hellion";
422-
case "CJF" -> ROOT_DIRECTORY + "Jade Falcon";
423-
case "CMG" -> ROOT_DIRECTORY + "Mongoose";
424-
case "CNC" -> ROOT_DIRECTORY + "Nova Cat";
425-
case "CSJ" -> ROOT_DIRECTORY + "Smoke Jaguar";
426-
case "CSR" -> ROOT_DIRECTORY + "Snow Raven";
427-
case "SOC" -> ROOT_DIRECTORY + "Society";
428-
case "CSA" -> ROOT_DIRECTORY + "Star Adder";
429-
case "CSV" -> ROOT_DIRECTORY + "Steel Viper";
430-
case "CSL" -> ROOT_DIRECTORY + "Stone Lion";
431-
case "CWI" -> ROOT_DIRECTORY + "Widowmaker";
432-
case "CW", "CWE" -> ROOT_DIRECTORY + "Wolf";
433-
case "CWIE" -> ROOT_DIRECTORY + "Wolf-in-Exile";
434-
case "CWOV" -> ROOT_DIRECTORY + "Wolverine";
435-
default -> "Standard Camouflage";
436-
};
354+
private static String getCamouflageDirectory(int year, String factionCode) {
355+
return Factions.getInstance().getFaction(factionCode)
356+
.getCamosFolder(year)
357+
.orElse("Standard Camouflage");
437358
}
438359

439360
public void calculateLength(final boolean variable) {

MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import megamek.common.equipment.WeaponMounted;
8080
import megamek.common.icons.Camouflage;
8181
import megamek.common.planetaryconditions.Atmosphere;
82+
import megamek.common.universe.FactionTag;
8283
import megamek.common.planetaryconditions.Wind;
8384
import megamek.logging.MMLogger;
8485
import mekhq.MHQConstants;
@@ -112,15 +113,14 @@
112113
import mekhq.campaign.stratcon.StratconTrackState;
113114
import mekhq.campaign.unit.Unit;
114115
import mekhq.campaign.universe.Faction;
115-
import mekhq.campaign.universe.Faction.Tag;
116116
import mekhq.campaign.universe.Factions;
117117
import mekhq.campaign.universe.IUnitGenerator;
118118
import mekhq.campaign.universe.Planet;
119119
import mekhq.campaign.universe.PlanetarySystem;
120120
import mekhq.campaign.universe.Systems;
121121
import mekhq.campaign.universe.UnitGeneratorParameters;
122122
import mekhq.campaign.universe.enums.EraFlag;
123-
import mekhq.campaign.universe.enums.HonorRating;
123+
import megamek.common.universe.HonorRating;
124124
import mekhq.campaign.universe.factionStanding.BatchallFactions;
125125

126126
/**
@@ -2826,9 +2826,9 @@ private static Entity getEntityByName(String name, String factionCode, SkillLeve
28262826
faction.isClan(), extraData);
28272827

28282828
CampaignOptions campaignOptions = campaign.getCampaignOptions();
2829-
2829+
28302830
// Optionally assign a callsign to the unit commander if enabled and skill at or above minimum level
2831-
if (campaignOptions.isAutoGenerateOpForCallsigns() &&
2831+
if (campaignOptions.isAutoGenerateOpForCallsigns() &&
28322832
(skill.equalsOrGreaterThan(campaignOptions.getMinimumCallsignSkillLevel()))) {
28332833
entityCrew.setNickname(RandomCallsignGenerator.getInstance().generate(), 0);
28342834
}
@@ -4634,7 +4634,7 @@ static String getPlanetOwnerFaction(AtBContract contract, LocalDate currentDate)
46344634
factionCode = planetFactions.get(0);
46354635
Faction ownerFaction = Factions.getInstance().getFaction(factionCode);
46364636

4637-
if (ownerFaction.is(Tag.ABANDONED)) {
4637+
if (ownerFaction.is(FactionTag.ABANDONED)) {
46384638
factionCode = "MERC";
46394639
}
46404640
}

MekHQ/src/mekhq/campaign/randomEvents/prisoners/CapturePrisoners.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
import mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus;
7272
import mekhq.campaign.universe.Faction;
7373
import mekhq.campaign.universe.Factions;
74-
import mekhq.campaign.universe.enums.HonorRating;
74+
import megamek.common.universe.HonorRating;
7575
import mekhq.utilities.ReportingUtilities;
7676
import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple;
7777

0 commit comments

Comments
 (0)