From a01b3fefcfc9e4d40e1c7e48d71eeb6c09bcd3d3 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 20 Dec 2024 19:16:00 -0600 Subject: [PATCH] Update StratCon scenario generation to handle deployment delays Modified `generateScenario` to include an optional `daysTilDeployment` parameter, allowing scenarios to account for deployment delays. Improved documentation to clarify functionality and integration with the campaign and StratCon tracks. --- .../stratcon/StratconRulesManager.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 0d7474545c..a4ded0ea19 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -1040,7 +1040,7 @@ public static void deployForceToCoords(StratconCoords coords, int forceID, Campa if (template != null) { scenario = generateScenario(campaign, contract, track, forceID, coords, template, daysTilDeployment); } else { - scenario = generateScenario(campaign, contract, track, forceID, coords); + scenario = generateScenario(campaign, contract, track, forceID, coords, daysTilDeployment); } if (scenario == null) { @@ -1602,20 +1602,34 @@ private static Map> sortForcesByMapType(List } /** - * Worker function that generates stratcon scenario at the given coords, for the - * given force, on the - * given track. Also registers it with the track and campaign. + * Generates a StratCon scenario at the specified coordinates for the given force on the specified track. + * The scenario is determined based on a random template suitable for the unit type of the specified force, + * and it is optionally configured with a deployment delay. + * + *

This method selects a random scenario template based on the primary unit type of the force, + * then delegates the scenario creation and configuration to another overloaded {@code generateScenario} method + * which handles specific template-based scenario generation.

+ * + * @param campaign the {@link Campaign} managing the overall gameplay state + * @param contract the {@link AtBContract} governing the StratCon campaign + * @param track the {@link StratconTrackState} where the scenario is placed + * @param forceID the ID of the force for which the scenario is generated + * @param coords the {@link StratconCoords} specifying where the scenario will be generated + * @param daysTilDeployment the number of days until the scenario is deployed; if {@code null}, + * deployment dates are determined dynamically + * @return the generated {@link StratconScenario}, or {@code null} if scenario generation fails */ private static @Nullable StratconScenario generateScenario(Campaign campaign, AtBContract contract, StratconTrackState track, int forceID, - StratconCoords coords) { + StratconCoords coords, + @Nullable Integer daysTilDeployment) { int unitType = campaign.getForce(forceID).getPrimaryUnitType(campaign); ScenarioTemplate template = StratconScenarioFactory.getRandomScenario(unitType); // useful for debugging specific scenario types // template = StratconScenarioFactory.getSpecificScenario("Defend Grounded // Dropship.xml"); - return generateScenario(campaign, contract, track, forceID, coords, template, -1); + return generateScenario(campaign, contract, track, forceID, coords, template, daysTilDeployment); } /**