Fix Tiger Mom buff cleanup logic#173
Conversation
- Created `cleanupEnemyBuffs` helper in `MainViewModel.kt` to ensure ARMOR buffs are removed if the source Tiger Mom is dead, no longer targeting, or grabbed. - Applied cleanup at the end of both `handleEnemyPipeline` and `handleProjectiles`. - Added `TigerMomBuffCleanupTest.kt` to verify fix. - Updated `fixes.md` with FIX-016. Co-authored-by: candour <4670475+candour@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCentralizes Tiger Mom ARMOR buff lifecycle into a new ChangesTiger Mom Buff Cleanup Centralization
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly Related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
app/src/test/java/com/messark/hawker/TigerMomBuffCleanupTest.kt (1)
95-102: ⚡ Quick winAssert Tiger Mom state reset, not only target buff removal.
This test should also verify the source Tiger Mom clears
buffingTargetIdand unstops, matching the cleanup contract.Suggested assertion additions
val newState = viewModel.gameState.value val updatedTarget = newState.enemies.find { it.id == targetId } + val updatedMom = newState.enemies.find { it.id == momId } assertNotNull("Target enemy should still exist", updatedTarget) + assertNotNull("Tiger Mom should still exist", updatedMom) // This is expected to FAIL before the fix assertFalse("Buff should be removed when source is grabbed", updatedTarget!!.buffs.any { it.sourceId == momId && it.type == BuffType.ARMOR }) + assertFalse("Tiger Mom should no longer be stopped while grabbed cleanup runs", updatedMom!!.isStopped) + org.junit.Assert.assertNull("Tiger Mom buff target should be cleared", updatedMom.buffingTargetId)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1daa8c44-6818-4785-8cc5-66c24c0aacf4
📒 Files selected for processing (3)
app/src/main/java/com/messark/hawker/MainViewModel.ktapp/src/test/java/com/messark/hawker/TigerMomBuffCleanupTest.ktfixes.md
|
Handle dead targets explicitly when clearing |
Good catch. I've updated |
- Updated `cleanupEnemyBuffs` to explicitly clear `buffingTargetId` if the target is marked dead. - This ensures Tiger Mom state is reset immediately upon target defeat. Co-authored-by: candour <4670475+candour@users.noreply.github.com>
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
This PR fixes a bug where Tiger Mom buffs could persist indefinitely on enemies if the source Tiger Mom was grabbed by a Tray Return Uncle or if no projectiles hit any enemies in subsequent ticks.
I centralized the buff cleanup logic into a new
cleanupEnemyBuffsmethod inMainViewModel.kt. This method ensures that:ARMORbuffs are removed if their source is dead, no longer targeting the enemy, or is currently grabbed (e.g., by a Tray Return Uncle).buffingTargetId,isStopped) is cleaned up if her target is gone or if she herself is grabbed.The cleanup is now consistently performed at the end of the enemy processing pipeline and after projectile impacts, ensuring game state integrity even when combat is not active.
A new unit test
TigerMomBuffCleanupTestwas added to reproduce the issue and verify the fix.PR created automatically by Jules for task 15074498557543227381 started by @candour
Summary by CodeRabbit
Bug Fixes
Tests
Documentation