Skip to content

Random Civilian Removal Fix#8990

Merged
HammerGS merged 2 commits into
MegaMek:mainfrom
IllianiBird:randomCivilianRemovalFix
May 19, 2026
Merged

Random Civilian Removal Fix#8990
HammerGS merged 2 commits into
MegaMek:mainfrom
IllianiBird:randomCivilianRemovalFix

Conversation

@IllianiBird

Copy link
Copy Markdown
Collaborator

At some point in the distant past we introduced implicit filters to the method that fetches personnel. This was done to filter out unnecessary personnel, specifically Camp Followers. However, this was incorrectly propagated to the Random Civilian Removal system, so that all Camp Followers were filtered out and thus never considered eligible for random removal.

Addendum: we may see an uptick in player contract regarding civilians leaving their campaign. This will be working as intended, if players want to keep their civilians they should employ them. At which point they'll be covered by normal Retention systems.

@IllianiBird IllianiBird self-assigned this May 17, 2026
@IllianiBird IllianiBird requested a review from a team as a code owner May 17, 2026 20:44
@IllianiBird IllianiBird added Bug Personnel Personnel-related Issues labels May 17, 2026
@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 13.99%. Comparing base (d2c8380) to head (922aad2).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
...src/mekhq/campaign/personnel/RandomDependents.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8990      +/-   ##
============================================
- Coverage     14.00%   13.99%   -0.02%     
+ Complexity     8320     8317       -3     
============================================
  Files          1285     1285              
  Lines        167958   167972      +14     
  Branches      25418    25422       +4     
============================================
- Hits          23530    23513      -17     
- Misses       141950   141982      +32     
+ Partials       2478     2477       -1     

☔ 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.

@HammerGS HammerGS requested a review from Copilot May 18, 2026 15:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes the Random Civilian Removal (“Random Dependents”) flow so camp followers are included in the active personnel pool and can be considered for random removal, aligning behavior with campaign expectations around civilian retention.

Changes:

  • Include camp followers when building the candidate pool by switching Campaign.getActivePersonnel(..., includeCampFollowers) to includeCampFollowers=true.
  • Narrow dependent collection to camp followers that are civilians (!isEmployed() && isCivilian()), keeping the removal system focused on civilians.
  • Update the unit test mock to match the revised getActivePersonnel(false, true) call.

Reviewed changes

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

File Description
MekHQ/src/mekhq/campaign/personnel/RandomDependents.java Includes camp followers in the active personnel iteration so they can be tracked and removed as dependents.
MekHQ/unittests/mekhq/campaign/personnel/RandomDependentsTest.java Adjusts mocking to reflect the updated getActivePersonnel(false, true) usage.

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

@HammerGS HammerGS merged commit 02680ff into MegaMek:main May 19, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Personnel Personnel-related Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants