Skip to content

Commit

Permalink
Merge pull request #5466 from IllianiCBT/resupply_dateBug
Browse files Browse the repository at this point in the history
Corrected Date of Resupply Interception Scenarios & Added Clarity to Scenario Names
  • Loading branch information
HammerGS authored Dec 22, 2024
2 parents d713187 + a01b3fe commit d613cc0
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,19 @@ private static void processConvoyInterception(Resupply resupply, @Nullable Force
// scenario, or a facility. If the player is really lucky, the scenario will spawn on top
// of a force already deployed to the Strategic Map.
StratconScenario scenario = generateExternalScenario(campaign, contract, track,
null, template, false);
null, template, false, 0);

// If we successfully generated a scenario, we need to make a couple of final
// adjustments, including assigning the Resupply contents as loot and
// assigning a player convoy (if appropriate)
if (scenario != null) {
AtBDynamicScenario backingScenario = scenario.getBackingScenario();
backingScenario.setDate(campaign.getLocalDate());

if (targetConvoy != null) {
backingScenario.addForce(targetConvoy.getId(), "Player");
String currentName = backingScenario.getName();
backingScenario.setName(currentName + " - " + targetConvoy.getName());

backingScenario.addForce(targetConvoy.getId(), ScenarioTemplate.PRIMARY_PLAYER_FORCE_ID);
targetConvoy.setScenarioId(backingScenario.getId(), campaign);
scenario.commitPrimaryForces();
}
Expand Down
29 changes: 26 additions & 3 deletions MekHQ/src/mekhq/campaign/stratcon/StratconContractInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,31 @@ private static void initializeTrackFacilities(StratconTrackState trackState, int
}

/**
* Worker function that takes a trackstate and plops down the given number of
* facilities owned by the given faction
* Initializes and populates a StratCon track with a specified number of objective scenarios.
* This method selects scenario templates, places them on the track in unoccupied coordinates,
* and optionally assigns facilities and objectives based on predefined rules.
*
* <p>The key steps of this method include:
* <ul>
* <li>Selecting scenario templates from the provided list of objective scenarios.</li>
* <li>Identifying unoccupied coordinates on the track to place each scenario.</li>
* <li>Adding facilities if the scenario template requires them (hostile or allied).</li>
* <li>Generating and configuring scenarios with relevant attributes and modifiers:</li>
* <ul>
* <li>Clearing scenario dates to maintain persistence.</li>
* <li>Marking scenarios as strategic objectives.</li>
* <li>Adding optional modifiers to provide additional effects or conditions.</li>
* </ul>
* <li>Tracking newly added scenarios as strategic objectives for gameplay purposes.</li>
* </ul>
*
* @param campaign the {@link Campaign} managing the state of the overall gameplay
* @param contract the {@link AtBContract} related to the current StratCon campaign
* @param trackState the {@link StratconTrackState} representing the track where objectives are placed
* @param numScenarios the number of objective scenarios to generate
* @param objectiveScenarios a list of {@link String} identifiers for potential scenarios that can be generated
* @param objectiveModifiers a list of optional {@link String} modifiers to apply to the generated scenarios;
* can be {@code null} if no modifiers are required
*/
private static void initializeObjectiveScenarios(Campaign campaign, AtBContract contract,
StratconTrackState trackState,
Expand Down Expand Up @@ -409,7 +432,7 @@ private static void initializeObjectiveScenarios(Campaign campaign, AtBContract

// create scenario - don't assign a force yet
StratconScenario scenario = StratconRulesManager.generateScenario(campaign, contract, trackState,
Force.FORCE_NONE, coords, template);
Force.FORCE_NONE, coords, template, null);

// clear dates, because we don't want the scenario disappearing on us
scenario.setDeploymentDate(null);
Expand Down
Loading

0 comments on commit d613cc0

Please sign in to comment.