Skip to content

PR: Fix crew killed buildings not counting as crew killed in after-action#8774

Merged
HammerGS merged 6 commits intoMegaMek:mainfrom
psikomonkie:pr/buildings/capture-building-mhq
Mar 14, 2026
Merged

PR: Fix crew killed buildings not counting as crew killed in after-action#8774
HammerGS merged 6 commits intoMegaMek:mainfrom
psikomonkie:pr/buildings/capture-building-mhq

Conversation

@psikomonkie
Copy link
Member

Do not merge until MegaMek/megamek#8059 has been merged!

Updates to scenario resolution to better support capturing buildings:

  • Entity's will count as captured if the building's opponent controls the battlefield
  • Buildings will count as preserved if they're captured
  • Buildings will count as captured if they still have CF (CF goes to 0 when it collapses!) even if "Destroyed" (Like after a crew kill!)

@psikomonkie psikomonkie requested a review from a team as a code owner March 4, 2026 02:13
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 0% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 13.22%. Comparing base (86a54f9) to head (6e9f6a0).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
.../mekhq/gui/dialog/ResolveScenarioWizardDialog.java 0.00% 37 Missing ⚠️
...q/campaign/mission/ScenarioObjectiveProcessor.java 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8774   +/-   ##
=========================================
  Coverage     13.22%   13.22%           
- Complexity     7873     7874    +1     
=========================================
  Files          1306     1306           
  Lines        169162   169191   +29     
  Branches      25452    25458    +6     
=========================================
+ Hits          22378    22383    +5     
- Misses       144606   144632   +26     
+ Partials       2178     2176    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 PR fixes a bug where crew-killed buildings were not being counted correctly in the after-action scenario resolution screen. Specifically, it updates the entityIsCaptured logic so that buildings with remaining CF (i.e., not collapsed) count as captured even if their entity state is "Destroyed", and updates entity capture/preserve evaluation to correctly use opponentHasBattlefieldControl rather than its inverse. It also re-enables the recheckObjectives() call in the tab-change handler.

Changes:

  • ScenarioObjectiveProcessor: Fixed entityIsCaptured to check opponentHasBattlefieldControl (instead of !opponentHasBattlefieldControl), and updated it to count non-collapsed AbstractBuildingEntity instances as captured. Added entityIsCaptured to the Preserve case in updateObjectiveEntityState.
  • ScenarioObjectiveProcessor: Updated the Capture case in entityMeetsObjective to also use opponentHasBattlefieldControl (matching the fix above).
  • ResolveScenarioWizardDialog: Introduced recheckObjectives() method and enabled it in tabChanged(), replacing the previously commented-out stub.

Reviewed changes

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

File Description
MekHQ/src/mekhq/campaign/mission/ScenarioObjectiveProcessor.java Fixes capture/preserve logic for buildings and corrects the opponentHasBattlefieldControl polarity for capture evaluation
MekHQ/src/mekhq/gui/dialog/ResolveScenarioWizardDialog.java Implements recheckObjectives() and enables it in tabChanged() to keep objective checkboxes in sync

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

…ves should remember manual player overrides - unless the player makes changes that change the "auto" value - going back and changing if a unit was killed, for example
@HammerGS HammerGS merged commit 5391287 into MegaMek:main Mar 14, 2026
9 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Bug & Feature Catcher: Buildings Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants