From c5a1f5ff52d1f55f984ce05fe686fdd6aa32ce9e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 11 Dec 2024 13:01:04 -0600 Subject: [PATCH] Renamed `Strategic Formations` to `Combat Teams` Replaced all occurrences of `StrategicFormation` with `CombatTeam`. Updated associated methods, variables, and references across multiple classes to align with this new terminology. --- MekHQ/src/mekhq/AtBGameThread.java | 8 +- MekHQ/src/mekhq/campaign/Campaign.java | 118 +++++++++--------- ...trategicFormation.java => CombatTeam.java} | 109 ++++++++-------- MekHQ/src/mekhq/campaign/force/Force.java | 36 +++--- .../mekhq/campaign/io/CampaignXmlParser.java | 26 ++-- .../AbstractContractMarket.java | 2 +- .../mekhq/campaign/mission/AtBContract.java | 2 +- .../campaign/mission/AtBDynamicScenario.java | 10 +- .../mission/AtBDynamicScenarioFactory.java | 2 +- .../mekhq/campaign/mission/AtBScenario.java | 38 +++--- .../mission/CommonObjectiveFactory.java | 6 +- .../mission/atb/AtBScenarioFactory.java | 76 +++++------ .../atb/AtBScenarioModifierApplicator.java | 2 +- .../scenario/BaseAttackBuiltInScenario.java | 6 +- .../scenario/BreakthroughBuiltInScenario.java | 2 +- .../atb/scenario/ChaseBuiltInScenario.java | 4 +- .../scenario/ExtractionBuiltInScenario.java | 2 +- .../scenario/HideAndSeekBuiltInScenario.java | 4 +- .../scenario/HoldTheLineBuiltInScenario.java | 2 +- .../atb/scenario/ProbeBuiltInScenario.java | 2 +- .../scenario/ReconRaidBuiltInScenario.java | 2 +- .../atb/scenario/StandUpBuiltInScenario.java | 2 +- .../personnel/autoAwards/MiscAwards.java | 2 +- .../stratcon/StratconRulesManager.java | 16 +-- MekHQ/src/mekhq/gui/BriefingTab.java | 6 +- MekHQ/src/mekhq/gui/ForceRenderer.java | 8 +- .../mekhq/gui/adapter/TOEMouseAdapter.java | 32 ++--- .../mekhq/gui/panes/CampaignOptionsPane.java | 4 +- .../stratcon/ScenarioWizardLanceRenderer.java | 4 +- .../mekhq/gui/view/AtBScenarioViewPanel.java | 4 +- .../mekhq/gui/view/LanceAssignmentView.java | 48 +++---- 31 files changed, 293 insertions(+), 292 deletions(-) rename MekHQ/src/mekhq/campaign/force/{StrategicFormation.java => CombatTeam.java} (88%) diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index fad80ca322..55842bda57 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -44,7 +44,7 @@ import java.util.*; import java.util.stream.Collectors; -import static mekhq.campaign.force.StrategicFormation.getStandardForceSize; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; /** * Enhanced version of GameThread which imports settings and non-player units @@ -267,8 +267,8 @@ public void run() { // Set scenario type-specific delay deploymentRound = Math.max(entity.getDeployRound(), scenario.getDeploymentDelay() - speed); // Lances deployed in scout roles always deploy units in 6-walking speed turns - if (scenario.getLanceRole().isScouting() && (scenario.getStrategicFormation(campaign) != null) - && (scenario.getStrategicFormation(campaign).getForceId() == scenario.getStrategicFormationId()) + if (scenario.getLanceRole().isScouting() && (scenario.getCombatTeamById(campaign) != null) + && (scenario.getCombatTeamById(campaign).getForceId() == scenario.getCombatTeamId()) && !useDropship) { deploymentRound = Math.max(deploymentRound, 6 - speed); } @@ -336,7 +336,7 @@ public void run() { } deploymentRound = Math.max(entity.getDeployRound(), scenario.getDeploymentDelay() - speed); if (!useDropship && scenario.getLanceRole().isScouting() - && (scenario.getStrategicFormation(campaign).getForceId() == scenario.getStrategicFormationId())) { + && (scenario.getCombatTeamById(campaign).getForceId() == scenario.getCombatTeamId())) { deploymentRound = Math.max(deploymentRound, 6 - speed); } } diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index a610f94fe1..d117109ac0 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -52,8 +52,8 @@ import mekhq.campaign.event.*; import mekhq.campaign.finances.*; import mekhq.campaign.finances.enums.TransactionType; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import mekhq.campaign.icons.StandardForceIcon; import mekhq.campaign.icons.UnitIcon; import mekhq.campaign.log.HistoricalLogEntry; @@ -142,15 +142,15 @@ import java.util.Map.Entry; import java.util.stream.Collectors; -import static mekhq.campaign.force.StrategicFormation.recalculateStrategicFormations; +import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; import static mekhq.campaign.market.contractMarket.ContractAutomation.performAutomatedActivation; +import static mekhq.campaign.mission.AtBContract.pickRandomCamouflage; import static mekhq.campaign.personnel.SkillType.S_ADMIN; 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_BASIC; import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; -import static mekhq.campaign.mission.AtBContract.pickRandomCamouflage; /** * The main campaign class, keeps track of teams and units * @@ -203,7 +203,7 @@ public class Campaign implements ITechManager { // hierarchically structured Force object to define TO&E private Force forces; - private Hashtable strategicFormations; // AtB + private Hashtable combatTeams; // AtB private Faction faction; private int techFactionCode; @@ -318,7 +318,7 @@ public Campaign() { setRankSystemDirect(Ranks.getRankSystemFromCode(Ranks.DEFAULT_SYSTEM_CODE)); forces = new Force(name); forceIds.put(0, forces); - strategicFormations = new Hashtable<>(); + combatTeams = new Hashtable<>(); finances = new Finances(); astechPool = 0; medicPool = 0; @@ -459,45 +459,45 @@ public List getAllForces() { } /** - * Adds a {@link StrategicFormation} to the {@code strategicFormations} {@link Hashtable} using + * Adds a {@link CombatTeam} to the {@code combatTeams} {@link Hashtable} using * {@code forceId} as the key. * - * @param strategicFormation the {@link StrategicFormation} to be added to the {@link Hashtable} + * @param combatTeam the {@link CombatTeam} to be added to the {@link Hashtable} */ - public void addStrategicFormation(StrategicFormation strategicFormation) { - strategicFormations.put(strategicFormation.getForceId(), strategicFormation); + public void addCombatTeam(CombatTeam combatTeam) { + combatTeams.put(combatTeam.getForceId(), combatTeam); } /** - * Removes a {@link StrategicFormation} from the {@code strategicFormations} {@link Hashtable} - * using {@code forceId} as they key. + * Removes a {@link CombatTeam} from the {@code combatTeams} {@link Hashtable} using + * {@code forceId} as the key. * - * @param forceId the key of the {@link StrategicFormation} to be removed from the {@link Hashtable} + * @param forceId the key of the {@link CombatTeam} to be removed from the {@link Hashtable} */ - public void removeStrategicFormation(final int forceId) { - this.strategicFormations.remove(forceId); + public void removeCombatTeam(final int forceId) { + this.combatTeams.remove(forceId); } /** - * Returns the {@link Hashtable} containing all the {@link StrategicFormation} objects after + * Returns the {@link Hashtable} containing all the {@link CombatTeam} objects after * removing the ineligible ones. Although sanitization might not be necessary, it ensures that * there is no need for {@code isEligible()} checks when fetching the {@link Hashtable}. * - * @return the sanitized {@link Hashtable} of {@link StrategicFormation} objects stored in the + * @return the sanitized {@link Hashtable} of {@link CombatTeam} objects stored in the * current campaign. */ - public Hashtable getStrategicFormationsTable() { + public Hashtable getCombatTeamsTable() { // Here we sanitize the list, ensuring ineligible formations have been removed before // returning the hashtable. In theory, this shouldn't be necessary, however, having this // sanitizing step should remove the need for isEligible() checks whenever we fetch the // hashtable. List formationsToSanitize = new ArrayList<>(); - for (StrategicFormation strategicFormation : strategicFormations.values()) { - if (!strategicFormation.isEligible(this)) { - formationsToSanitize.add(strategicFormation.getForceId()); + for (CombatTeam combatTeam : combatTeams.values()) { + if (!combatTeam.isEligible(this)) { + formationsToSanitize.add(combatTeam.getForceId()); try { - Force force = getForce(strategicFormation.getForceId()); - force.setStrategicFormation(false); + Force force = getForce(combatTeam.getForceId()); + force.setCombatTeamStatus(false); } catch (Exception ex) { // We're not too worried if we can't find the associated Force, // as this just means it has been deleted at some point and not removed correctly. @@ -506,27 +506,27 @@ public Hashtable getStrategicFormationsTable() { } for (int id : formationsToSanitize) { - strategicFormations.remove(id); + combatTeams.remove(id); } - return strategicFormations; + return combatTeams; } /** - * Returns an {@link ArrayList} of all {@link StrategicFormation} objects in the - * {@code strategicFormations} {@link Hashtable}. - * Calls the {@code getStrategicFormationsTable()} method to sanitize the {@link Hashtable} + * Returns an {@link ArrayList} of all {@link CombatTeam} objects in the + * {@code combatTeams} {@link Hashtable}. + * Calls the {@code getCombatTeamsTable()} method to sanitize the {@link Hashtable} * before conversion to {@link ArrayList}. * - * @return an {@link ArrayList} of all the {@link StrategicFormation} objects in the - * {@code strategicFormations} {@link Hashtable} + * @return an {@link ArrayList} of all the {@link CombatTeam} objects in the + * {@code combatTeams} {@link Hashtable} */ - public ArrayList getAllStrategicFormations() { - // This call allows us to utilize the self-sanitizing feature of getStrategicFormationsTable(), + public ArrayList getAllCombatTeams() { + // This call allows us to utilize the self-sanitizing feature of getCombatTeamsTable(), // without needing to directly include the code here, too. - strategicFormations = getStrategicFormationsTable(); + combatTeams = getCombatTeamsTable(); - return strategicFormations.values().stream() + return combatTeams.values().stream() .filter(l -> forceIds.containsKey(l.getForceId())) .collect(Collectors.toCollection(ArrayList::new)); } @@ -975,7 +975,7 @@ public void addForce(Force force, Force superForce) { force.updateCommander(this); if (campaignOptions.isUseAtB()) { - recalculateStrategicFormations(this); + recalculateCombatTeams(this); } } @@ -1069,18 +1069,18 @@ public void addUnitToForce(@Nullable Unit u, int id) { } if (campaignOptions.isUseAtB()) { - recalculateStrategicFormations(this); + recalculateCombatTeams(this); } } /** - * Adds force and all its subforces to the AtB lance table + * Adds force and all its subforces to the Combat Teams table */ - private void addAllStrategicFormations(Force force) { - recalculateStrategicFormations(this); + private void addAllCombatTeams(Force force) { + recalculateCombatTeams(this); for (Force subForce : force.getSubForces()) { - addAllStrategicFormations(subForce); + addAllCombatTeams(subForce); } } @@ -3714,7 +3714,7 @@ public int getDeploymentDeficit(AtBContract contract) { int role = -Math.max(1, contract.getRequiredLances() / 2); final AtBLanceRole requiredLanceRole = contract.getContractType().getRequiredLanceRole(); - for (StrategicFormation l : strategicFormations.values()) { + for (CombatTeam l : combatTeams.values()) { if (!l.getRole().isUnassigned() && (l.getMissionId() == contract.getId())) { total++; if (l.getRole() == requiredLanceRole) { @@ -3813,8 +3813,8 @@ && getLocation().getJumpPath().getLastSystem().getId().equals(contract.getSystem // If there is a standard battle set for today, deploy the lance. for (final AtBScenario s : contract.getCurrentAtBScenarios()) { if ((s.getDate() != null) && s.getDate().equals(getLocalDate())) { - int forceId = s.getStrategicFormationId(); - if ((strategicFormations.get(forceId) != null) && !forceIds.get(forceId).isDeployed()) { + int forceId = s.getCombatTeamId(); + if ((combatTeams.get(forceId) != null) && !forceIds.get(forceId).isDeployed()) { // If any unit in the force is under repair, don't deploy the force // Merely removing the unit from deployment would break with user expectation boolean forceUnderRepair = false; @@ -3872,11 +3872,11 @@ private void processNewDayATB() { if (getLocalDate().getDayOfWeek() == DayOfWeek.MONDAY) { processShipSearch(); - // Training Experience - Award to eligible training Strategic Formations on active contracts - getStrategicFormationsTable().values().stream() - .filter(strategicFormation -> strategicFormation.getRole().isTraining() - && (strategicFormation.getContract(this) != null) && strategicFormation.isEligible(this) - && strategicFormation.getContract(this).isActiveOn(getLocalDate(), true)) + // Training Experience - Award to eligible training Combat Teams on active contracts + getCombatTeamsTable().values().stream() + .filter(combatTeam -> combatTeam.getRole().isTraining() + && (combatTeam.getContract(this) != null) && combatTeam.isEligible(this) + && combatTeam.getContract(this).isActiveOn(getLocalDate(), true)) .forEach(this::awardTrainingXP); } @@ -4404,7 +4404,7 @@ public void processNewDayUnits() { private void processNewDayForces() { // update formation levels Force.populateFormationLevelsFromOrigin(this); - recalculateStrategicFormations(this); + recalculateCombatTeams(this); // Update the force icons based on the end-of-day unit status if desired if (MekHQ.getMHQOptions().getNewDayForceIconOperationalStatus()) { @@ -4981,9 +4981,9 @@ public void removePerson(final @Nullable Person person, final boolean log) { * commanding officer and * the minimum experience level of the unit's members. * - * @param l The {@link StrategicFormation} to calculate XP to award for training. + * @param l The {@link CombatTeam} to calculate XP to award for training. */ - private void awardTrainingXP(final StrategicFormation l) { + private void awardTrainingXP(final CombatTeam l) { for (UUID trainerId : forceIds.get(l.getForceId()).getAllUnits(true)) { Unit trainerUnit = getHangar().getUnit(trainerId); @@ -5120,7 +5120,7 @@ public void removeForce(Force force) { } if (campaignOptions.isUseAtB()) { - recalculateStrategicFormations(this); + recalculateCombatTeams(this); } } @@ -5154,7 +5154,7 @@ public void removeUnitFromForce(Unit u) { } if (campaignOptions.isUseAtB() && force.getUnits().isEmpty()) { - strategicFormations.remove(force.getId()); + combatTeams.remove(force.getId()); } } } @@ -5730,14 +5730,14 @@ public void writeToXML(final PrintWriter pw) { // CAW: implicit DEPENDS-ON to the node, do not move this above it contractMarket.writeToXML(pw, indent); - if (!strategicFormations.isEmpty()) { - MHQXMLUtility.writeSimpleXMLOpenTag(pw, indent++, "strategicFormations"); - for (StrategicFormation l : strategicFormations.values()) { + if (!combatTeams.isEmpty()) { + MHQXMLUtility.writeSimpleXMLOpenTag(pw, indent++, "combatTeams"); + for (CombatTeam l : combatTeams.values()) { if (forceIds.containsKey(l.getForceId())) { l.writeToXML(pw, indent); } } - MHQXMLUtility.writeSimpleXMLCloseTag(pw, --indent, "strategicFormations"); + MHQXMLUtility.writeSimpleXMLCloseTag(pw, --indent, "combatTeams"); } MHQXMLUtility.writeSimpleXMLTag(pw, indent, "shipSearchStart", getShipSearchStart()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "shipSearchType", shipSearchType); @@ -6763,8 +6763,8 @@ public TargetRoll getTargetForAcquisition(final IAcquisitionWork acquisition, } public @Nullable AtBContract getAttachedAtBContract(Unit unit) { - if (null != unit && null != strategicFormations.get(unit.getForceId())) { - return strategicFormations.get(unit.getForceId()).getContract(this); + if (null != unit && null != combatTeams.get(unit.getForceId())) { + return combatTeams.get(unit.getForceId()).getContract(this); } return null; } @@ -8410,7 +8410,7 @@ public void initAtB(boolean newCampaign) { } } - addAllStrategicFormations(this.forces); + addAllCombatTeams(this.forces); // Determine whether or not there is an active contract setHasActiveContract(); diff --git a/MekHQ/src/mekhq/campaign/force/StrategicFormation.java b/MekHQ/src/mekhq/campaign/force/CombatTeam.java similarity index 88% rename from MekHQ/src/mekhq/campaign/force/StrategicFormation.java rename to MekHQ/src/mekhq/campaign/force/CombatTeam.java index b0212b0e0a..d1be1f0ed1 100644 --- a/MekHQ/src/mekhq/campaign/force/StrategicFormation.java +++ b/MekHQ/src/mekhq/campaign/force/CombatTeam.java @@ -50,20 +50,20 @@ import static megamek.common.Entity.ETYPE_PROTOMEK; import static megamek.common.Entity.ETYPE_TANK; import static megamek.common.EntityWeightClass.WEIGHT_ULTRA_LIGHT; -import static mekhq.campaign.force.Force.STRATEGIC_FORMATION_OVERRIDE_NONE; -import static mekhq.campaign.force.Force.STRATEGIC_FORMATION_OVERRIDE_TRUE; +import static mekhq.campaign.force.Force.COMBAT_TEAM_OVERRIDE_NONE; +import static mekhq.campaign.force.Force.COMBAT_TEAM_OVERRIDE_TRUE; import static mekhq.campaign.force.FormationLevel.LANCE; /** * Used by Against the Bot & StratCon to track additional information about each force * on the TO&E that has at least one unit assigned. Extra info includes whether - * the force counts as a Strategic Formation eligible for assignment to a scenario role + * the force counts as a Combat Team eligible for assignment to a scenario role * and what the assignment is on which contract. * * @author Neoancient */ -public class StrategicFormation { - private static final MMLogger logger = MMLogger.create(StrategicFormation.class); +public class CombatTeam { + private static final MMLogger logger = MMLogger.create(CombatTeam.class); public static final int LANCE_SIZE = 4; public static final int STAR_SIZE = 5; @@ -132,9 +132,9 @@ public static int getStandardForceSize(Faction faction, int formationLevelDepth) /** * Default constructor */ - public StrategicFormation() {} + public CombatTeam() {} - public StrategicFormation(int forceId, Campaign campaign) { + public CombatTeam(int forceId, Campaign campaign) { this.forceId = forceId; role = AtBLanceRole.UNASSIGNED; missionId = -1; @@ -308,7 +308,7 @@ public boolean isEligible(Campaign campaign) { } if (!force.isCombatForce()) { - force.setStrategicFormation(false); + force.setCombatTeamStatus(false); return false; } @@ -319,14 +319,14 @@ public boolean isEligible(Campaign campaign) { int size = getSize(campaign); if (size < getStandardForceSize(campaign.getFaction()) - 1 || size > getStandardForceSize(campaign.getFaction()) + 2) { - force.setStrategicFormation(false); + force.setCombatTeamStatus(false); return false; } } if (campaign.getCampaignOptions().isLimitLanceWeight() && getWeightClass(campaign) > EntityWeightClass.WEIGHT_ASSAULT) { - force.setStrategicFormation(false); + force.setCombatTeamStatus(false); return false; } @@ -338,7 +338,7 @@ size > getStandardForceSize(campaign.getFaction()) + 2) { if (entity != null) { if (entity.getUnitType() >= UnitType.JUMPSHIP) { - force.setStrategicFormation(false); + force.setCombatTeamStatus(false); return false; } if ((entity.getEntityType() & ETYPE_GROUND) != 0) { @@ -348,16 +348,16 @@ size > getStandardForceSize(campaign.getFaction()) + 2) { } } - int isOverridden = force.getOverrideStrategicFormation(); - if (isOverridden != STRATEGIC_FORMATION_OVERRIDE_NONE) { - boolean overrideState = isOverridden == STRATEGIC_FORMATION_OVERRIDE_TRUE; - force.setStrategicFormation(overrideState); + int isOverridden = force.getOverrideCombatTeam(); + if (isOverridden != COMBAT_TEAM_OVERRIDE_NONE) { + boolean overrideState = isOverridden == COMBAT_TEAM_OVERRIDE_TRUE; + force.setCombatTeamStatus(overrideState); List associatedForces = force.getAllParents(); associatedForces.addAll(force.getAllSubForces()); for (Force associatedForce : associatedForces) { - associatedForce.setStrategicFormation(false); + associatedForce.setCombatTeamStatus(false); } return overrideState; @@ -367,8 +367,8 @@ size > getStandardForceSize(campaign.getFaction()) + 2) { List childForces = force.getAllSubForces(); for (Force childForce : childForces) { - if (childForce.isStrategicFormation()) { - force.setStrategicFormation(false); + if (childForce.isCombatTeam()) { + force.setCombatTeamStatus(false); return false; } } @@ -376,14 +376,14 @@ size > getStandardForceSize(campaign.getFaction()) + 2) { List parentForces = force.getAllParents(); for (Force parentForce : parentForces) { - if (parentForce.isStrategicFormation()) { - force.setStrategicFormation(false); + if (parentForce.isCombatTeam()) { + force.setCombatTeamStatus(false); return false; } } } - force.setStrategicFormation(hasGround); + force.setCombatTeamStatus(hasGround); return hasGround; } @@ -592,13 +592,13 @@ public void writeToXML(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLCloseTag(pw, --indent, "lance"); } - public static StrategicFormation generateInstanceFromXML(Node wn) { - StrategicFormation retVal = null; + public static CombatTeam generateInstanceFromXML(Node wn) { + CombatTeam retVal = null; NamedNodeMap attrs = wn.getAttributes(); Node classNameNode = attrs.getNamedItem("type"); String className = classNameNode.getTextContent(); try { - retVal = (StrategicFormation) Class.forName(className).newInstance(); + retVal = (CombatTeam) Class.forName(className).newInstance(); NodeList nl = wn.getChildNodes(); for (int x = 0; x < nl.getLength(); x++) { @@ -662,49 +662,49 @@ public static double calculateTotalWeight(Campaign campaign, int forceId) { } /** - * This static method updates the strategic formations across the campaign. - * It starts at the top level force, and calculates the strategic formations for each sub-force. - * It keeps only the eligible strategic formations and imports them into the campaign. + * This static method updates the combat teams across the campaign. + * It starts at the top level force, and calculates the combat teams for each sub-force. + * It keeps only the eligible combat teams and imports them into the campaign. * After every formation is processed, an 'OrganizationChangedEvent' is triggered by that force. * * @param campaign the current campaign. */ - public static void recalculateStrategicFormations(Campaign campaign) { - Hashtable strategicFormations = campaign.getStrategicFormationsTable(); - StrategicFormation strategicFormation = strategicFormations.get(0); // This is the origin node + public static void recalculateCombatTeams(Campaign campaign) { + Hashtable combatTeamsTable = campaign.getCombatTeamsTable(); + CombatTeam combatTeam = combatTeamsTable.get(0); // This is the origin node Force force = campaign.getForce(0); // Does the force already exist in our hashtable? If so, update it accordingly - if (strategicFormation != null) { - boolean isEligible = strategicFormation.isEligible(campaign); + if (combatTeam != null) { + boolean isEligible = combatTeam.isEligible(campaign); if (!isEligible) { - campaign.removeStrategicFormation(0); + campaign.removeCombatTeam(0); } - force.setStrategicFormation(isEligible); + force.setCombatTeamStatus(isEligible); // Otherwise, create a new formation and then add it to the table, if appropriate } else { - strategicFormation = new StrategicFormation(0, campaign); - boolean isEligible = strategicFormation.isEligible(campaign); + combatTeam = new CombatTeam(0, campaign); + boolean isEligible = combatTeam.isEligible(campaign); if (isEligible) { - campaign.addStrategicFormation(strategicFormation); + campaign.addCombatTeam(combatTeam); } - force.setStrategicFormation(isEligible); + force.setCombatTeamStatus(isEligible); } // Update the TO&E and then begin recursively walking it MekHQ.triggerEvent(new OrganizationChangedEvent(force)); - recalculateSubForceStrategicStatus(campaign, campaign.getStrategicFormationsTable(), force); + recalculateSubForceStrategicStatus(campaign, campaign.getCombatTeamsTable(), force); } /** - * This method is used to update the strategic formations for the campaign working downwards + * This method is used to update the combat teams for the campaign working downwards * from a specified node, through all of its sub-forces. - * It creates a new {@link StrategicFormation} for each sub-force and checks its eligibility. - * Eligible formations are imported into the campaign, and the strategic formation status of + * It creates a new {@link CombatTeam} for each sub-force and checks its eligibility. + * Eligible formations are imported into the campaign, and the combat team status of * the respective force is set to {@code true}. * After every force is processed, an 'OrganizationChangedEvent' is triggered. * This function runs recursively on each sub-force, effectively traversing the complete TO&E. @@ -713,37 +713,38 @@ public static void recalculateStrategicFormations(Campaign campaign) { * @param workingNode the {@link Force} node from which the method starts working down through * all its sub-forces. */ - private static void recalculateSubForceStrategicStatus(Campaign campaign, Hashtable strategicFormations, Force workingNode) { + private static void recalculateSubForceStrategicStatus(Campaign campaign, + Hashtable combatTeamsTable, + Force workingNode) { for (Force force : workingNode.getSubForces()) { int forceId = force.getId(); - StrategicFormation strategicFormation = strategicFormations.get(forceId); + CombatTeam combatTeam = combatTeamsTable.get(forceId); // Does the force already exist in our hashtable? If so, update it accordingly - if (strategicFormation != null) { - boolean isEligible = strategicFormation.isEligible(campaign); + if (combatTeam != null) { + boolean isEligible = combatTeam.isEligible(campaign); if (!isEligible) { - campaign.removeStrategicFormation(forceId); + campaign.removeCombatTeam(forceId); } - force.setStrategicFormation(isEligible); + force.setCombatTeamStatus(isEligible); // Otherwise, create a new formation and then add it to the table, if appropriate } else { - strategicFormation = new StrategicFormation(forceId, campaign); - boolean isEligible = strategicFormation.isEligible(campaign); + combatTeam = new CombatTeam(forceId, campaign); + boolean isEligible = combatTeam.isEligible(campaign); if (isEligible) { - campaign.addStrategicFormation(strategicFormation); + campaign.addCombatTeam(combatTeam); } - force.setStrategicFormation(isEligible); + force.setCombatTeamStatus(isEligible); } // Update the TO&E and then continue recursively walking it MekHQ.triggerEvent(new OrganizationChangedEvent(force)); - recalculateSubForceStrategicStatus(campaign, campaign.getStrategicFormationsTable(), force); + recalculateSubForceStrategicStatus(campaign, campaign.getCombatTeamsTable(), force); } } } diff --git a/MekHQ/src/mekhq/campaign/force/Force.java b/MekHQ/src/mekhq/campaign/force/Force.java index 85ea4d1656..c7b9994b9f 100644 --- a/MekHQ/src/mekhq/campaign/force/Force.java +++ b/MekHQ/src/mekhq/campaign/force/Force.java @@ -68,17 +68,17 @@ public class Force { // pathway to force icon public static final int FORCE_NONE = -1; - public static final int STRATEGIC_FORMATION_OVERRIDE_NONE = -1; - public static final int STRATEGIC_FORMATION_OVERRIDE_FALSE = 0; - public static final int STRATEGIC_FORMATION_OVERRIDE_TRUE = 1; + public static final int COMBAT_TEAM_OVERRIDE_NONE = -1; + public static final int COMBAT_TEAM_OVERRIDE_FALSE = 0; + public static final int COMBAT_TEAM_OVERRIDE_TRUE = 1; private String name; private StandardForceIcon forceIcon; private Camouflage camouflage; private String desc; private boolean combatForce; - private boolean isStrategicFormation; - private int overrideStrategicFormation; + private boolean isCombatTeam; + private int overrideCombatTeam; private FormationLevel formationLevel; private FormationLevel overrideFormationLevel; private Force parentForce; @@ -100,8 +100,8 @@ public Force(String name) { setCamouflage(new Camouflage()); setDescription(""); this.combatForce = true; - this.isStrategicFormation = false; - this.overrideStrategicFormation = STRATEGIC_FORMATION_OVERRIDE_NONE; + this.isCombatTeam = false; + this.overrideCombatTeam = COMBAT_TEAM_OVERRIDE_NONE; this.formationLevel = FormationLevel.NONE; this.overrideFormationLevel = FormationLevel.NONE; this.parentForce = null; @@ -171,20 +171,20 @@ public void setCombatForce(boolean combatForce, boolean setForSubForces) { } } - public boolean isStrategicFormation() { - return isStrategicFormation; + public boolean isCombatTeam() { + return isCombatTeam; } - public void setStrategicFormation(final boolean isStrategicFormation) { - this.isStrategicFormation = isStrategicFormation; + public void setCombatTeamStatus(final boolean isCombatTeam) { + this.isCombatTeam = isCombatTeam; } - public int getOverrideStrategicFormation() { - return overrideStrategicFormation; + public int getOverrideCombatTeam() { + return overrideCombatTeam; } - public void setOverrideStrategicFormation(final int overrideStrategicFormation) { - this.overrideStrategicFormation = overrideStrategicFormation; + public void setOverrideCombatTeam(final int overrideCombatTeam) { + this.overrideCombatTeam = overrideCombatTeam; } public FormationLevel getFormationLevel() { @@ -685,7 +685,7 @@ public void writeToXML(PrintWriter pw1, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "desc", desc); } MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "combatForce", combatForce); - MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "overrideStrategicFormation", overrideStrategicFormation); + MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "overrideCombatTeam", overrideCombatTeam); MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "formationLevel", formationLevel.toString()); MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "populateOriginNode", overrideFormationLevel.toString()); MHQXMLUtility.writeSimpleXMLTag(pw1, indent, "scenarioId", scenarioId); @@ -733,8 +733,8 @@ public void writeToXML(PrintWriter pw1, int indent) { retVal.setDescription(wn2.getTextContent().trim()); } else if (wn2.getNodeName().equalsIgnoreCase("combatForce")) { retVal.setCombatForce(Boolean.parseBoolean(wn2.getTextContent().trim()), false); - } else if (wn2.getNodeName().equalsIgnoreCase("overrideStrategicFormation")) { - retVal.setOverrideStrategicFormation(Integer.parseInt(wn2.getTextContent().trim())); + } else if (wn2.getNodeName().equalsIgnoreCase("overrideCombatTeam")) { + retVal.setOverrideCombatTeam(Integer.parseInt(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("formationLevel")) { retVal.setFormationLevel(FormationLevel.parseFromString(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("populateOriginNode")) { diff --git a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java index fb573fd1cc..01cbc64343 100644 --- a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java +++ b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java @@ -35,8 +35,8 @@ import mekhq.campaign.*; import mekhq.campaign.againstTheBot.AtBConfiguration; import mekhq.campaign.finances.Finances; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import mekhq.campaign.icons.UnitIcon; import mekhq.campaign.market.PersonnelMarket; import mekhq.campaign.market.ShoppingList; @@ -78,7 +78,7 @@ import java.util.*; import java.util.Map.Entry; -import static mekhq.campaign.force.StrategicFormation.recalculateStrategicFormations; +import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; import static org.apache.commons.lang3.ObjectUtils.firstNonNull; @@ -284,8 +284,8 @@ public Campaign parse() throws CampaignXmlParseException, NullEntityException { retVal.setUnitMarket(retVal.getCampaignOptions().getUnitMarketMethod().getUnitMarket()); retVal.getUnitMarket().fillFromXML(wn, retVal, version); foundUnitMarket = true; - } else if (xn.equalsIgnoreCase("lances") || xn.equalsIgnoreCase("strategicFormations")) { - processStrategicFormationNodes(retVal, wn); + } else if (xn.equalsIgnoreCase("lances") || xn.equalsIgnoreCase("combatTeams")) { + processCombatTeamNodes(retVal, wn); } else if (xn.equalsIgnoreCase("retirementDefectionTracker")) { retVal.setRetirementDefectionTracker( RetirementDefectionTracker.generateInstanceFromXML(wn, retVal)); @@ -355,10 +355,10 @@ public Campaign parse() throws CampaignXmlParseException, NullEntityException { // determine if we've missed any lances and add those back into the campaign if (options.isUseAtB()) { - Hashtable lances = retVal.getStrategicFormationsTable(); + Hashtable lances = retVal.getCombatTeamsTable(); for (Force f : retVal.getAllForces()) { if (!f.getUnits().isEmpty() && (null == lances.get(f.getId()))) { - lances.put(f.getId(), new StrategicFormation(f.getId(), retVal)); + lances.put(f.getId(), new CombatTeam(f.getId(), retVal)); logger.warn(String.format("Added missing Lance %s to AtB list", f.getName())); } } @@ -773,7 +773,7 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version) retVal.setNewReports(newReports); } - private static void processStrategicFormationNodes(Campaign campaign, Node workingNode) { + private static void processCombatTeamNodes(Campaign campaign, Node workingNode) { NodeList workingNodes = workingNode.getChildNodes(); // Okay, let's iterate through the children, eh? @@ -786,17 +786,17 @@ private static void processStrategicFormationNodes(Campaign campaign, Node worki } if (!wn2.getNodeName().equalsIgnoreCase("lance") - && !wn2.getNodeName().equalsIgnoreCase("strategicFormations")) { + && !wn2.getNodeName().equalsIgnoreCase("combatTeam")) { // Error condition of sorts! // Errr, what should we do here? - logger.error("Unknown node type not loaded in strategicFormations nodes: " + wn2.getNodeName()); + logger.error("Unknown node type not loaded in combatTeam nodes: " + wn2.getNodeName()); continue; } - StrategicFormation strategicFormation = StrategicFormation.generateInstanceFromXML(wn2); + CombatTeam combatTeam = CombatTeam.generateInstanceFromXML(wn2); - if (strategicFormation != null) { - campaign.addStrategicFormation(strategicFormation); + if (combatTeam != null) { + campaign.addCombatTeam(combatTeam); } } } @@ -857,7 +857,7 @@ private static void processForces(Campaign retVal, Node wn, Version version) { } } - recalculateStrategicFormations(retVal); + recalculateCombatTeams(retVal); logger.info("Load of Force Organization complete!"); } diff --git a/MekHQ/src/mekhq/campaign/market/contractMarket/AbstractContractMarket.java b/MekHQ/src/mekhq/campaign/market/contractMarket/AbstractContractMarket.java index b106407860..4595810102 100644 --- a/MekHQ/src/mekhq/campaign/market/contractMarket/AbstractContractMarket.java +++ b/MekHQ/src/mekhq/campaign/market/contractMarket/AbstractContractMarket.java @@ -25,7 +25,7 @@ import static java.lang.Math.max; import static java.lang.Math.round; import static megamek.common.Compute.d6; -import static mekhq.campaign.force.StrategicFormation.getStandardForceSize; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; import static mekhq.campaign.mission.AtBContract.getEffectiveNumUnits; /** diff --git a/MekHQ/src/mekhq/campaign/mission/AtBContract.java b/MekHQ/src/mekhq/campaign/mission/AtBContract.java index 6bf29b5b2b..d7da8933b8 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBContract.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBContract.java @@ -85,9 +85,9 @@ import static megamek.common.enums.SkillLevel.REGULAR; import static megamek.common.enums.SkillLevel.parseFromInteger; import static megamek.common.enums.SkillLevel.parseFromString; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; import static mekhq.campaign.force.FormationLevel.BATTALION; import static mekhq.campaign.force.FormationLevel.COMPANY; -import static mekhq.campaign.force.StrategicFormation.getStandardForceSize; import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getEntity; import static mekhq.campaign.mission.BotForceRandomizer.UNIT_WEIGHT_UNSPECIFIED; import static mekhq.campaign.rating.IUnitRating.*; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java index 32be95056e..19f71e8557 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java @@ -24,8 +24,8 @@ import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; import mekhq.campaign.Campaign; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment; import mekhq.campaign.mission.ScenarioForceTemplate.ForceGenerationMethod; import mekhq.campaign.mission.atb.AtBScenarioModifier; @@ -393,11 +393,11 @@ public Person getLanceCommander(Campaign campaign) { return null; // if we don't have forces, just a bunch of units, then get the highest-ranked? } - StrategicFormation strategicFormation = campaign.getStrategicFormationsTable().get(getForceIDs().get(0)); + CombatTeam combatTeam = campaign.getCombatTeamsTable().get(getForceIDs().get(0)); - if (strategicFormation != null) { - strategicFormation.refreshCommander(campaign); - return strategicFormation.getCommander(campaign); + if (combatTeam != null) { + combatTeam.refreshCommander(campaign); + return combatTeam.getCommander(campaign); } else { return null; } diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 20f56264b9..f8c723e8ab 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -71,7 +71,7 @@ import static megamek.common.Compute.randomInt; import static megamek.common.UnitType.*; import static megamek.common.planetaryconditions.Wind.TORNADO_F4; -import static mekhq.campaign.force.StrategicFormation.getStandardForceSize; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; import static mekhq.campaign.mission.Scenario.T_GROUND; import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_AERO_MIX; import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_CIVILIANS; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 25d0070771..6ed631f9f4 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -40,8 +40,8 @@ import mekhq.campaign.Campaign; import mekhq.campaign.againstTheBot.AtBConfiguration; import mekhq.campaign.againstTheBot.AtBStaticWeightGenerator; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import mekhq.campaign.mission.ObjectiveEffect.ObjectiveEffectType; import mekhq.campaign.mission.ScenarioObjective.ObjectiveCriterion; import mekhq.campaign.mission.atb.IAtBScenario; @@ -143,7 +143,7 @@ public abstract class AtBScenario extends Scenario implements IAtBScenario { public static final int NO_LANCE = -1; private boolean attacker; - private int strategicFormationId; // -1 if scenario is not generated for a specific lance (special scenario, big + private int combatTeamId; // -1 if scenario is not generated for a specific lance (special scenario, big // battle) private AtBLanceRole lanceRole; /* * set when scenario is created in case it is changed for the next week before @@ -207,7 +207,7 @@ public abstract class AtBScenario extends Scenario implements IAtBScenario { public AtBScenario() { super(); - strategicFormationId = -1; + combatTeamId = -1; lanceRole = AtBLanceRole.UNASSIGNED; alliesPlayer = new ArrayList<>(); alliesPlayerStub = new ArrayList<>(); @@ -224,7 +224,7 @@ public AtBScenario() { SB = StratconBiomeManifest.getInstance(); } - public void initialize(Campaign c, StrategicFormation lance, boolean attacker, LocalDate date) { + public void initialize(Campaign c, CombatTeam lance, boolean attacker, LocalDate date) { setAttacker(attacker); alliesPlayer = new ArrayList<>(); @@ -236,10 +236,10 @@ public void initialize(Campaign c, StrategicFormation lance, boolean attacker, L entityIds = new HashMap<>(); if (null == lance) { - strategicFormationId = -1; + combatTeamId = -1; lanceRole = AtBLanceRole.UNASSIGNED; } else { - this.strategicFormationId = lance.getForceId(); + this.combatTeamId = lance.getForceId(); lanceRole = lance.getRole(); setMissionId(lance.getMissionId()); @@ -326,10 +326,10 @@ private void initBattle(Campaign campaign) { lanceCount = 2; } - if (null != getStrategicFormation(campaign)) { - getStrategicFormation(campaign).refreshCommander(campaign); - if (null != getStrategicFormation(campaign).getCommander(campaign).getSkill(SkillType.S_TACTICS)) { - rerollsRemaining = getStrategicFormation(campaign).getCommander(campaign).getSkill(SkillType.S_TACTICS).getLevel(); + if (null != getCombatTeamById(campaign)) { + getCombatTeamById(campaign).refreshCommander(campaign); + if (null != getCombatTeamById(campaign).getCommander(campaign).getSkill(SkillType.S_TACTICS)) { + rerollsRemaining = getCombatTeamById(campaign).getCommander(campaign).getSkill(SkillType.S_TACTICS).getLevel(); } } } @@ -888,7 +888,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(getAllyBotForce(getContract(campaign), getStartingPos(), playerHome, allyEntities), campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), campaign); + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), campaign); addBotForce(getEnemyBotForce(getContract(campaign), enemyHome, enemyHome, enemyEntities), campaign); } @@ -1640,7 +1640,7 @@ protected void setObjectives(Campaign c, AtBContract contract) { @Override protected void writeToXMLEnd(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "attacker", isAttacker()); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lanceForceId", strategicFormationId); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lanceForceId", combatTeamId); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lanceRole", lanceRole.name()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "deploymentDelay", deploymentDelay); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "lanceCount", lanceCount); @@ -1734,7 +1734,7 @@ protected void loadFieldsFromXmlNode(final Node wn, final Version version, final if (wn2.getNodeName().equalsIgnoreCase("attacker")) { setAttacker(Boolean.parseBoolean(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("lanceForceId")) { - strategicFormationId = Integer.parseInt(wn2.getTextContent()); + combatTeamId = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("lanceRole")) { lanceRole = AtBLanceRole.parseFromString(wn2.getTextContent().trim()); } else if (wn2.getNodeName().equalsIgnoreCase("deploymentDelay")) { @@ -1962,20 +1962,20 @@ public List filterUntransportedUnits(List entities) { return retVal; } - public int getStrategicFormationId() { - return strategicFormationId; + public int getCombatTeamId() { + return combatTeamId; } public AtBLanceRole getLanceRole() { return lanceRole; } - public StrategicFormation getStrategicFormation(Campaign campaign) { - return campaign.getStrategicFormationsTable().get(strategicFormationId); + public CombatTeam getCombatTeamById(Campaign campaign) { + return campaign.getCombatTeamsTable().get(combatTeamId); } - public void setLance(StrategicFormation strategicFormation) { - strategicFormationId = strategicFormation.getForceId(); + public void setCombatTeam(CombatTeam combatTeam) { + combatTeamId = combatTeam.getForceId(); } /** diff --git a/MekHQ/src/mekhq/campaign/mission/CommonObjectiveFactory.java b/MekHQ/src/mekhq/campaign/mission/CommonObjectiveFactory.java index dea23e1026..73b95cf0d3 100644 --- a/MekHQ/src/mekhq/campaign/mission/CommonObjectiveFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/CommonObjectiveFactory.java @@ -31,7 +31,7 @@ import java.util.ResourceBundle; import java.util.UUID; -import static mekhq.campaign.force.StrategicFormation.getStandardForceSize; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; /** * This class contains code for the creation of some common objectives for an AtB scenario @@ -230,8 +230,8 @@ private static void addAssignedPlayerUnitsToObjective(AtBScenario scenario, Camp // some scenarios have a lance assigned // some scenarios have individual units assigned - if (scenario.getStrategicFormationId() != AtBScenario.NO_LANCE) { - objective.addForce(campaign.getForce(scenario.getStrategicFormationId()).getName()); + if (scenario.getCombatTeamId() != AtBScenario.NO_LANCE) { + objective.addForce(campaign.getForce(scenario.getCombatTeamId()).getName()); } else { int unitCount = 0; diff --git a/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioFactory.java index 4650763d7e..5004d2a786 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioFactory.java @@ -21,7 +21,7 @@ import megamek.codeUtilities.ObjectUtility; import megamek.logging.MMLogger; import mekhq.campaign.Campaign; -import mekhq.campaign.force.StrategicFormation; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.AtBScenario; import mekhq.campaign.mission.atb.scenario.*; @@ -67,7 +67,7 @@ public static List> getScenarios(int type) { return scenarioMap.get(type); } - public static AtBScenario createScenario(Campaign c, StrategicFormation lance, int type, boolean attacker, LocalDate date) { + public static AtBScenario createScenario(Campaign c, CombatTeam lance, int type, boolean attacker, LocalDate date) { List> classList = getScenarios(type); Class selectedClass; @@ -126,7 +126,7 @@ public static void createScenariosForNewWeek(Campaign campaign) { } // If we have an active contract, then we can progress with generation - Hashtable strategicFormations = campaign.getStrategicFormationsTable(); + Hashtable combatTeamsTable = campaign.getCombatTeamsTable(); List sList; List assignedLances = new ArrayList<>(); @@ -151,8 +151,8 @@ public static void createScenariosForNewWeek(Campaign campaign) { // the generation rules are followed for all active scenarios not just new // scenarios for (final AtBScenario scenario : contract.getCurrentAtBScenarios()) { - // Add any currently assigned strategicFormations to the assignedLances - assignedLances.add(scenario.getStrategicFormationId()); + // Add any currently assigned combatTeamsTable to the assignedLances + assignedLances.add(scenario.getCombatTeamId()); // Remove any active scenarios from the contract, and add them to the current // scenarios list instead @@ -174,14 +174,14 @@ public static void createScenariosForNewWeek(Campaign campaign) { // endregion Current Scenarios // region Generate Scenarios - // Generate scenarios for strategicFormations based on their current situation + // Generate scenarios for combatTeamsTable based on their current situation if (!hasBaseAttackAttacker) { - for (StrategicFormation strategicFormation : strategicFormations.values()) { - // Don't generate scenarios for any strategicFormations already assigned, those assigned to a - // different contract, those not assigned to a contract, or for illegible strategicFormations - if (assignedLances.contains(strategicFormation.getForceId()) || (strategicFormation.getContract(campaign) == null) - || !strategicFormation.isEligible(campaign) || (strategicFormation.getMissionId() != contract.getId()) - || !strategicFormation.getContract(campaign).isActiveOn(campaign.getLocalDate(), true)) { + for (CombatTeam combatTeam : combatTeamsTable.values()) { + // Don't generate scenarios for any combatTeamsTable already assigned, those assigned to a + // different contract, those not assigned to a contract, or for illegible combatTeamsTable + if (assignedLances.contains(combatTeam.getForceId()) || (combatTeam.getContract(campaign) == null) + || !combatTeam.isEligible(campaign) || (combatTeam.getMissionId() != contract.getId()) + || !combatTeam.getContract(campaign).isActiveOn(campaign.getLocalDate(), true)) { continue; } @@ -191,13 +191,13 @@ public static void createScenariosForNewWeek(Campaign campaign) { continue; } - // Attempt to generate a scenario for the strategicFormation - AtBScenario scenario = strategicFormation.checkForBattle(campaign); + // Attempt to generate a scenario for the combatTeam + AtBScenario scenario = combatTeam.checkForBattle(campaign); // If one is generated, then add it to the scenario list if (scenario != null) { sList.add(scenario); - assignedLances.add(strategicFormation.getForceId()); + assignedLances.add(combatTeam.getForceId()); // We care if the scenario is a Base Attack, as one must be generated if the // current contract's morale is Unbreakable @@ -226,39 +226,39 @@ public static void createScenariosForNewWeek(Campaign campaign) { * first to those assigned to the same contract, * then to those assigned to defense roles */ - List lList = new ArrayList<>(); - for (StrategicFormation strategicFormation : strategicFormations.values()) { - if ((strategicFormation.getMissionId() == contract.getId()) - && strategicFormation.getRole().isDefence() && strategicFormation.isEligible(campaign)) { - lList.add(strategicFormation); + List lList = new ArrayList<>(); + for (CombatTeam combatTeam : combatTeamsTable.values()) { + if ((combatTeam.getMissionId() == contract.getId()) + && combatTeam.getRole().isDefence() && combatTeam.isEligible(campaign)) { + lList.add(combatTeam); } } if (lList.isEmpty()) { - for (StrategicFormation strategicFormation : strategicFormations.values()) { - if ((strategicFormation.getMissionId() == contract.getId()) && strategicFormation.isEligible(campaign)) { - lList.add(strategicFormation); + for (CombatTeam combatTeam : combatTeamsTable.values()) { + if ((combatTeam.getMissionId() == contract.getId()) && combatTeam.isEligible(campaign)) { + lList.add(combatTeam); } } } if (lList.isEmpty()) { - for (StrategicFormation strategicFormation : strategicFormations.values()) { - if (strategicFormation.isEligible(campaign)) { - lList.add(strategicFormation); + for (CombatTeam combatTeam : combatTeamsTable.values()) { + if (combatTeam.isEligible(campaign)) { + lList.add(combatTeam); } } } if (!lList.isEmpty()) { - StrategicFormation strategicFormation = ObjectUtility.getRandomItem(lList); - AtBScenario atbScenario = AtBScenarioFactory.createScenario(campaign, strategicFormation, - AtBScenario.BASEATTACK, false, StrategicFormation.getBattleDate(campaign.getLocalDate())); + CombatTeam combatTeam = ObjectUtility.getRandomItem(lList); + AtBScenario atbScenario = AtBScenarioFactory.createScenario(campaign, combatTeam, + AtBScenario.BASEATTACK, false, CombatTeam.getBattleDate(campaign.getLocalDate())); if (atbScenario != null) { - if ((strategicFormation.getMissionId() == atbScenario.getMissionId()) - || (strategicFormation.getMissionId() == StrategicFormation.NO_MISSION)) { + if ((combatTeam.getMissionId() == atbScenario.getMissionId()) + || (combatTeam.getMissionId() == CombatTeam.NO_MISSION)) { for (int i = 0; i < sList.size(); i++) { - if (sList.get(i).getStrategicFormationId() == strategicFormation.getForceId()) { + if (sList.get(i).getCombatTeamId() == combatTeam.getForceId()) { if (dontGenerateForces.contains(atbScenario.getId())) { dontGenerateForces.remove(atbScenario.getId()); } @@ -267,23 +267,23 @@ public static void createScenariosForNewWeek(Campaign campaign) { } } } else { - // edge case: strategicFormation assigned to another mission gets assigned the scenario, + // edge case: combatTeam assigned to another mission gets assigned the scenario, // we need to remove any scenario they are assigned to already - campaign.getMission(strategicFormation.getMissionId()).getScenarios() + campaign.getMission(combatTeam.getMissionId()).getScenarios() .removeIf(scenario -> (scenario instanceof AtBScenario) - && (((AtBScenario) scenario).getStrategicFormationId() == strategicFormation.getForceId())); + && (((AtBScenario) scenario).getCombatTeamId() == combatTeam.getForceId())); } if (!sList.contains(atbScenario)) { sList.add(atbScenario); } - if (!assignedLances.contains(strategicFormation.getForceId())) { - assignedLances.add(strategicFormation.getForceId()); + if (!assignedLances.contains(combatTeam.getForceId())) { + assignedLances.add(combatTeam.getForceId()); } } else { logger.error("Unable to generate Base Attack scenario."); } } else { - logger.warn("No strategicFormations assigned to mission " + contract.getName() + logger.warn("No combatTeamsTable assigned to mission " + contract.getName() + ". Can't generate an Unbreakable Morale base defense mission for this force."); } } diff --git a/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java b/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java index 9d4c5feabe..8516fffe0b 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java @@ -40,7 +40,7 @@ import java.util.UUID; -import static mekhq.campaign.force.StrategicFormation.getStandardForceSize; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; import static mekhq.campaign.mission.AtBDynamicScenarioFactory.generateForce; import static mekhq.campaign.mission.AtBDynamicScenarioFactory.randomForceWeight; diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java index 62286ce795..a080127b5e 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BaseAttackBuiltInScenario.java @@ -98,7 +98,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti * Ally deploys 2 lances of a lighter weight class than the player, * minimum light */ - int allyForceWeight = Math.max(getStrategicFormation(campaign).getWeightClass(campaign) - 1, EntityWeightClass.WEIGHT_LIGHT); + int allyForceWeight = Math.max(getCombatTeamById(campaign).getWeightClass(campaign) - 1, EntityWeightClass.WEIGHT_LIGHT); addLance(allyEntities, getContract(campaign).getEmployerCode(), getContract(campaign).getAllySkill(), getContract(campaign).getAllyQuality(), allyForceWeight, campaign); addLance(allyEntities, getContract(campaign).getEmployerCode(), getContract(campaign).getAllySkill(), @@ -138,14 +138,14 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(new BotForce(BASE_TURRET_FORCE_ID, isAttacker() ? 2 : 1, defenderStart, defenderHome, turretForce), campaign); /* Roll 2x on bot lances roll */ - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), campaign); + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), campaign); addBotForce(getEnemyBotForce(getContract(campaign), enemyStart, getEnemyHome(), enemyEntities), campaign); // the "second" enemy force will either flee in the same direction as // the first enemy force in case of the player being the attacker // or where it came from in case of player being defender ArrayList secondBotEntities = new ArrayList<>(); - addEnemyForce(secondBotEntities, getStrategicFormation(campaign).getWeightClass(campaign), campaign); + addEnemyForce(secondBotEntities, getCombatTeamById(campaign).getWeightClass(campaign), campaign); BotForce secondBotForce = getEnemyBotForce(getContract(campaign), isAttacker() ? enemyStart : secondAttackerForceStart, isAttacker() ? getEnemyHome() : secondAttackerForceStart, secondBotEntities); diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BreakthroughBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BreakthroughBuiltInScenario.java index 38ef0705fb..adf193daee 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/BreakthroughBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/BreakthroughBuiltInScenario.java @@ -92,7 +92,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(allyEntitiesForce, campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), campaign); + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), campaign); BotForce botForce = getEnemyBotForce(getContract(campaign), enemyStart, getEnemyHome(), enemyEntities); try { diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ChaseBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ChaseBuiltInScenario.java index a52b493173..6fad76808f 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ChaseBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ChaseBuiltInScenario.java @@ -80,9 +80,9 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(allyEntitiesForce, campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, 0, + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, 0, -1, campaign); - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, 0, + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, 0, -1, campaign); BotForce botForce = getEnemyBotForce(getContract(campaign), startEdge, getEnemyHome(), enemyEntities); diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ExtractionBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ExtractionBuiltInScenario.java index d81a7b29d2..da06e960c5 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ExtractionBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ExtractionBuiltInScenario.java @@ -98,7 +98,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(getAllyBotForce(getContract(campaign), getStartingPos(), playerHome, allyEntities), campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), campaign); + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), campaign); addBotForce(getEnemyBotForce(getContract(campaign), enemyStart, getEnemyHome(), enemyEntities), campaign); ArrayList otherForce = new ArrayList<>(); diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java index 9f593f1c5a..65d2855e93 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HideAndSeekBuiltInScenario.java @@ -108,10 +108,10 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti } if (isAttacker()) { - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, 2, 0, campaign); } else { - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_HEAVY, 0, 0, campaign); } diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HoldTheLineBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HoldTheLineBuiltInScenario.java index 36bde06255..2a3c1f4529 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/HoldTheLineBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/HoldTheLineBuiltInScenario.java @@ -79,7 +79,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(getAllyBotForce(getContract(campaign), getStartingPos(), playerHome, allyEntities), campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_ASSAULT, isAttacker() ? 0 : 4, 0, campaign); addBotForce(getEnemyBotForce(getContract(campaign), enemyStart, getEnemyHome(), enemyEntities), campaign); diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java index a18f653bb8..361146c023 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ProbeBuiltInScenario.java @@ -79,7 +79,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(getAllyBotForce(getContract(campaign), getStartingPos(), playerHome, allyEntities), campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_MEDIUM, 0, 0, + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), EntityWeightClass.WEIGHT_MEDIUM, 0, 0, campaign); addBotForce(getEnemyBotForce(getContract(campaign), enemyStart, getEnemyHome(), enemyEntities), campaign); diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ReconRaidBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ReconRaidBuiltInScenario.java index f547848e72..247550d338 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/ReconRaidBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/ReconRaidBuiltInScenario.java @@ -76,7 +76,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(getAllyBotForce(getContract(campaign), getStartingPos(), playerHome, allyEntities), campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), isAttacker() ? EntityWeightClass.WEIGHT_ASSAULT : EntityWeightClass.WEIGHT_MEDIUM, 0, 0, campaign); addBotForce(getEnemyBotForce(getContract(campaign), enemyStart, getEnemyHome(), enemyEntities), campaign); diff --git a/MekHQ/src/mekhq/campaign/mission/atb/scenario/StandUpBuiltInScenario.java b/MekHQ/src/mekhq/campaign/mission/atb/scenario/StandUpBuiltInScenario.java index 8e1ecb0dc7..b306f609c1 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/scenario/StandUpBuiltInScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/scenario/StandUpBuiltInScenario.java @@ -64,7 +64,7 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList allyEnti addBotForce(getAllyBotForce(getContract(campaign), getStartingPos(), playerHome, allyEntities), campaign); } - addEnemyForce(enemyEntities, getStrategicFormation(campaign).getWeightClass(campaign), campaign); + addEnemyForce(enemyEntities, getCombatTeamById(campaign).getWeightClass(campaign), campaign); addBotForce(getEnemyBotForce(getContract(campaign), getEnemyHome(), getEnemyHome(), enemyEntities), campaign); } diff --git a/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java b/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java index 607f381829..edaeba6fa6 100644 --- a/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java +++ b/MekHQ/src/mekhq/campaign/personnel/autoAwards/MiscAwards.java @@ -279,7 +279,7 @@ private static boolean prisonerOfWar(Campaign campaign, Award award, UUID person */ private static boolean drillInstructor(Campaign campaign, Award award, UUID person) { if (award.canBeAwarded(campaign.getPerson(person))) { - return campaign.getAllStrategicFormations().stream() + return campaign.getAllCombatTeams().stream() .anyMatch(lance -> (lance.getRole().isTraining()) && (lance.getCommanderId().equals(person))); } diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index a87ad37985..fb3df6d164 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -33,8 +33,8 @@ import mekhq.campaign.event.NewDayEvent; import mekhq.campaign.event.ScenarioChangedEvent; import mekhq.campaign.event.StratconDeploymentEvent; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import mekhq.campaign.mission.*; import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment; import mekhq.campaign.mission.ScenarioForceTemplate.ForceGenerationMethod; @@ -999,7 +999,7 @@ public static void processForceDeployment(StratconCoords coords, int forceID, Ca MekHQ.triggerEvent(new ScenarioChangedEvent(scenario.getBackingScenario())); } - if (campaign.getStrategicFormationsTable().get(forceID).getRole().isScouting()) { + if (campaign.getCombatTeamsTable().get(forceID).getRole().isScouting()) { for (int direction = 0; direction < 6; direction++) { StratconCoords checkCoords = coords.translate(direction); @@ -1403,7 +1403,7 @@ private static boolean commanderLanceHasDefensiveAssignment(AtBDynamicScenario s if (lanceCommander != null){ Unit commanderUnit = lanceCommander.getUnit(); if (commanderUnit != null) { - StrategicFormation lance = campaign.getStrategicFormationsTable().get(commanderUnit.getForceId()); + CombatTeam lance = campaign.getCombatTeamsTable().get(commanderUnit.getForceId()); return (lance != null) && lance.getRole().isDefence(); } @@ -1775,7 +1775,7 @@ public static List getAvailableForceIDs(Campaign campaign) { // that are // deployed to a scenario and not in a track already - return campaign.getStrategicFormationsTable().keySet().stream() + return campaign.getCombatTeamsTable().keySet().stream() .mapToInt(key -> key) .mapToObj(campaign::getForce).filter(force -> (force != null) && !force.isDeployed() @@ -1808,7 +1808,7 @@ public static List getAvailableForceIDs(int unitType, Campaign campaign forcesInTracks.addAll(currentScenario.getFailedReinforcements()); } - for (StrategicFormation formation : campaign.getStrategicFormationsTable().values()) { + for (CombatTeam formation : campaign.getCombatTeamsTable().values()) { Force force = campaign.getForce(formation.getForceId()); if (force == null) { @@ -2013,9 +2013,9 @@ public static ReinforcementEligibilityType getReinforcementType(int forceID, Str // it can deploy "for free" (ReinforcementEligibilityType.ChainedScenario) // if the force is in 'fight' stance, it'll be able to deploy using 'fight lance' rules - if (campaign.getStrategicFormationsTable().containsKey(forceID)) { - Hashtable strategicFormations = campaign.getStrategicFormationsTable(); - StrategicFormation formation = strategicFormations.get(forceID); + if (campaign.getCombatTeamsTable().containsKey(forceID)) { + Hashtable combatTeamsTable = campaign.getCombatTeamsTable(); + CombatTeam formation = combatTeamsTable.get(forceID); if (formation == null) { return ReinforcementEligibilityType.NONE; diff --git a/MekHQ/src/mekhq/gui/BriefingTab.java b/MekHQ/src/mekhq/gui/BriefingTab.java index aed006bb84..e494090b3a 100644 --- a/MekHQ/src/mekhq/gui/BriefingTab.java +++ b/MekHQ/src/mekhq/gui/BriefingTab.java @@ -39,7 +39,7 @@ import mekhq.campaign.event.*; import mekhq.campaign.finances.Money; import mekhq.campaign.finances.enums.TransactionType; -import mekhq.campaign.force.StrategicFormation; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.mission.*; import mekhq.campaign.mission.atb.AtBScenarioFactory; import mekhq.campaign.mission.enums.MissionStatus; @@ -908,11 +908,11 @@ private void startScenario(BehaviorSettings autoResolveBehaviorSettings) { // code to support deployment of reinforcements for legacy ATB scenarios. if ((scenario instanceof AtBScenario) && !(scenario instanceof AtBDynamicScenario)) { - StrategicFormation assignedLance = ((AtBScenario) scenario).getStrategicFormation(getCampaign()); + CombatTeam assignedLance = ((AtBScenario) scenario).getCombatTeamById(getCampaign()); if (assignedLance != null) { int assignedForceId = assignedLance.getForceId(); int cmdrStrategy = 0; - Person commander = getCampaign().getPerson(StrategicFormation.findCommander(assignedForceId, getCampaign())); + Person commander = getCampaign().getPerson(CombatTeam.findCommander(assignedForceId, getCampaign())); if ((null != commander) && (null != commander.getSkill(SkillType.S_STRATEGY))) { cmdrStrategy = commander.getSkill(SkillType.S_STRATEGY).getLevel(); } diff --git a/MekHQ/src/mekhq/gui/ForceRenderer.java b/MekHQ/src/mekhq/gui/ForceRenderer.java index acecca9f71..3403a5f4cd 100644 --- a/MekHQ/src/mekhq/gui/ForceRenderer.java +++ b/MekHQ/src/mekhq/gui/ForceRenderer.java @@ -32,7 +32,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import java.awt.*; -import static mekhq.campaign.force.Force.STRATEGIC_FORMATION_OVERRIDE_NONE; +import static mekhq.campaign.force.Force.COMBAT_TEAM_OVERRIDE_NONE; public class ForceRenderer extends DefaultTreeCellRenderer { private static final MMLogger logger = MMLogger.create(ForceRenderer.class); @@ -150,11 +150,11 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean } String format; - if (force.isStrategicFormation()) { - format = (force.getOverrideStrategicFormation() != STRATEGIC_FORMATION_OVERRIDE_NONE) ? + if (force.isCombatTeam()) { + format = (force.getOverrideCombatTeam() != COMBAT_TEAM_OVERRIDE_NONE) ? "%s" : "%s"; } else { - format = (force.getOverrideStrategicFormation() != STRATEGIC_FORMATION_OVERRIDE_NONE) ? + format = (force.getOverrideCombatTeam() != COMBAT_TEAM_OVERRIDE_NONE) ? "%s" : "%s"; } diff --git a/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java index f15a1ec29a..61cb056d9a 100644 --- a/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java @@ -55,10 +55,10 @@ import java.awt.event.ActionEvent; import java.util.*; -import static mekhq.campaign.force.Force.STRATEGIC_FORMATION_OVERRIDE_FALSE; -import static mekhq.campaign.force.Force.STRATEGIC_FORMATION_OVERRIDE_NONE; -import static mekhq.campaign.force.Force.STRATEGIC_FORMATION_OVERRIDE_TRUE; -import static mekhq.campaign.force.StrategicFormation.recalculateStrategicFormations; +import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; +import static mekhq.campaign.force.Force.COMBAT_TEAM_OVERRIDE_FALSE; +import static mekhq.campaign.force.Force.COMBAT_TEAM_OVERRIDE_NONE; +import static mekhq.campaign.force.Force.COMBAT_TEAM_OVERRIDE_TRUE; public class TOEMouseAdapter extends JPopupMenuAdapter { private static final MMLogger logger = MMLogger.create(TOEMouseAdapter.class); @@ -448,26 +448,26 @@ public void actionPerformed(ActionEvent action) { return; } - boolean formationState = singleForce.isStrategicFormation(); - singleForce.setStrategicFormation(!formationState); - singleForce.setOverrideStrategicFormation(formationState ? STRATEGIC_FORMATION_OVERRIDE_FALSE : STRATEGIC_FORMATION_OVERRIDE_TRUE); + boolean formationState = singleForce.isCombatTeam(); + singleForce.setCombatTeamStatus(!formationState); + singleForce.setOverrideCombatTeam(formationState ? COMBAT_TEAM_OVERRIDE_FALSE : COMBAT_TEAM_OVERRIDE_TRUE); for (Force childForce : singleForce.getAllSubForces()) { - childForce.setOverrideStrategicFormation(STRATEGIC_FORMATION_OVERRIDE_NONE); + childForce.setOverrideCombatTeam(COMBAT_TEAM_OVERRIDE_NONE); } for (Force parentForce : singleForce.getAllParents()) { - parentForce.setOverrideStrategicFormation(STRATEGIC_FORMATION_OVERRIDE_NONE); + parentForce.setOverrideCombatTeam(COMBAT_TEAM_OVERRIDE_NONE); } - recalculateStrategicFormations(gui.getCampaign()); + recalculateCombatTeams(gui.getCampaign()); } else if (command.contains(REMOVE_STRATEGIC_FORCE_OVERRIDE)) { if (singleForce == null) { return; } - singleForce.setOverrideStrategicFormation(STRATEGIC_FORMATION_OVERRIDE_NONE); - recalculateStrategicFormations(gui.getCampaign()); + singleForce.setOverrideCombatTeam(COMBAT_TEAM_OVERRIDE_NONE); + recalculateCombatTeams(gui.getCampaign()); } else if (command.contains(TOEMouseAdapter.REMOVE_FORCE)) { for (Force force : forces) { if (null != force && null != force.getParentForce()) { @@ -1057,16 +1057,16 @@ protected Optional createPopupMenu() { menuItem.addActionListener(this); popup.add(menuItem); - JMenuItem optionStrategicForceOverride = new JMenuItem((force.isStrategicFormation() ? - "Never" : "Always") + " Consider Force a Strategic Formation"); + JMenuItem optionStrategicForceOverride = new JMenuItem((force.isCombatTeam() ? + "Never" : "Always") + " Consider Force a Combat Team"); optionStrategicForceOverride.setActionCommand(COMMAND_CHANGE_STRATEGIC_FORCE_OVERRIDE + forceIds); optionStrategicForceOverride.addActionListener(this); popup.add(optionStrategicForceOverride); - JMenuItem optionRemoveStrategicForceOverride = new JMenuItem("Remove Strategic Force Override"); + JMenuItem optionRemoveStrategicForceOverride = new JMenuItem("Remove Combat Team Override"); optionRemoveStrategicForceOverride.setActionCommand(COMMAND_REMOVE_STRATEGIC_FORCE_OVERRIDE + forceIds); optionRemoveStrategicForceOverride.addActionListener(this); - optionRemoveStrategicForceOverride.setVisible(force.getOverrideStrategicFormation() != STRATEGIC_FORMATION_OVERRIDE_NONE); + optionRemoveStrategicForceOverride.setVisible(force.getOverrideCombatTeam() != COMBAT_TEAM_OVERRIDE_NONE); popup.add(optionRemoveStrategicForceOverride); } diff --git a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java index 780b5d8874..1aea4fa46c 100644 --- a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java @@ -98,7 +98,7 @@ import java.util.stream.IntStream; import static megamek.client.ui.WrapLayout.wordWrap; -import static mekhq.campaign.force.StrategicFormation.recalculateStrategicFormations; +import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; /** * @author Justin 'Windchild' Bowen @@ -9571,7 +9571,7 @@ public void updateOptions() { campaign.setCampaignOptions(options); - recalculateStrategicFormations(campaign); + recalculateCombatTeams(campaign); MekHQ.triggerEvent(new OptionsChangedEvent(campaign, options)); } catch (Exception ex) { diff --git a/MekHQ/src/mekhq/gui/stratcon/ScenarioWizardLanceRenderer.java b/MekHQ/src/mekhq/gui/stratcon/ScenarioWizardLanceRenderer.java index ff21a92f65..736b2f8fba 100644 --- a/MekHQ/src/mekhq/gui/stratcon/ScenarioWizardLanceRenderer.java +++ b/MekHQ/src/mekhq/gui/stratcon/ScenarioWizardLanceRenderer.java @@ -19,8 +19,8 @@ package mekhq.gui.stratcon; import mekhq.campaign.Campaign; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import javax.swing.*; import java.awt.*; @@ -50,7 +50,7 @@ public Component getListCellRendererComponent(final JList list, setForeground(foreground); setBackground(background); - StrategicFormation lance = campaign.getStrategicFormationsTable().get(value.getId()); + CombatTeam lance = campaign.getCombatTeamsTable().get(value.getId()); String roleString = ""; if (lance != null) { roleString = lance.getRole().toString() + ", "; diff --git a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java index ebee91f81a..e2feb90b9e 100644 --- a/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/AtBScenarioViewPanel.java @@ -292,8 +292,8 @@ private void fillStats() { gridBagConstraints.gridwidth = 1; panStats.add(lblForce, gridBagConstraints); - if (null != scenario.getStrategicFormation(campaign)) { - lblForceDesc.setText(campaign.getForce(scenario.getStrategicFormationId()).getFullName()); + if (null != scenario.getCombatTeamById(campaign)) { + lblForceDesc.setText(campaign.getForce(scenario.getCombatTeamId()).getFullName()); } else if (scenario instanceof AtBDynamicScenario) { StringBuilder forceBuilder = new StringBuilder(); forceBuilder.append(""); diff --git a/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java b/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java index ed6a939a2c..dfb7a4ca28 100644 --- a/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java +++ b/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java @@ -24,8 +24,8 @@ import megamek.common.util.sorter.NaturalOrderComparator; import mekhq.MekHQ; import mekhq.campaign.Campaign; +import mekhq.campaign.force.CombatTeam; import mekhq.campaign.force.Force; -import mekhq.campaign.force.StrategicFormation; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.enums.AtBLanceRole; import mekhq.campaign.personnel.SkillType; @@ -172,8 +172,8 @@ public Component getTableCellRendererComponent(JTable table, Object value, RowFilter laFilter = new RowFilter<>() { @Override public boolean include(Entry entry) { - StrategicFormation strategicFormation = entry.getModel().getRow(entry.getIdentifier()); - return strategicFormation.isEligible(campaign); + CombatTeam combatTeam = entry.getModel().getRow(entry.getIdentifier()); + return combatTeam.isEligible(campaign); } }; final NaturalOrderComparator noc = new NaturalOrderComparator(); @@ -226,14 +226,14 @@ public void refresh() { cbContract.addItem(contract); } AtBContract defaultContract = activeContracts.isEmpty() ? null : activeContracts.get(0); - for (StrategicFormation strategicFormation : campaign.getStrategicFormationsTable().values()) { - if ((strategicFormation.getContract(campaign) == null) - || !strategicFormation.getContract(campaign).isActiveOn(campaign.getLocalDate(), true)) { - strategicFormation.setContract(defaultContract); + for (CombatTeam combatTeam : campaign.getCombatTeamsTable().values()) { + if ((combatTeam.getContract(campaign) == null) + || !combatTeam.getContract(campaign).isActiveOn(campaign.getLocalDate(), true)) { + combatTeam.setContract(defaultContract); } } ((DataTableModel) tblRequiredLances.getModel()).setData(activeContracts); - ((DataTableModel) tblAssignments.getModel()).setData(campaign.getAllStrategicFormations()); + ((DataTableModel) tblAssignments.getModel()).setData(campaign.getAllCombatTeams()); panRequiredLances.setVisible(tblRequiredLances.getRowCount() > 0); } @@ -347,10 +347,10 @@ public Object getValueAt(int row, int column) { if (data.get(row) instanceof AtBContract contract) { if (column == COL_TOTAL) { int t = 0; - for (StrategicFormation strategicFormation : campaign.getAllStrategicFormations()) { - if (data.get(row).equals(strategicFormation.getContract(campaign)) - && (strategicFormation.getRole() != AtBLanceRole.UNASSIGNED) - && strategicFormation.isEligible(campaign)) { + for (CombatTeam combatTeam : campaign.getAllCombatTeams()) { + if (data.get(row).equals(combatTeam.getContract(campaign)) + && (combatTeam.getRole() != AtBLanceRole.UNASSIGNED) + && combatTeam.isEligible(campaign)) { t++; } } @@ -360,10 +360,10 @@ public Object getValueAt(int row, int column) { return Integer.toString(contract.getRequiredLances()); } else if (contract.getContractType().getRequiredLanceRole().ordinal() == column - 2) { int t = 0; - for (StrategicFormation strategicFormation : campaign.getAllStrategicFormations()) { - if (data.get(row).equals(strategicFormation.getContract(campaign)) - && (strategicFormation.getRole() == strategicFormation.getContract(campaign).getContractType().getRequiredLanceRole()) - && strategicFormation.isEligible(campaign)) { + for (CombatTeam combatTeam : campaign.getAllCombatTeams()) { + if (data.get(row).equals(combatTeam.getContract(campaign)) + && (combatTeam.getRole() == combatTeam.getContract(campaign).getContractType().getRequiredLanceRole()) + && combatTeam.isEligible(campaign)) { t++; } } @@ -426,8 +426,8 @@ public boolean isCellEditable(int row, int col) { return col > COL_WEIGHT_CLASS; } - public StrategicFormation getRow(int row) { - return (StrategicFormation) data.get(row); + public CombatTeam getRow(int row) { + return (CombatTeam) data.get(row); } @Override @@ -438,10 +438,10 @@ public Object getValueAt(int row, int column) { return ""; } return switch (column) { - case COL_FORCE -> campaign.getForce(((StrategicFormation) data.get(row)).getForceId()); - case COL_WEIGHT_CLASS -> WEIGHT_CODES[((StrategicFormation) data.get(row)).getWeightClass(campaign)]; - case COL_CONTRACT -> campaign.getMission(((StrategicFormation) data.get(row)).getMissionId()); - case COL_ROLE -> ((StrategicFormation) data.get(row)).getRole(); + case COL_FORCE -> campaign.getForce(((CombatTeam) data.get(row)).getForceId()); + case COL_WEIGHT_CLASS -> WEIGHT_CODES[((CombatTeam) data.get(row)).getWeightClass(campaign)]; + case COL_CONTRACT -> campaign.getMission(((CombatTeam) data.get(row)).getMissionId()); + case COL_ROLE -> ((CombatTeam) data.get(row)).getRole(); default -> "?"; }; } @@ -449,10 +449,10 @@ public Object getValueAt(int row, int column) { @Override public void setValueAt(Object value, int row, int col) { if (col == COL_CONTRACT) { - ((StrategicFormation) data.get(row)).setContract((AtBContract) value); + ((CombatTeam) data.get(row)).setContract((AtBContract) value); } else if (col == COL_ROLE) { if (value instanceof AtBLanceRole) { - ((StrategicFormation) data.get(row)).setRole((AtBLanceRole) value); + ((CombatTeam) data.get(row)).setRole((AtBLanceRole) value); } } fireTableDataChanged();