Fix #8504: Fixed DropShip Force Experience Rating Contributions#8505
Fix #8504: Fixed DropShip Force Experience Rating Contributions#8505HammerGS merged 3 commits intoMegaMek:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8505 +/- ##
============================================
+ Coverage 12.32% 12.36% +0.04%
- Complexity 7425 7448 +23
============================================
Files 1287 1287
Lines 165312 165359 +47
Branches 24875 24886 +11
============================================
+ Hits 20375 20453 +78
+ Misses 142983 142950 -33
- Partials 1954 1956 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #8504 where DropShips and Small Craft were incorrectly contributing to Force Experience Rating calculations. Previously, these unit types would use commander-only skills, which resulted in missing gunnery or piloting skills and negative reputation effects. The fix introduces averaging logic that calculates the mean piloting skill across all drivers and the mean gunnery skill across all gunners for SmallCraft and DropShip units.
Key Changes
- Added special handling for SmallCraft (including DropShips) to average piloting skills across all drivers and gunnery skills across all gunners
- Moved commander-based skill calculation into an else branch for non-SmallCraft units
- Added necessary imports for List, Set, and SmallCraft classes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MekHQ/src/mekhq/campaign/camOpsReputation/AverageExperienceRating.java
Outdated
Show resolved
Hide resolved
MekHQ/src/mekhq/campaign/camOpsReputation/AverageExperienceRating.java
Outdated
Show resolved
Hide resolved
MekHQ/src/mekhq/campaign/camOpsReputation/AverageExperienceRating.java
Outdated
Show resolved
Hide resolved
MekHQ/src/mekhq/campaign/camOpsReputation/AverageExperienceRating.java
Outdated
Show resolved
Hide resolved
| double totalGunneryTargetNumbers = 0; | ||
| Set<Person> gunners = unit.getGunners(); | ||
| for (Person gunner : gunners) { | ||
| SkillModifierData skillModifierData = gunner.getSkillModifierData(true); | ||
| totalGunneryTargetNumbers += getSkillTargetNumber(gunner, entity, skillModifierData, false); | ||
| } | ||
| int gunnerCount = gunners.size(); | ||
| gunneryTargetNumber = gunnerCount == 0 ? 0 : (int) round(totalGunneryTargetNumbers / gunnerCount); |
There was a problem hiding this comment.
But what if (tbh writing it out I don't love it)
Set<Person> gunners = unit.getGunners();
gunneryTargetNumber = (int) round(gunners.stream()
.mapToInt(g -> getSkillTargetNumber(g,
entity,
g.getSkillModifierData(true),
false))
.average()
.orElse(0));
int gunnerCount = gunners.size();
& for piloting above
There was a problem hiding this comment.
A stream here feels like overkill.
Fix #8504
DropShips (and Small Craft) don't have commanders with both gunnery & piloting skills. That meant that the unit's experience rating contributions would be calculated as if the unit either had no gunnery, or no piloting. This resulting in the unit's contributions having a negative effect on Reputation.
Now we take an average of the piloting skills across all pilots, and the gunnery skill across all gunners.