Fix stall placement on enemies - #163
Conversation
- Added proximity check in `MainViewModel.onCellClick` to prevent building stalls on tiles occupied by enemies or tiles that are their next immediate target. - Ensured `lastSoldStall` is only cleared if placement is valid. - Added `StallPlacementEnemyTest.kt` to verify the fix. - Updated `fixes.md` with FIX-012. 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)
📝 WalkthroughWalkthroughThis PR adds enemy proximity validation to stall placement logic in MainViewModel. When a player clicks a hex tile to place a stall, the code now checks whether any active enemy occupies that coordinate or targets it as their immediate next path step. If either condition is true, placement is blocked. Tests verify both blocking scenarios and the bugfix is documented. ChangesEnemy Placement Validation
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 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: 1
🧹 Nitpick comments (2)
app/src/main/java/com/messark/hawker/MainViewModel.kt (1)
1073-1076: ⚡ Quick winConsider excluding grabbed enemies from proximity check.
Grabbed enemies (held by Tray Return Uncle stalls) have
isGrabbed = trueand aren't actively moving toward their next path target. Including them in the proximity check could block placement on tiles they'll never reach while grabbed. Consider adding&& !enemy.isGrabbedto the check.🎯 Suggested refinement
// Prevent building on or immediately in front of enemies - val isEnemyNear = currentState.enemies.any { enemy -> + val isEnemyNear = currentState.enemies.any { enemy -> + if (enemy.isGrabbed) return@any false val currentTarget = enemy.path.getOrNull(enemy.currentPathIndex + 1) GridUtils.hexRound(enemy.position.q, enemy.position.r) == coord || currentTarget == coord }app/src/test/java/com/messark/hawker/StallPlacementEnemyTest.kt (1)
56-62: 💤 Low valueConsider setting
currentPathIndex = 2for consistency.The enemy's
positionis(2f, 0f)which corresponds to index 2 in the path, butcurrentPathIndexdefaults to0. While this doesn't affect the test's correctness (it still validates that placement is blocked when an enemy occupies a tile), settingcurrentPathIndex = 2would make the test data more realistic and consistent with how enemy state works during actual gameplay.✨ Suggested improvement
val enemy = Enemy( id = "e1", health = 100f, maxHealth = 100f, position = PreciseAxialCoordinate(2f, 0f), - path = listOf(start, AxialCoordinate(1, 0), coord, AxialCoordinate(3, 0), end) + path = listOf(start, AxialCoordinate(1, 0), coord, AxialCoordinate(3, 0), end), + currentPathIndex = 2 )
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a22b5ec9-2e94-4b5d-a3fb-b2462ee47588
📒 Files selected for processing (3)
app/src/main/java/com/messark/hawker/MainViewModel.ktapp/src/test/java/com/messark/hawker/StallPlacementEnemyTest.ktfixes.md
|
Move lastSoldStall = null after successful placement validation. Line 1079 clears lastSoldStall after the enemy proximity check but before pathfinding validation (line 1109) and the Tray Return Uncle rule check (lines 1092-1107). If either of those validations fails, placement won't occur but the player will lose their undo ability. Move this line inside the successful placement block (around line 1124-1127) or include it in the state.copy() call to ensure it's only cleared when placement actually succeeds. |
Acknowledged. I've moved the |
- Added proximity check in `MainViewModel.onCellClick` to prevent building stalls on tiles occupied by enemies or tiles that are their next immediate target. - Ensured `lastSoldStall` is only cleared if placement is valid (addressed PR feedback). - Added `StallPlacementEnemyTest.kt` to verify the fix. - Updated `fixes.md` with FIX-012. Co-authored-by: candour <4670475+candour@users.noreply.github.com>
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
This change fixes a bug in Hawker Rush where stalls could be placed on top of moving customers, leading to visual clipping and potential gameplay issues. I've implemented a check in the placement logic to ensure that a tile is not occupied by an enemy or about to be occupied by one before allowing a stall to be built there. I've also included unit tests to verify this behavior and updated the project's fix log.
PR created automatically by Jules for task 7100298176518883205 started by @candour
Summary by CodeRabbit
Bug Fixes
Tests