Centralize stall placement validation and fix undoSell bug#167
Conversation
Centralized stall placement validation logic into `validateStallPlacement` in `MainViewModel.kt`. This ensures that all rules—including enemy proximity, path blocking, and the 'Tray Return Uncle' neighbor rule—are consistently enforced when placing a new stall or using the 'undo sell' feature. Previously, `undoSell` lacked these checks, which could lead to illegal game states. Changes: - Added `validateStallPlacement` helper in `MainViewModel.kt`. - Updated `onCellClick` and `undoSell` to use the helper. - Added `UndoPathBlockTest.kt` to verify pathing and Uncle rule enforcement during undo. - Updated `UndoUncleTeleportTest.kt` to comply with stricter placement rules. - Logged fix as FIX-014 in `fixes.md`. 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 (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthrough
ChangesStall Placement Validation Centralization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2c4ca824-1daa-4060-adec-7e5e42dc4840
📒 Files selected for processing (4)
app/src/main/java/com/messark/hawker/MainViewModel.ktapp/src/test/java/com/messark/hawker/UndoPathBlockTest.ktapp/src/test/java/com/messark/hawker/UndoUncleTeleportTest.ktfixes.md
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
|
[MAJOR] Suggested test setup adjustment...[MINOR] |
Thank you for the feedback. I have updated the |
- Updated `UndoPathBlockTest.kt` to include start and end positions in the hex map for the Tray Return Uncle rule test, ensuring it isolates the intended failure path. - Corrected the resolution date for FIX-014 in `fixes.md` to the actual date (2026-05-20). Co-authored-by: candour <4670475+candour@users.noreply.github.com>
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
I have fixed a bug in the
undoSellmechanic where players could restore a sold stall even if it blocked the main path or left a Tray Return Uncle without any walkable neighbors.To solve this, I centralized the stall placement validation logic into a new private method
validateStallPlacementwithinMainViewModel.kt. This method now handles all placement-related checks:Both
onCellClick(for new stalls) andundoSell(for restoring sold stalls) now call this centralized validation. I also added a comprehensive unit test suiteUndoPathBlockTest.ktto cover these scenarios and updated existing tests to ensure they provide valid board configurations. Finally, I documented the fix infixes.md.PR created automatically by Jules for task 11469130489472164888 started by @candour
Summary by CodeRabbit
Bug Fixes
Tests
Documentation