Skip to content

Fix Tray Return Uncle placement validation for DRAIN tiles#145

Merged
candour merged 1 commit into
mainfrom
fix/tray-uncle-placement-drain-7489954040297907364
May 11, 2026
Merged

Fix Tray Return Uncle placement validation for DRAIN tiles#145
candour merged 1 commit into
mainfrom
fix/tray-uncle-placement-drain-7489954040297907364

Conversation

@candour

@candour candour commented May 11, 2026

Copy link
Copy Markdown
Owner

I have fixed a bug in the Tray Return Uncle placement validation logic. Previously, the check only considered FLOOR tiles as valid release points, ignoring DRAIN tiles which are also walkable and buildable. This caused valid placement attempts to be rejected if only drains were available adjacent to the Uncle.

I have:

  • Updated the placement rule in MainViewModel.kt to include DRAIN tiles.
  • Added a new unit test TrayUncleDrainTest.kt to reproduce and verify the fix.
  • Verified that all related tests pass.
  • Recorded the fix in fixes.md as FIX-006.

PR created automatically by Jules for task 7489954040297907364 started by @candour

Summary by CodeRabbit

  • Bug Fixes

    • Fixed stall placement validation to recognize drain tiles as valid adjacent walkable areas, improving placement flexibility in constrained spaces.
  • Tests

    • Added test coverage validating stall placement behavior with adjacent drain tile configurations.

Review Change Stack

Modified onCellClick in MainViewModel.kt to include TileType.DRAIN
as a valid walkable tile when checking for available release points
for the Tray Return Uncle stall. This ensures consistency with the
actual release logic in releaseEnemy and prevents invalid placement
rejections.

Added TrayUncleDrainTest.kt to verify the fix and updated fixes.md.

Co-authored-by: candour <4670475+candour@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updates TRAY_RETURN_UNCLE stall placement validation to treat TileType.DRAIN as walkable alongside TileType.FLOOR when checking neighbor availability. Adds a corresponding unit test and fix documentation.

Changes

TRAY_RETURN_UNCLE DRAIN Walkability

Layer / File(s) Summary
Neighbor Validation Logic
app/src/main/java/com/messark/hawker/MainViewModel.kt
TRAY_RETURN_UNCLE placement now accepts DRAIN tiles as valid walkable neighbors (alongside FLOOR) when validating the "last empty space" rule, changing the neighbor filtering condition from FLOOR-only to FLOOR or DRAIN.
Test Validation
app/src/test/java/com/messark/hawker/TrayUncleDrainTest.kt
New test class validates placement succeeds when target is FLOOR with one adjacent DRAIN neighbor and other neighbors blocked by pillars. Test uses mocked repositories, deterministic coroutine dispatcher, and hex grid fixture.
Fix Documentation
fixes.md
FIX-006 entry documents the update to MainViewModel TRAY_RETURN_UNCLE placement validation to treat DRAIN tiles as walkable hexes, aligning with releaseEnemy behavior.

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • candour/towerpower#138: Introduces TileType.DRAIN and its core gameplay handling, which this PR builds upon by allowing DRAIN as a valid walkable neighbor.
  • candour/towerpower#117: Previously modified TRAY_RETURN_UNCLE placement logic to relax which neighboring TileTypes count as valid release spots.
  • candour/towerpower#70: Original introduction of TRAY_RETURN_UNCLE stall and its "last empty space" placement validation logic.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: fixing Tray Return Uncle placement validation to support DRAIN tiles, which aligns with the core code modification in MainViewModel.kt and the test addition.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tray-uncle-placement-drain-7489954040297907364

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/src/main/java/com/messark/hawker/MainViewModel.kt (1)

957-960: ⚡ Quick win

Good fix; consider centralizing release-tile eligibility to avoid future drift.

This change fixes the DRAIN gap. To prevent the same mismatch recurring, extract the “valid release tile” rule into a shared helper and reuse it here and in releaseEnemy.

Proposed refactor
+    private fun isValidTrayReleaseTile(
+        coord: AxialCoordinate,
+        tile: HexTile,
+        blocked: Set<AxialCoordinate>
+    ): Boolean {
+        val isWalkableFloor = (tile.type == TileType.FLOOR || tile.type == TileType.DRAIN) && coord !in blocked
+        return isWalkableFloor || tile.type == TileType.START || tile.type == TileType.GOAL_TABLE
+    }
...
-                        val isWalkableFloor = (neighborTile.type == TileType.FLOOR || neighborTile.type == TileType.DRAIN) && !blocked.contains(it)
-                        it != coord && (isWalkableFloor ||
-                                neighborTile.type == TileType.START ||
-                                neighborTile.type == TileType.GOAL_TABLE)
+                        it != coord && isValidTrayReleaseTile(it, neighborTile, blocked)

As per coding guidelines, "Implement DRAIN tile variant as walkable and buildable floor tile rendered with 30% width Color.DarkGray square and black grill lines in center in GameBoard.kt".


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 62658a12-78b9-47b7-943b-7e9d55262935

📥 Commits

Reviewing files that changed from the base of the PR and between c2283cc and e1aebf7.

📒 Files selected for processing (3)
  • app/src/main/java/com/messark/hawker/MainViewModel.kt
  • app/src/test/java/com/messark/hawker/TrayUncleDrainTest.kt
  • fixes.md

@github-actions

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

Note: This link will be removed when the PR is closed.

@candour
candour merged commit e7d5797 into main May 11, 2026
3 checks passed
@candour
candour deleted the fix/tray-uncle-placement-drain-7489954040297907364 branch May 11, 2026 04:36
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.

1 participant