Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected Date of Resupply Interception Scenarios & Added Clarity to Scenario Names #5466

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading