Skip to content

Commit

Permalink
Fixed post-merge weirdness
Browse files Browse the repository at this point in the history
  • Loading branch information
IllianiCBT committed Sep 25, 2024
1 parent 5ae936e commit f1f7c5a
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 251 deletions.
58 changes: 8 additions & 50 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@
*/
package mekhq.campaign;

import static mekhq.campaign.personnel.backgrounds.BackgroundsController.randomMercenaryCompanyNameGenerator;
import static mekhq.campaign.personnel.education.EducationController.getAcademy;
import static mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker.Payout.isBreakingContract;
import static mekhq.campaign.unit.Unit.SITE_FACILITY_MAINTENANCE;

import java.io.PrintWriter;
import java.text.MessageFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;

import javax.swing.JOptionPane;

import megamek.client.generator.RandomGenderGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.generator.RandomUnitGenerator;
Expand All @@ -54,11 +37,7 @@
import megamek.common.loaders.BLKFile;
import megamek.common.loaders.EntityLoadingException;
import megamek.common.loaders.EntitySavingException;
import megamek.common.options.GameOptions;
import megamek.common.options.IBasicOption;
import megamek.common.options.IOption;
import megamek.common.options.IOptionGroup;
import megamek.common.options.OptionsConstants;
import megamek.common.options.*;
import megamek.common.util.BuildingBlock;
import megamek.common.weapons.autocannons.ACWeapon;
import megamek.common.weapons.flamers.FlamerWeapon;
Expand All @@ -71,11 +50,7 @@
import mekhq.campaign.Quartermaster.PartAcquisitionResult;
import mekhq.campaign.againstTheBot.AtBConfiguration;
import mekhq.campaign.event.*;
import mekhq.campaign.finances.Accountant;
import mekhq.campaign.finances.CurrencyManager;
import mekhq.campaign.finances.Finances;
import mekhq.campaign.finances.Loan;
import mekhq.campaign.finances.Money;
import mekhq.campaign.finances.*;
import mekhq.campaign.finances.enums.TransactionType;
import mekhq.campaign.force.Force;
import mekhq.campaign.force.Lance;
Expand All @@ -90,12 +65,7 @@
import mekhq.campaign.market.ShoppingList;
import mekhq.campaign.market.unitMarket.AbstractUnitMarket;
import mekhq.campaign.market.unitMarket.DisabledUnitMarket;
import mekhq.campaign.mission.AtBContract;
import mekhq.campaign.mission.AtBDynamicScenario;
import mekhq.campaign.mission.AtBScenario;
import mekhq.campaign.mission.Contract;
import mekhq.campaign.mission.Mission;
import mekhq.campaign.mission.Scenario;
import mekhq.campaign.mission.*;
import mekhq.campaign.mission.atb.AtBScenarioFactory;
import mekhq.campaign.mission.enums.AtBLanceRole;
import mekhq.campaign.mission.enums.MissionStatus;
Expand All @@ -105,12 +75,7 @@
import mekhq.campaign.parts.equipment.AmmoBin;
import mekhq.campaign.parts.equipment.EquipmentPart;
import mekhq.campaign.parts.equipment.MissingEquipmentPart;
import mekhq.campaign.personnel.Bloodname;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.PersonnelOptions;
import mekhq.campaign.personnel.Skill;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.SpecialAbility;
import mekhq.campaign.personnel.*;
import mekhq.campaign.personnel.autoAwards.AutoAwardsController;
import mekhq.campaign.personnel.death.AbstractDeath;
import mekhq.campaign.personnel.death.DisabledRandomDeath;
Expand All @@ -129,21 +94,16 @@
import mekhq.campaign.personnel.ranks.Ranks;
import mekhq.campaign.personnel.turnoverAndRetention.Fatigue;
import mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker;
import mekhq.campaign.rating.CamOpsReputation.ReputationController;
import mekhq.campaign.rating.FieldManualMercRevDragoonsRating;
import mekhq.campaign.rating.IUnitRating;
import mekhq.campaign.rating.UnitRatingMethod;
import mekhq.campaign.rating.CamOpsReputation.ReputationController;
import mekhq.campaign.storyarc.StoryArc;
import mekhq.campaign.stratcon.StratconContractInitializer;
import mekhq.campaign.stratcon.StratconRulesManager;
import mekhq.campaign.stratcon.StratconTrackState;
import mekhq.campaign.unit.CargoStatistics;
import mekhq.campaign.unit.CrewType;
import mekhq.campaign.unit.HangarStatistics;
import mekhq.campaign.unit.TestUnit;
import mekhq.campaign.unit.Unit;
import mekhq.campaign.unit.UnitOrder;
import mekhq.campaign.unit.UnitTechProgression;
import mekhq.campaign.unit.*;
import mekhq.campaign.universe.*;
import mekhq.campaign.universe.Planet.PlanetaryEvent;
import mekhq.campaign.universe.PlanetarySystem.PlanetarySystemEvent;
Expand Down Expand Up @@ -190,8 +150,6 @@ public class Campaign implements ITechManager {

public static final String REPORT_LINEBREAK = "<br/><br/>";

private static final MMLogger logger = MMLogger.create(Person.class);

private UUID id;

// we have three things to track: (1) teams, (2) units, (3) repair tasks
Expand Down Expand Up @@ -4254,7 +4212,7 @@ private void processRandomDependents() {

int lowerRoll = (dependents.size() > dependentCapacity) ? getLowerRandomInt() : Compute.randomInt(100);

if (lowerRoll <= 4 - getUnitRatingMod()) {
if (lowerRoll <= 4 - getAtBUnitRatingMod()) {
addReport(String.format(resources.getString("dependentLeavesForce.text"),
dependent.getFullTitle()));

Expand All @@ -4272,7 +4230,7 @@ private void processRandomDependents() {
for (int i = 0; i < rollCount; i++) {
int lowerRoll = (dependentCount <= (dependentCapacity / 2)) ? getLowerRandomInt() : Compute.randomInt(100);

if (lowerRoll <= (getUnitRatingMod() * 2)) {
if (lowerRoll <= (getAtBUnitRatingMod() * 2)) {
final Person dependent = newDependent(false, Gender.RANDOMIZE);

recruitPerson(dependent, PrisonerStatus.FREE, true, false);
Expand Down
25 changes: 11 additions & 14 deletions MekHQ/src/mekhq/campaign/CampaignOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,13 @@
*/
package mekhq.campaign;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.Version;
import megamek.codeUtilities.MathUtility;
import megamek.common.EquipmentType;
import megamek.common.TechConstants;
import megamek.common.enums.SkillLevel;
import megamek.logging.MMLogger;
import mekhq.MekHQ;
import mekhq.Utilities;
import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit;
import mekhq.campaign.finances.Money;
Expand All @@ -45,10 +35,17 @@
import mekhq.campaign.market.enums.UnitMarketMethod;
import mekhq.campaign.mission.enums.AtBLanceRole;
import mekhq.campaign.parts.enums.PartRepairType;
import mekhq.campaign.personnel.Skills;
import mekhq.campaign.personnel.enums.*;
import mekhq.campaign.rating.UnitRatingMethod;
import mekhq.service.mrms.MRMSOption;
import mekhq.utilities.MHQXMLUtility;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.io.PrintWriter;
import java.util.*;
import java.util.Map.Entry;

/**
* @author natit
Expand Down Expand Up @@ -6165,7 +6162,7 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
} else if (wn2.getNodeName().equalsIgnoreCase("scenarioModBV")) {
retVal.setScenarioModBV(Integer.parseInt(wn2.getTextContent().trim()));
} else if (wn2.getNodeName().equalsIgnoreCase("autoconfigMunitions")) {
retVal.setAutoconfigMunitions(Boolean.parseBoolean(wn2.getTextContent().trim()));
retVal.setAutoConfigMunitions(Boolean.parseBoolean(wn2.getTextContent().trim()));

//region Legacy
// Removed in 0.49.*
Expand Down Expand Up @@ -6217,7 +6214,7 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
} else if (values.length == 9) {
retVal.migrateMarriageSurnameWeights47(values);
} else {
LogManager.getLogger().error("Unknown length of randomMarriageSurnameWeights");
logger.error("Unknown length of randomMarriageSurnameWeights");
}
} else if (wn2.getNodeName().equalsIgnoreCase("logConception")) { // Legacy - 0.49.4 Removal
retVal.setLogProcreation(Boolean.parseBoolean(wn2.getTextContent().trim()));
Expand Down Expand Up @@ -6277,7 +6274,7 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
retVal.setUnitRatingMethod(UnitRatingMethod.NONE);
}
} else if (wn2.getNodeName().equalsIgnoreCase("probPhenoMW")) { // Legacy
retVal.phenotypeProbabilities[Phenotype.MECHWARRIOR.ordinal()] = Integer.parseInt(wn2.getTextContent().trim());
retVal.phenotypeProbabilities[Phenotype.MEKWARRIOR.ordinal()] = Integer.parseInt(wn2.getTextContent().trim());
} else if (wn2.getNodeName().equalsIgnoreCase("probPhenoBA")) { // Legacy
retVal.phenotypeProbabilities[Phenotype.ELEMENTAL.ordinal()] = Integer.parseInt(wn2.getTextContent().trim());
} else if (wn2.getNodeName().equalsIgnoreCase("probPhenoAero")) { // Legacy
Expand Down
59 changes: 5 additions & 54 deletions MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,20 @@
*/
package mekhq.campaign.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;

import javax.xml.parsers.DocumentBuilder;

import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.Version;
import megamek.client.generator.RandomGenderGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.ui.swing.util.PlayerColour;
import megamek.common.Entity;
import megamek.common.EntityMovementMode;
import megamek.common.Jumpship;
import megamek.common.Mek;
import megamek.common.MekSummaryCache;
import megamek.common.MiscType;
import megamek.common.Mounted;
import megamek.common.SmallCraft;
import megamek.common.Tank;
import megamek.common.*;
import megamek.common.annotations.Nullable;
import megamek.common.icons.Camouflage;
import megamek.common.weapons.bayweapons.BayWeapon;
import megamek.logging.MMLogger;
import mekhq.MekHQ;
import mekhq.NullEntityException;
import mekhq.Utilities;
import mekhq.campaign.Campaign;
import mekhq.campaign.CampaignOptions;
import mekhq.campaign.CurrentLocation;
import mekhq.campaign.Kill;
import mekhq.campaign.RandomSkillPreferences;
import mekhq.campaign.Warehouse;
import mekhq.campaign.*;
import mekhq.campaign.againstTheBot.AtBConfiguration;
import mekhq.campaign.finances.Finances;
import mekhq.campaign.force.Force;
Expand All @@ -81,20 +44,8 @@
import mekhq.campaign.mission.Mission;
import mekhq.campaign.mission.Scenario;
import mekhq.campaign.mod.am.InjuryTypes;
import mekhq.campaign.parts.EnginePart;
import mekhq.campaign.parts.MekActuator;
import mekhq.campaign.parts.MekLocation;
import mekhq.campaign.parts.MissingEnginePart;
import mekhq.campaign.parts.MissingMekActuator;
import mekhq.campaign.parts.MissingPart;
import mekhq.campaign.parts.Part;
import mekhq.campaign.parts.equipment.AmmoBin;
import mekhq.campaign.parts.equipment.EquipmentPart;
import mekhq.campaign.parts.equipment.HeatSink;
import mekhq.campaign.parts.equipment.MASC;
import mekhq.campaign.parts.equipment.MissingAmmoBin;
import mekhq.campaign.parts.equipment.MissingEquipmentPart;
import mekhq.campaign.parts.equipment.MissingMASC;
import mekhq.campaign.parts.*;
import mekhq.campaign.parts.equipment.*;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.PersonnelOptions;
import mekhq.campaign.personnel.SkillType;
Expand Down Expand Up @@ -301,7 +252,7 @@ public Campaign parse() throws CampaignXmlParseException, NullEntityException {
} else if (xn.equalsIgnoreCase("location")) {
retVal.setLocation(CurrentLocation.generateInstanceFromXML(wn, retVal));
} else if (xn.equalsIgnoreCase("skillTypes")) {
processSkillTypeNodes(wn);
processSkillTypeNodes(retVal, wn, version);
} else if (xn.equalsIgnoreCase("specialAbilities")) {
processSpecialAbilityNodes(retVal, wn, version);
} else if (xn.equalsIgnoreCase("storyArc")) {
Expand Down
33 changes: 8 additions & 25 deletions MekHQ/src/mekhq/campaign/mission/BotForceRandomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,18 @@
*/
package mekhq.campaign.mission;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.math3.distribution.GammaDistribution;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.Version;
import megamek.client.generator.RandomGenderGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.generator.enums.SkillGeneratorType;
import megamek.client.generator.skillGenerators.AbstractSkillGenerator;
import megamek.client.generator.skillGenerators.TaharqaSkillGenerator;
import megamek.codeUtilities.StringUtility;
import megamek.common.Compute;
import megamek.common.Crew;
import megamek.common.Entity;
import megamek.common.EntityWeightClass;
import megamek.common.MekFileParser;
import megamek.common.MekSummary;
import megamek.common.UnitType;
import megamek.common.*;
import megamek.common.annotations.Nullable;
import megamek.common.enums.Gender;
import megamek.common.enums.SkillLevel;
import megamek.logging.MMLogger;
import mekhq.campaign.Campaign;
import mekhq.campaign.personnel.Bloodname;
import mekhq.campaign.personnel.enums.Phenotype;
Expand All @@ -57,7 +41,6 @@
import mekhq.campaign.universe.UnitGeneratorParameters;
import mekhq.utilities.MHQXMLUtility;
import org.apache.commons.math3.distribution.GammaDistribution;
import org.apache.logging.log4j.LogManager;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

Expand Down Expand Up @@ -501,7 +484,7 @@ public Entity getEntity(int uType, int weightClass, Campaign campaign) {

String[] crewNameArray = rng.generateGivenNameSurnameSplit(gender, faction.isClan(), faction.getShortName());
String crewName = crewNameArray[0];
crewName += !StringUtility.isNullOrBlank(crewNameArray[1]) ? " " + crewNameArray[1] : "";
crewName += !StringUtility.isNullOrBlank(crewNameArray[1]) ? ' ' + crewNameArray[1] : "";

Map<Integer, Map<String, String>> extraData = new HashMap<>();
Map<String, String> innerMap = new HashMap<>();
Expand Down Expand Up @@ -552,7 +535,7 @@ public Entity getEntity(int uType, int weightClass, Campaign campaign) {
if (!phenotype.isNone()) {
String bloodname = Bloodname.randomBloodname(faction.getShortName(), phenotype,
campaign.getGameYear()).getName();
crewName += " " + bloodname;
crewName += ' ' + bloodname;
innerMap.put(Crew.MAP_BLOODNAME, bloodname);
innerMap.put(Crew.MAP_PHENOTYPE, phenotype.name());
}
Expand Down Expand Up @@ -714,7 +697,7 @@ private double calculateMeanWeightClass(List<Unit> playerUnits) {
}

public String getShortDescription() {
String sb = forceMultiplier + " (" + balancingMethod.toString() + ")";
String sb = forceMultiplier + " (" + balancingMethod.toString() + ')';
return sb;
}

Expand All @@ -728,9 +711,9 @@ public String getShortDescription() {
public String getDescription(Campaign campaign) {
StringBuilder sb = new StringBuilder();
sb.append(Factions.getInstance().getFaction(factionCode).getFullName(campaign.getGameYear()));
sb.append(" ");
sb.append(' ');
sb.append(skill.toString());
sb.append(" ");
sb.append(' ');
String typeDesc = UnitType.getTypeDisplayableName(unitType);
if (percentConventional > 0) {
typeDesc = typeDesc + " and Conventional";
Expand All @@ -740,7 +723,7 @@ public String getDescription(Campaign campaign) {
sb.append(forceMultiplier);
sb.append(" multiplier (");
sb.append(balancingMethod.toString());
sb.append(")");
sb.append(')');
return sb.toString();
}

Expand Down
Loading

0 comments on commit f1f7c5a

Please sign in to comment.