Fix StratCon completed objectives being invalidated by subsequent scenario losses (Fixes #8705)#8726
Open
Fix StratCon completed objectives being invalidated by subsequent scenario losses (Fixes #8705)#8726
Conversation
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().
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause
When a scenario is lost at a location with a
SpecificScenarioVictoryobjective, the code unconditionally sets theobjective to
OBJECTIVE_FAILEDwithout checking if the objective was already completed from a previous victory. Thiscauses completed objectives to be invalidated when a new scenario spawns at the same location and is lost.
Changes
StratConRulesManager.updateStrategicObjectives()- Added guard clause to only fail objectives that haven't already been completedStratConTrackState.failObjective()- Added same guard clause to preserve completed objectives when scenarios are ignoredFiles Changed
MekHQ/src/mekhq/campaign/stratCon/StratConRulesManager.java- CheckisObjectiveCompleted()before settingOBJECTIVE_FAILEDon scenario lossMekHQ/src/mekhq/campaign/stratCon/StratConTrackState.java- CheckisObjectiveCompleted()before failing objective in convenience methodTesting
Fixes #8705