From 9db18601b9d892693abf0c2c65601ab9cab8280e Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 21 Nov 2024 12:03:17 -0600 Subject: [PATCH] Optimize StratCon handling and improve offensive definition Updated isOffensive method to include planetary assaults, modified processMassRout to streamline parameters, and adjusted seeding logic with revised multipliers. This enhances the clarity and efficiency of the StratCon campaign state management and scenario processing. --- .../mekhq/campaign/mission/AtBContract.java | 2 +- .../mission/enums/AtBContractType.java | 2 +- .../stratcon/StratconContractInitializer.java | 18 ++++++++---------- .../stratcon/StratconRulesManager.java | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBContract.java b/MekHQ/src/mekhq/campaign/mission/AtBContract.java index 5871ae60b9..15aca7fb34 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBContract.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBContract.java @@ -543,7 +543,7 @@ public void checkMorale(Campaign campaign, LocalDate today) { } if (campaign.getCampaignOptions().isUseStratCon()) { - processMassRout(campaign, getStratconCampaignState()); + processMassRout(getStratconCampaignState()); } } diff --git a/MekHQ/src/mekhq/campaign/mission/enums/AtBContractType.java b/MekHQ/src/mekhq/campaign/mission/enums/AtBContractType.java index 16b5ea8d47..442e386053 100644 --- a/MekHQ/src/mekhq/campaign/mission/enums/AtBContractType.java +++ b/MekHQ/src/mekhq/campaign/mission/enums/AtBContractType.java @@ -146,7 +146,7 @@ public boolean isRaidType() { * {@code false} otherwise */ public boolean isOffensive() { - return isRaidType() || isPirateHunting() || isGuerrillaWarfare(); + return isRaidType() || isPirateHunting() || isGuerrillaWarfare() || isPlanetaryAssault(); } // endregion Boolean Comparison Methods diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconContractInitializer.java b/MekHQ/src/mekhq/campaign/stratcon/StratconContractInitializer.java index 46de53b82a..a5ef1b5373 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconContractInitializer.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconContractInitializer.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.Random; +import static java.lang.Math.ceil; import static java.lang.Math.round; import static megamek.common.Coords.ALL_DIRECTIONS; import static mekhq.campaign.rating.IUnitRating.*; @@ -221,28 +222,25 @@ public static void initializeCampaignState(AtBContract contract, Campaign campai * @param track the relevant {@link StratconTrackState} */ public static void seedPreDeployedForces(AtBContract contract, Campaign campaign, StratconTrackState track) { - final int CLAN_CLUSTER = 27; // Stars - final int IS_BATTALION = 27; // Lances - final int COMSTAR_LEVEL_IV = 36; // Level IIs + // TODO remove reductions once we have friendly forces deploying too + final int CLAN_CLUSTER = 11; // 22 Stars, reduced to 11 + final int IS_BATTALION = 14; // 27 Lances, reduced to 14 + final int COMSTAR_LEVEL_IV = 18; // 36 Level IIs, reduced to 18 double multiplier = switch (contract.getEnemyQuality()) { case DRAGOON_F -> 0.25; case DRAGOON_D -> 0.5; case DRAGOON_C -> 0.75; - case DRAGOON_B -> 1; case DRAGOON_A -> 1.5; case DRAGOON_ASTAR -> 2; - default -> - throw new IllegalStateException( - "Unexpected value in mekhq/campaign/stratcon/StratconContractInitializer.java/seedPreDeployedForces: " - + contract.getEnemyQuality()); + default -> 1; // DRAGOON_B }; AtBContractType contractType = contract.getContractType(); if (contractType.isPirateHunting() || contractType.isGarrisonType()) { multiplier *= 0.5; - } else if (contractType.isOffensive()) { + } else if (contractType.isPlanetaryAssault()) { multiplier *= 2; } @@ -254,7 +252,7 @@ public static void seedPreDeployedForces(AtBContract contract, Campaign campaign elementCount = COMSTAR_LEVEL_IV; } - elementCount = (int) round(elementCount * multiplier); + elementCount = (int) ceil(elementCount * multiplier); for (int i = 0; i < elementCount; i++) { addHiddenExternalScenario(campaign, contract, track, null, false); diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 1b6232175e..4d327b34ed 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -2070,10 +2070,9 @@ public static void processDailyMovement(Campaign campaign, StratconCampaignState * If scenario's deployment date is {@code null} and scenario is not a strategic objective, * it is removed from the track and then updated. * - * @param campaign the current campaign. * @param campaignState the relevant StratCon campaign state. */ - public static void processMassRout(Campaign campaign, StratconCampaignState campaignState) { + public static void processMassRout(StratconCampaignState campaignState) { for (StratconTrackState track : campaignState.getTracks()) { List allScenarios = new ArrayList<>(track.getScenarios().values());