Skip to content

Fix enemy death threshold logic - #161

Merged
candour merged 1 commit into
mainfrom
fix-enemy-death-threshold-12605285028550738522
May 16, 2026
Merged

Fix enemy death threshold logic#161
candour merged 1 commit into
mainfrom
fix-enemy-death-threshold-12605285028550738522

Conversation

@candour

@candour candour commented May 16, 2026

Copy link
Copy Markdown
Owner

Corrected a bug in the game engine where enemies were being removed from play when their health dropped below 1.0f. This was likely a leftover from an earlier implementation using integer health. Since health is now tracked as a Float, enemies should only be considered dead when their health reaches zero or below. This ensures that stalls dealing small amounts of damage or fractional damage due to buffs (like the Tiger Mom's armor) correctly deplete the enemy's entire health pool before they are removed.

Key changes:

  • Updated handleProjectiles in MainViewModel.kt to use currentHealth <= 0f.
  • Updated UndeadEnemyTest.kt to use a starting health of 0.5f to confirm that fractional health no longer triggers immediate death.
  • Added an entry for FIX-011 in fixes.md.

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

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed enemy death detection to correctly identify enemies as defeated when their health reaches zero, resolving an issue where enemies with minimal health could be incorrectly treated as alive during combat.

Review Change Stack

Modified the enemy death condition from `currentHealth < 1.0f` to `currentHealth <= 0f` to ensure precise health tracking and prevent premature deaths when using floating-point health values.
Updated `UndeadEnemyTest.kt` to verify this behavior and recorded the fix as FIX-011 in `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 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR corrects enemy death detection in projectile handling. The threshold check changes from currentHealth < 1.0f to currentHealth <= 0f across three related decision points (early skip, kill attribution, and enemy removal), with a corresponding test update and changelog entry.

Changes

Enemy Death Threshold Fix

Layer / File(s) Summary
Death threshold logic and test validation
app/src/main/java/com/messark/hawker/MainViewModel.kt, app/src/test/java/com/messark/hawker/UndeadEnemyTest.kt
MainViewModel.handleProjectiles adjusts the enemy death threshold from currentHealth < 1.0f to currentHealth <= 0f in three places: skipping dead enemies, computing kill attribution, and deciding whether to remove the enemy and award gold/score. Test fixture health updated from 1f to 0.5f to validate the threshold.
Bugfix changelog entry
fixes.md
FIX-011 documents the MainViewModel.kt death-threshold correction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • candour/towerpower#133: Both PRs modify MainViewModel.handleProjectiles's enemy death/kill-credit logic (the currentHealth threshold used to decide when enemies are treated as dead and when kills are attributed to the firing stall).
  • candour/towerpower#101: Both PRs modify MainViewModel.handleProjectiles death/kill logic for "undead" enemies by changing how health is evaluated and update/add UndeadEnemyTest accordingly.
  • candour/towerpower#141: Both PRs adjust MainViewModel.handleProjectiles' floating-point enemy death/kill threshold logic, highlighting the same inconsistency in combat handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 'Fix enemy death threshold logic' is clear and directly summarizes the main change: correcting the enemy death detection condition from 1.0f to 0f.
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-enemy-death-threshold-12605285028550738522

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

Build Successful! 🚀

Download APK

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

@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)
fixes.md (1)

42-42: 💤 Low value

Consider clarifying the comparison operator change in the description.

The description states the threshold changed "from 1.0f to 0f", but the actual code change is from < 1.0f to <= 0f. Both the threshold value and the comparison operator changed. Consider updating to "from < 1.0f to <= 0f" for precision.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e5d9ceb1-34f5-4ac3-a458-d28dd80797e5

📥 Commits

Reviewing files that changed from the base of the PR and between 5257656 and dd47b67.

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

@candour
candour merged commit 997992e into main May 16, 2026
3 checks passed
@candour
candour deleted the fix-enemy-death-threshold-12605285028550738522 branch May 16, 2026 04:24
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