Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Sleet01
Copy link
Collaborator

@Sleet01 Sleet01 commented May 6, 2025

Fix for Artillery units moving but keeping their auto-hit mods on hexes they've already hit.
This patch adds a new method to the ArtilleryTracker to remove only those autohit mods when a unit expends MP.

Note that other mods (such as base artillery mod, spotter adjustment mod, etc.) should not be modified by this method, as only the auto-hit mod is lost after movement (per TO:AR rules).

Testing:

  • Tested with games vs Princess including on- and off-board artillery on various unit types
  • Added unit tests
  • Ran all 3 projects' unit tests

Close #6929

@Sleet01 Sleet01 requested a review from a team as a code owner May 6, 2025 23:17
@Sleet01 Sleet01 force-pushed the Fix_6929_artillery_units_should_lose_autohit_mod_after_spending_mp branch from 5dd5b27 to fe039ae Compare May 6, 2025 23:19
@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 30.33%. Comparing base (aa956ee) to head (fe039ae).
Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
...c/megamek/server/totalwarfare/MovePathHandler.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6994      +/-   ##
============================================
+ Coverage     30.32%   30.33%   +0.01%     
- Complexity    15855    15874      +19     
============================================
  Files          2890     2890              
  Lines        283352   283363      +11     
  Branches      49313    49316       +3     
============================================
+ Hits          85927    85969      +42     
+ Misses       191799   191768      -31     
  Partials       5626     5626              

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

if (md.getMpUsed() > 0) {
// All auto-hit hexes for this unit (not including preset targets) are cleared
// if any MP are expended.
entity.aTracker.clearHitHexMods();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think a report would be reasonable for this. But not vital.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I had stepped away for dinner.
The only issue with reporting is that this is happening during the movement phase, as each move is executed, so reports inserted here would be interleaved with the normal movement reporting.
It feels a little wrong to insert reports about lost auto-hit artillery mods into the move report, but we could store the removed Coords in the ArtilleryTracker and report them during the next Indirect Phase report...
Actually, it might be good to report any auto-hit mods on a per-unit basis as well since we don't do that either.
I'll file an RFE, but I think it's outside the sope of this fix.

@Scoppio Scoppio merged commit ce2bfe5 into MegaMek:master May 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Artillery auto-hit hexes not lost on MP expenditure

2 participants