Fix/4527 sam range upgrade - #4802
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughSAM launchers now mark range changes after level updates, publish that state, clear cached target results, and reevaluate nukes against the updated range. ChangesSAM range recheck
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/core/game/UnitImpl.ts (1)
644-647: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for SAM downgrades.
The new test covers
increaseLevel(), but this changeddecreaseLevel()branch also invalidates cached range results. Add a case that verifies the flag is set and stale targeting is rechecked after a downgrade. As per coding guidelines, core simulation changes should include tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/game/UnitImpl.ts` around lines 644 - 647, Add regression coverage for the SAMLauncher downgrade path in decreaseLevel(), verifying that _recheckSAMRange is set after decreasing the unit level and that subsequent targeting recalculates range rather than using stale cached results. Keep the existing increaseLevel() coverage and follow the established core simulation test patterns.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/core/game/UnitImpl.ts`:
- Around line 644-647: Add regression coverage for the SAMLauncher downgrade
path in decreaseLevel(), verifying that _recheckSAMRange is set after decreasing
the unit level and that subsequent targeting recalculates range rather than
using stale cached results. Keep the existing increaseLevel() coverage and
follow the established core simulation test patterns.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e2788c7-4f8b-4455-a33d-6cd5efaf505c
📒 Files selected for processing (5)
src/core/execution/SAMLauncherExecution.tssrc/core/game/Game.tssrc/core/game/GameUpdates.tssrc/core/game/UnitImpl.tstests/core/executions/SAMLauncherExecution.test.ts
…cks in test (no NukeExecution - nukes don't physicially move in the game)
Could this be used to cheese? For example if a hydro is heading toward a level 4 SAM, you could quickly upgrade it before the hydro hits? |
| //Needs to recheck range on upgrade | ||
| private _recheckSAMRange: boolean = false; |
There was a problem hiding this comment.
since this is SAM specific, can we create a SAMState type like WarshipState
There was a problem hiding this comment.
I will make the SAMState thing. I just copied it from another unit I saw so there might be more that would need a State class/file.
And yes, I mentioned this as a problem in the issue. You can just spam level up and catch everything with this. I personally suggest making a range that increases over 9 seconds (missile reload time to be exact)
Code on MAIN just caches any missiles and doesn't reupdate, so it's just a magic variable causing an unintended side effect. I'm down with making it official too, but as it stands it's not based on anything like Sam level or range, just a hidden variable nobody knows.
Since it just got assigned without comment I just decided to fix the unintended side effect but I'm super happy to change the functionality to an increase in range over time
There was a problem hiding this comment.
I think the current behavior is good, we should make it more clear in the code though. maybe a timer or something for how long the new range takes affect. Or maybe any inflight missiles still use the old range. something like that.
Add approved & assigned issue number here:
Resolves #4527
Description:
Fixes a bug where a SAM wouldn't shoot something after a range upgrade in the detection range since it got cached.
Has a new flag when SAM gets upgraded, clears cache in the next cycle in SAMExecution.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
JB940