Skip to content

Fix StratCon completed objectives being invalidated by subsequent scenario losses (Fixes #8705)#8726

Open
HammerGS wants to merge 1 commit intomainfrom
fix/8705-stratcon-objective-invalidation
Open

Fix StratCon completed objectives being invalidated by subsequent scenario losses (Fixes #8705)#8726
HammerGS wants to merge 1 commit intomainfrom
fix/8705-stratcon-objective-invalidation

Conversation

@HammerGS
Copy link
Member

@HammerGS HammerGS commented Feb 5, 2026

Root Cause

When a scenario is lost at a location with a SpecificScenarioVictory objective, the code unconditionally sets the
objective to OBJECTIVE_FAILED without checking if the objective was already completed from a previous victory. This
causes completed objectives to be invalidated when a new scenario spawns at the same location and is lost.

Changes

  1. StratConRulesManager.updateStrategicObjectives() - Added guard clause to only fail objectives that haven't already been completed
  2. StratConTrackState.failObjective() - Added same guard clause to preserve completed objectives when scenarios are ignored

Files Changed

  • MekHQ/src/mekhq/campaign/stratCon/StratConRulesManager.java - Check isObjectiveCompleted() before setting OBJECTIVE_FAILED on scenario loss
  • MekHQ/src/mekhq/campaign/stratCon/StratConTrackState.java - Check isObjectiveCompleted() before failing objective in convenience method

Testing

  1. Load save with a completed SpecificScenarioVictory objective
  2. Advance campaign until new scenario spawns at same coordinates
  3. Resolve new scenario as defeat
  4. Verify completed objective remains completed (not invalidated)

Fixes #8705

  Fix StratCon completed objectives being invalidated by subsequent scenario losses (Fixes #8705)

  ---
  PR Body

  ## Root Cause

  When a scenario is lost at a location with a `SpecificScenarioVictory` objective, the code unconditionally sets the
  objective to `OBJECTIVE_FAILED` without checking if the objective was already completed from a previous victory. This
  causes completed objectives to be invalidated when a new scenario spawns at the same location and is lost.

  ## Changes

  1. `StratConRulesManager.updateStrategicObjectives()` - Added guard clause to only fail objectives that haven't
  already been completed
  2. `StratConTrackState.failObjective()` - Added same guard clause to preserve completed objectives when scenarios are
  ignored

  ## Files Changed

  - `MekHQ/src/mekhq/campaign/stratCon/StratConRulesManager.java` - Check `isObjectiveCompleted()` before setting
  `OBJECTIVE_FAILED` on scenario loss
  - `MekHQ/src/mekhq/campaign/stratCon/StratConTrackState.java` - Check `isObjectiveCompleted()` before failing
  objective in convenience method

  ## Testing

  1. Load save with a completed SpecificScenarioVictory objective
  2. Advance campaign until new scenario spawns at same coordinates
  3. Resolve new scenario as defeat
  4. Verify completed objective remains completed (not invalidated)

  Fixes #8705

  ---
  Commit Message

  Fix StratCon completed objectives invalidated by scenario loss

  Fixes #8705

  Root cause: When a scenario is lost, updateStrategicObjectives()
  unconditionally sets the objective at that location to OBJECTIVE_FAILED,
  even if the objective was already completed from a previous victory.

  Fix: Add guard clause to check !isObjectiveCompleted(track) before
  setting OBJECTIVE_FAILED in both StratConRulesManager and
  StratConTrackState.failObjective().
Copilot AI review requested due to automatic review settings February 5, 2026 02:22
@HammerGS HammerGS requested a review from a team as a code owner February 5, 2026 02:22
@HammerGS HammerGS added the AI Generated Code AI-generated fix. Requires human testing and review before merging. label Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a bug where completed StratCon objectives were being invalidated when a subsequent scenario at the same location was lost. The fix adds guard clauses to prevent setting completed objectives to OBJECTIVE_FAILED.

Changes:

  • Added guard clause in StratConRulesManager.updateStrategicObjectives() to only fail objectives that haven't been completed
  • Added same guard clause in StratConTrackState.failObjective() convenience method
  • Updated method documentation to reflect the new behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
MekHQ/src/mekhq/campaign/stratCon/StratConRulesManager.java Added check to prevent failing already-completed objectives when scenarios are lost
MekHQ/src/mekhq/campaign/stratCon/StratConTrackState.java Added check in convenience method to preserve completed objectives when scenarios are ignored

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Code AI-generated fix. Requires human testing and review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue] Stratcon completed objective invalidated by another scenario failure on same track

1 participant