Skip to content

Fix Tiger Mom buff delay and UpgradeOverlay refactor#134

Merged
candour merged 1 commit into
mainfrom
fix-tiger-mom-buff-delay-944813144424530300
May 9, 2026
Merged

Fix Tiger Mom buff delay and UpgradeOverlay refactor#134
candour merged 1 commit into
mainfrom
fix-tiger-mom-buff-delay-944813144424530300

Conversation

@candour
Copy link
Copy Markdown
Owner

@candour candour commented May 9, 2026

This PR addresses several minor issues:

  1. Tiger Mom Buff Cleanup: Fixed a logic bug in the projectile handling loop where armor buffs were not being removed immediately when a Tiger Mom died. This was because the cleanup logic was using an initial enemy lookup instead of the updated list of surviving enemies.
  2. UI Deduplication: Refactored UpgradeOverlay.kt to use StallUpgradeManager for retrieving available upgrade categories, ensuring the UI is always in sync with the game logic and reducing duplication.
  3. Compiler Warning: Removed a redundant tile.stall == null check in MainViewModel.kt that was triggering a 'Condition is always true' warning.
  4. Maintenance: Recorded the changes in fixes.md.

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

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Fixed buff and armor cleanup logic following projectile impacts. Defeated enemies no longer leave stale buff relationships that could corrupt game state and negatively impact subsequent gameplay. This improves battle consistency and reliability.
  • Streamlined stall placement validation by removing redundant checks, enhancing code efficiency without affecting functionality.

- Fixed a bug in `MainViewModel.kt` where enemy buffs were cleaned up using a stale lookup map, causing a delay in removing buffs when a source enemy (like Tiger Mom) died.
- Deduplicated `availableStats` in `UpgradeOverlay.kt` by using `StallUpgradeManager.getAvailableUpgradeStats(stall)`.
- Removed a redundant null check in `MainViewModel.onCellClick` to eliminate a compiler warning.
- Updated `fixes.md` with FIX-004.

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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR addresses three related bugs and a refactoring: projectile impact buff cleanup now filters against surviving enemies to prevent stale buff relationships; upgrade stat selection is extracted from UpgradeOverlay to StallUpgradeManager; a redundant null check is removed from stall placement logic.

Changes

Bug Fixes and Upgrade Stats Refactoring

Layer / File(s) Summary
Projectile Impact Buff Cleanup
app/src/main/java/com/messark/hawker/MainViewModel.kt
Post-hit enemy processing derives fullyUpdatedEnemies by filtering each enemy's buffs against a lookup of surviving enemies, ensuring buffs with dead sources are removed before updating GameState.
Upgrade Stats Extraction to Manager
app/src/main/java/com/messark/hawker/ui/components/UpgradeOverlay.kt
UpgradeOverlay now calls StallUpgradeManager.getAvailableUpgradeStats(stall) instead of using inline hardcoded when (stall.stallType) mapping.
Condition Simplification
app/src/main/java/com/messark/hawker/MainViewModel.kt
Removed redundant tile.stall == null guard from stall placement condition, as the code path already implies an empty tile.
Fix Documentation
fixes.md
Added FIX-004 entry documenting Tiger Mom buff cleanup, upgrade stats deduplication, and null-check removal.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • candour/towerpower#91: Introduced Tiger Mom armor-buff cleanup logic that this PR directly fixes.
  • candour/towerpower#128: Refactored StallUpgradeManager API that UpgradeOverlay now calls for available stats.
  • candour/towerpower#132: Also modifies MainViewModel.updateGame for timing and iteration safety in the same function.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 accurately summarizes the two main changes: fixing Tiger Mom buff cleanup timing and refactoring UpgradeOverlay to use StallUpgradeManager.
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-tiger-mom-buff-delay-944813144424530300

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Build Successful! 🚀

Download APK

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
app/src/main/java/com/messark/hawker/ui/components/UpgradeOverlay.kt (3)

70-70: ⚡ Quick win

Replace hardcoded colors with MaterialTheme.colorScheme.

The hardcoded green color Color(0xFF4CAF50) violates the coding guideline to avoid hardcoding colors in UI components. Use theme colors to support light and dark themes consistently.

🎨 Proposed fix to use theme colors

For the free upgrade message (line 70):

                    Text(
                        text = "Free specific upgrade active ($freeUpgradeCount remaining)! This upgrade will cost $0 and will not cause a shutdown.",
-                       color = Color(0xFF4CAF50),
+                       color = MaterialTheme.colorScheme.primary,
                        fontSize = 12.sp,

For the button background (line 144):

    Surface(
-       color = if (enabled) Color(0xFF4CAF50) else MaterialTheme.colorScheme.surfaceVariant,
+       color = if (enabled) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.surfaceVariant,
        shape = RoundedCornerShape(8.dp),

As per coding guidelines, avoid hardcoding colors in UI components; always prefer MaterialTheme.colorScheme to support light and dark themes.

Also applies to: 144-144


155-156: ⚡ Quick win

Replace hardcoded Color.White with theme colors.

Hardcoded Color.White should be replaced with MaterialTheme.colorScheme.onPrimary to ensure proper contrast and theme support.

🎨 Proposed fix
        Row(
            modifier = Modifier.padding(12.dp),
            horizontalArrangement = Arrangement.SpaceBetween,
            verticalAlignment = Alignment.CenterVertically
        ) {
-           Text(text = label, color = Color.White, fontWeight = FontWeight.Bold)
-           Text(text = "$$cost", color = Color.White, fontWeight = FontWeight.Bold)
+           Text(text = label, color = MaterialTheme.colorScheme.onPrimary, fontWeight = FontWeight.Bold)
+           Text(text = "$$cost", color = MaterialTheme.colorScheme.onPrimary, fontWeight = FontWeight.Bold)
        }

As per coding guidelines, avoid hardcoding colors in UI components; always prefer MaterialTheme.colorScheme to support light and dark themes.


137-159: ⚖️ Poor tradeoff

Consider using SpriteButton for consistency.

The coding guidelines specify using SpriteButton for all action buttons and referencing buttons.png for visual consistency. The custom UpgradeButton composable may lead to inconsistent styling across the app.

As per coding guidelines, use SpriteButton for all action buttons and reference buttons.png for visual consistency.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9be0297e-b659-47d9-9526-8988256dd0b4

📥 Commits

Reviewing files that changed from the base of the PR and between 684e0c9 and 7fd3658.

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

@candour candour merged commit 8ada4ac into main May 9, 2026
3 checks passed
@candour candour deleted the fix-tiger-mom-buff-delay-944813144424530300 branch May 9, 2026 04:43
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