Skip to content

Fix ATM passive income and improve iteration safety - #132

Merged
candour merged 2 commits into
mainfrom
fix-atm-passive-income-15518195651156498222
May 8, 2026
Merged

Fix ATM passive income and improve iteration safety#132
candour merged 2 commits into
mainfrom
fix-atm-passive-income-15518195651156498222

Conversation

@candour

@candour candour commented May 8, 2026

Copy link
Copy Markdown
Owner

Fixes a logic bug where ATM stalls would provide passive income even if they were disabled (e.g., due to an upgrade). The fix ensures income is only collected if the stall was enabled throughout the wave. It also improves iteration safety during the wave completion phase.


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

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed an issue where ATM passive income was incorrectly awarded based on its post-wave state rather than its active state during the wave. Income now correctly awards only when the ATM is enabled throughout the wave.

Modified MainViewModel.kt to check if an ATM stall was enabled during
the wave before awarding passive income. The logic now snapshots the
set of enabled stalls before decrementing their 'disabledWaves'
counters. This ensures that stalls disabled by upgrades do not pay
out for that wave, while still allowing stalls re-enabled in the same
tick (like Bak Kut Teh) to provide their bonuses to the payout amount.

Additionally, added toList() to the iteration over updatedHexes during
wave completion to ensure safety against concurrent modifications and
added a comprehensive regression test in AtmDisabledTest.kt.

Fixes: FIX-003

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 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Rate limit exceeded

@candour has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 48 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2d4294a-b0e9-4afa-ad66-939608b71da2

📥 Commits

Reviewing files that changed from the base of the PR and between 25c5282 and cd1c1d0.

📒 Files selected for processing (2)
  • app/src/test/java/com/messark/hawker/AtmDisabledTest.kt
  • app/src/test/java/com/messark/hawker/BakKutTehSameTickTest.kt
📝 Walkthrough

Walkthrough

The PR fixes an ATM passive income bug where disabled stalls were incorrectly contributing income. Wave completion now snapshots which stalls were enabled before decrementing their disabledWaves counter, then checks income eligibility against that snapshot rather than the post-decrement state. Test coverage validates both disabled and enabled scenarios, and a changelog entry documents the fix.

Changes

ATM Income Eligibility Fix

Layer / File(s) Summary
Core Logic Fix
app/src/main/java/com/messark/hawker/MainViewModel.kt
Wave completion captures previouslyEnabledStalls snapshot before decrementing disabledWaves, then gates ATM passive income collection against the pre-decrement snapshot while applying state updates.
Test Coverage
app/src/test/java/com/messark/hawker/AtmDisabledTest.kt
Two test cases assert that ATM with disabledWaves=1 does not contribute income and decrements its counter, while ATM with disabledWaves=0 contributes expected gold.
Documentation
fixes.md
Changelog entry documents ATM passive income eligibility fix and iteration safety improvement via toList().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • candour/towerpower#105: Adds ATM passive income aggregation logic; this PR refines the eligibility snapshot to use pre-decrement state.
  • candour/towerpower#126: Modifies MainViewModel wave-completion hex-grid handling for ATM income and stat boost calculations.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 PR title directly matches the main changes: fixing ATM passive income logic and improving iteration safety during wave completion.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-atm-passive-income-15518195651156498222

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ff9b5a8d-ce7d-4ca4-bcd5-21523171687c

📥 Commits

Reviewing files that changed from the base of the PR and between 2ccd3d0 and 25c5282.

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

Comment thread app/src/test/java/com/messark/hawker/AtmDisabledTest.kt
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

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

@candour
candour enabled auto-merge (squash) May 8, 2026 04:26
@candour

candour commented May 8, 2026

Copy link
Copy Markdown
Owner Author

Add Dispatchers.resetMain() teardown to avoid test dispatcher leakage.

Dispatchers.setMain(testDispatcher) is set in the @before setup but never reset, which can pollute other tests in the same JVM run.

@google-labs-jules

Copy link
Copy Markdown
Contributor

Add Dispatchers.resetMain() teardown to avoid test dispatcher leakage.

Dispatchers.setMain(testDispatcher) is set in the @before setup but never reset, which can pollute other tests in the same JVM run.

Thank you for the feedback. I've added Dispatchers.resetMain() to the tearDown methods of AtmDisabledTest and BakKutTehSameTickTest to prevent dispatcher leakage.

Added @after tearDown methods with Dispatchers.resetMain() to
AtmDisabledTest and BakKutTehSameTickTest to avoid test dispatcher
leakage across test runs.

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

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

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

@candour
candour disabled auto-merge May 8, 2026 05:41
@candour
candour enabled auto-merge (squash) May 8, 2026 05:41
@candour

candour commented May 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai resolve

@candour
candour merged commit cc4a70e into main May 8, 2026
3 checks passed
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Comments resolved and changes approved.

@candour
candour deleted the fix-atm-passive-income-15518195651156498222 branch May 8, 2026 05:42
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