Correct base stats in Registry to match documentation - #187
Conversation
- Updated Chicken Rice base damage to 10f (from 20f) - Updated Durian base damage to 150f (from 100f) - Updated Tiger Mom base HP to 80f (from 60f) - Added RegistryStatsTest.kt to verify these values and prevent regressions - Updated fixes.md with FIX-017 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. |
📝 WalkthroughWalkthroughThis PR adjusts gameplay balance by updating three entity stats in the registry (Chicken Rice damage reduced, Durian damage increased, Tiger Mom HP increased), adds JUnit tests to verify the new values, and documents the changes in the changelog. ChangesGameplay balance adjustments
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 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 |
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f29ead9-a195-42db-b3f7-f705b9b56b4c
📒 Files selected for processing (3)
app/src/main/java/com/messark/hawker/registry/Registry.ktapp/src/test/java/com/messark/hawker/RegistryStatsTest.ktfixes.md
| fun testChickenRiceBaseDamage() { | ||
| val def = StallRegistry.get(StallType.CHICKEN_RICE) | ||
| // STALL_STATS.md says Chicken Rice base damage should be 10 | ||
| assertEquals("Chicken Rice base damage should be 10", 10f, def.damage) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if the test file compiles and verify JUnit assertEquals signature for floats
# Try to compile the test file
./gradlew :app:compileDebugUnitTestKotlin 2>&1 | grep -A5 -B5 "RegistryStatsTest"
# Search for JUnit version in gradle files
rg -n "junit" --glob "*build.gradle*" -C2Repository: candour/towerpower
Length of output: 866
🏁 Script executed:
#!/bin/bash
set -e
# 1) Show the exact test code around the assertion and capture any imports (for JUnit vs kotlin.test)
FILE="app/src/test/java/com/messark/hawker/RegistryStatsTest.kt"
echo "---- $FILE (lines 1-80) ----"
nl -ba "$FILE" | sed -n '1,120p'
# 2) Confirm where assertEquals comes from (imports)
echo
echo "---- assertEquals references (file-local) ----"
rg -n "assertEquals\(" "$FILE" || true
rg -n "^import .*assertEquals" "$FILE" || true
# 3) Compile unit tests (should fail if the overload is invalid)
echo
echo "---- Running compileDebugUnitTestKotlin ----"
./gradlew :app:compileDebugUnitTestKotlin --no-daemon 2>&1 | tail -n 60
# 4) Determine JUnit version/type from gradle version catalog or build files
echo
echo "---- JUnit dependency resolution hints ----"
rg -n "libs\.junit|junit[:]" gradle* settings.gradle* build.gradle* gradle/libs.versions.toml app/build.gradle* 2>/dev/null || true
ls -la gradle || true
if [ -f gradle/libs.versions.toml ]; then
echo
echo "---- gradle/libs.versions.toml (junit entries) ----"
rg -n "junit" gradle/libs.versions.toml -n || true
fiRepository: candour/towerpower
Length of output: 6150
🏁 Script executed:
#!/bin/bash
set -e
# Locate RegistryStatsTest
FILE="app/src/test/java/com/messark/hawker/RegistryStatsTest.kt"
test -f "$FILE" && echo "Found $FILE" || (echo "Missing $FILE" && exit 1)
echo "---- RegistryStatsTest.kt around assertions ----"
sed -n '1,120p' "$FILE" | nl -ba | sed -n '1,120p' || sed -n '1,120p' "$FILE"
echo
echo "---- Determine type of def and def.damage ----"
# Find StallRegistry.get signature usage in codebase
rg -n "object StallRegistry|class StallRegistry|fun get\\(" app/src/main -S || true
# Find StallType.CHICKEN_RICE usages
rg -n "StallType\\.CHICKEN_RICE" app/src -S || true
# Find the definition of damage field on the registry entry type
rg -n "data class .*damage|val damage|var damage" app/src/main -S || true
# Specifically look for StallRegistry return type or registry entry model
rg -n "StallRegistry\\.get\\(" app/src/main app/src/test -S || true
# Print StallRegistry file(s)
fd -a "StallRegistry" app/src/main -t f || true
fd -a "StallRegistry" app/src/test -t f || trueRepository: candour/towerpower
Length of output: 9288
🏁 Script executed:
#!/bin/bash
set -e
FILE="app/src/test/java/com/messark/hawker/RegistryStatsTest.kt"
test -f "$FILE" || { echo "Missing $FILE"; exit 1; }
echo "---- RegistryStatsTest.kt (first 120 lines) ----"
sed -n '1,120p' "$FILE" | cat -n
echo
echo "---- Find StallRegistry definition and get() signature ----"
rg -n "class StallRegistry|object StallRegistry|fun get\\(.*StallType" app/src/main -S || true
echo
echo "---- Locate StallType.CHICKEN_RICE ----"
rg -n "StallType\\.CHICKEN_RICE" app/src -S || true
echo
echo "---- Find model/entry fields containing 'damage' near StallRegistry ----"
rg -n "val damage|var damage|damage:" app/src/main -S || true
echo
echo "---- Find StallRegistry.get call sites ----"
rg -n "StallRegistry\\.get\\(" app/src/main app/src/test -S || trueRepository: candour/towerpower
Length of output: 11177
🏁 Script executed:
#!/bin/bash
set -e
FILE="app/src/test/java/com/messark/hawker/RegistryStatsTest.kt"
test -f "$FILE" || { echo "Missing $FILE"; exit 1; }
echo "---- RegistryStatsTest.kt (first 120 lines) ----"
sed -n '1,120p' "$FILE" | cat -n
echo
echo "---- Find StallRegistry definition and get() signature ----"
rg -n "class StallRegistry|object StallRegistry|fun get\\(.*StallType" app/src/main -S || true
echo
echo "---- Locate StallType.CHICKEN_RICE ----"
rg -n "StallType\\.CHICKEN_RICE" app/src -S || true
echo
echo "---- Find model/entry fields containing 'damage' ----"
rg -n "val damage|var damage|damage:" app/src/main -S || true
echo
echo "---- Find StallRegistry.get call sites ----"
rg -n "StallRegistry\\.get\\(" app/src/main app/src/test -S || trueRepository: candour/towerpower
Length of output: 11158
🏁 Script executed:
#!/bin/bash
set -e
# Find other JUnit float assertEquals usages (with/without delta)
rg -n "assertEquals\\(.*\\b\\d+f\\b.*\\bdef\\.|assertEquals\\(.*\\b\\d+f\\b.*\\b.*\\b" app/src/test/java -S || true
rg -n "assertEquals\\(.*\\bFloat\\b|assertEquals\\(.*\\bfloat\\b" app/src/test/java -S || true
rg -n "assertEquals\\(.*\\,.*\\,.*\\,.*\\)" app/src/test/java -S | head -n 80 || true
# Specifically check for assertEquals(String, float, float, delta) style
rg -n "assertEquals\\([^\\)]*\\,\\s*[^\\,\\)]*f\\s*,\\s*[^\\,\\)]*\\s*,\\s*[^\\)]*f\\s*\\)" app/src/test/java -S || true
rg -n "assertEquals\\([^\\)]*\\,\\s*[^\\,\\)]*f\\s*,\\s*[^\\,\\)]*\\s*\\)" app/src/test/java -S || trueRepository: candour/towerpower
Length of output: 1120
🏁 Script executed:
#!/bin/bash
set -e
# Inspect surrounding code + imports for the other float assertEquals hits
for f in \
app/src/test/java/com/messark/hawker/StallStatsTest.kt \
app/src/test/java/com/messark/hawker/MilestoneBoostTest.kt \
app/src/test/java/com/messark/hawker/RegistryStatsTest.kt
do
echo "==================== $f (imports + around assertEquals hits) ===================="
sed -n '1,80p' "$f" | cat -n
echo "--- assertEquals lines ---"
rg -n "assertEquals\\(" "$f"
echo "--- context ---"
rg -n "assertEquals\\(" -n -C 3 "$f" || true
done
# Count how many float assertEquals calls include a delta parameter in this test tree
echo "==================== float assertEquals with delta (heuristic) ===================="
# Match: assertEquals( ... <float_literal>f, ... <float_expr>, <float_literal>f )
rg -n "assertEquals\\([^\\n\\)]*f\\s*,[^\\n\\)]*f\\s*,[^\\n\\)]*f" app/src/test/java -S || true
# List all assertEquals lines in RegistryStatsTest for completeness
echo "==================== RegistryStatsTest assertEquals ==="
rg -n "assertEquals\\(" app/src/test/java/com/messark/hawker/RegistryStatsTest.kt -S || trueRepository: candour/towerpower
Length of output: 13226
🏁 Script executed:
#!/bin/bash
set -e
FILE="app/src/main/java/com/messark/hawker/registry/Registry.kt"
test -f "$FILE" || { echo "Missing $FILE"; exit 1; }
echo "---- StallDefinition damage type ----"
# Show StallDefinition data class/interface block around the 'damage: Float' field
rg -n "val damage: Float|data class StallDefinition|class StallDefinition" "$FILE"
# Print around the 'damage: Float' line
ln=$(rg -n "val damage: Float" "$FILE" | head -n1 | cut -d: -f1)
start=$((ln-30)); end=$((ln+30))
sed -n "${start},${end}p" "$FILE" | nl -ba | head -n 120
echo
echo "---- StallRegistry CHICKEN_RICE definition ----"
# Print around the CHICKEN_RICE entry in the registry map
rg -n "StallType\\.CHICKEN_RICE to StallDefinition\\(" "$FILE" || true
ln2=$(rg -n "StallType\\.CHICKEN_RICE to StallDefinition\\(" "$FILE" | head -n1 | cut -d: -f1)
start2=$((ln2-10)); end2=$((ln2+60))
sed -n "${start2},${end2}p" "$FILE" | nl -ba | head -n 120
echo
echo "---- Enemy baseHp type and TIGER_MOM definition ----"
# show EnemyDefinition baseHp type
rg -n "val baseHp: Float|baseHp: Float|EnemyDefinition" "$FILE"
ln3=$(rg -n "val baseHp: Float" "$FILE" | head -n1 | cut -d: -f1 || true)
if [ -n "${ln3:-}" ]; then
start3=$((ln3-20)); end3=$((ln3+30))
sed -n "${start3},${end3}p" "$FILE" | nl -ba | head -n 120
fi
# search for TIGER_MOM in registry file
rg -n "EnemyType\\.TIGER_MOM" "$FILE" || true
ln4=$(rg -n "EnemyType\\.TIGER_MOM" "$FILE" | head -n1 | cut -d: -f1 || true)
if [ -n "${ln4:-}" ]; then
start4=$((ln4-10)); end4=$((ln4+40))
sed -n "${start4},${end4}p" "$FILE" | nl -ba | head -n 120
fiRepository: candour/towerpower
Length of output: 990
🏁 Script executed:
#!/bin/bash
set -e
# 1) Show the exact registry literals
FILE="app/src/main/java/com/messark/hawker/registry/Registry.kt"
echo "---- StallType.CHICKEN_RICE entry ----"
sed -n '410,460p' "$FILE" | cat -n
echo
echo "---- EnemyType.TIGER_MOM entry ----"
sed -n '540,600p' "$FILE" | cat -n
# 2) Compile unit tests without daemon to avoid daemon connectivity issues
echo
echo "---- Running compileDebugUnitTestKotlin with --no-daemon ----"
./gradlew :app:compileDebugUnitTestKotlin --no-daemon --stacktrace 2>&1 | tail -n 80Repository: candour/towerpower
Length of output: 15512
🌐 Web query:
JUnit 4.13.2 org.junit.Assert assertEquals(String,float,float) overload
💡 Result:
In JUnit 4.13.2, the org.junit.Assert class does not provide a direct overload for assertEquals(String, float, float) [1][2][3]. For floating-point comparisons, JUnit requires an explicit delta to account for precision issues [2][4]. The available methods for comparing two floats are: 1. assertEquals(String message, float expected, float actual, float delta) [2][3] 2. assertEquals(float expected, float actual, float delta) [2][3] In both cases, the delta parameter represents the maximum allowed difference between the expected and actual values for the assertion to be considered a pass [2][3]. If you attempt to use a method signature without a delta, you will typically find it does not exist for float types in the API, unlike the deprecated double-precision methods that previously omitted the delta (e.g., assertEquals(String, double, double)) [2][5]. If you are currently trying to compare floats without a delta, you must update your code to include one, such as: Assert.assertEquals("Optional error message", 1.0f, 1.0001f, 0.001f);
Citations:
- 1: https://junit.org/junit4/javadoc/4.13.2/src-html/org/junit/Assert.html
- 2: https://junit.org/junit4/javadoc/4.13/org/junit/Assert.html
- 3: https://github.com/junit-team/junit4/blob/main/src/main/java/org/junit/Assert.java
- 4: https://junit.org/junit4/javadoc/4.11/org/junit/Assert.html
- 5: https://junit.org/junit4/javadoc/latest/deprecated-list.html
🌐 Web query:
JUnit 4.13.2 org.junit.Assert assertEquals(String, Object, Object) and assertEquals(String, double, double) overloads
💡 Result:
JUnit 4.13.2 org.junit.Assert has these overloads: 1) assertEquals(String, Object, Object) - Signature: public static void assertEquals(String message, Object expected, Object actual) - Meaning: Asserts two objects are equal; if they are not, throws AssertionError with the given message. If expected and actual are both null, they are considered equal.[1] 2) assertEquals(String, double, double) - Signature: public static void assertEquals(String message, double expected, double actual) - Status: Deprecated. - Meaning/alternative: Javadoc marks it as “Deprecated. Use assertEquals(String message, double expected, double actual, double delta) instead”.[2] Practical guidance: For doubles (especially when comparing non-integers), prefer assertEquals(String, double, double, double delta), which asserts equality within a positive delta.[3]
Citations:
- 1: https://junit.org/junit4/javadoc/4.13.2/src-html/org/junit/Assert.html
- 2: https://junit.org/junit4/javadoc/4.13.2/deprecated-list.html
- 3: https://junit.org/junit4/javadoc/4.13/org/junit/Assert.html
Add delta to float assertEquals in RegistryStatsTest
org.junit.Assert.assertEquals (JUnit 4.13.2) doesn’t provide assertEquals(String, float, float); this assertion will fall back to a less-ideal overload (deprecated/boxed) rather than using an explicit float tolerance. Add a delta to prevent precision-related flakiness and avoid deprecation (apply the same change to the Durian and Tiger Mom assertions in the file too).
🔧 Proposed fix
- assertEquals("Chicken Rice base damage should be 10", 10f, def.damage)
+ assertEquals("Chicken Rice base damage should be 10", 10f, def.damage, 0.01f)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fun testChickenRiceBaseDamage() { | |
| val def = StallRegistry.get(StallType.CHICKEN_RICE) | |
| // STALL_STATS.md says Chicken Rice base damage should be 10 | |
| assertEquals("Chicken Rice base damage should be 10", 10f, def.damage) | |
| } | |
| fun testChickenRiceBaseDamage() { | |
| val def = StallRegistry.get(StallType.CHICKEN_RICE) | |
| // STALL_STATS.md says Chicken Rice base damage should be 10 | |
| assertEquals("Chicken Rice base damage should be 10", 10f, def.damage, 0.01f) | |
| } |
| fun testDurianBaseDamage() { | ||
| val def = StallRegistry.get(StallType.DURIAN) | ||
| // STALL_STATS.md says Durian base damage should be 150 | ||
| assertEquals("Durian base damage should be 150", 150f, def.damage) | ||
| } |
There was a problem hiding this comment.
Add delta parameter to float assertEquals.
Same issue as testChickenRiceBaseDamage: the delta parameter is required for float comparisons in JUnit.
🔧 Proposed fix
- assertEquals("Durian base damage should be 150", 150f, def.damage)
+ assertEquals("Durian base damage should be 150", 150f, def.damage, 0.01f)| fun testTigerMomBaseHp() { | ||
| val def = EnemyRegistry.get(EnemyType.TIGER_MOM) | ||
| // CUSTOMER_STATS.md says Tiger Mom base HP should be 80 | ||
| assertEquals("Tiger Mom base HP should be 80", 80f, def.baseHp) | ||
| } |
There was a problem hiding this comment.
Add delta parameter to float assertEquals.
Same issue: JUnit requires a delta parameter for float assertions.
🔧 Proposed fix
- assertEquals("Tiger Mom base HP should be 80", 80f, def.baseHp)
+ assertEquals("Tiger Mom base HP should be 80", 80f, def.baseHp, 0.01f)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fun testTigerMomBaseHp() { | |
| val def = EnemyRegistry.get(EnemyType.TIGER_MOM) | |
| // CUSTOMER_STATS.md says Tiger Mom base HP should be 80 | |
| assertEquals("Tiger Mom base HP should be 80", 80f, def.baseHp) | |
| } | |
| fun testTigerMomBaseHp() { | |
| val def = EnemyRegistry.get(EnemyType.TIGER_MOM) | |
| // CUSTOMER_STATS.md says Tiger Mom base HP should be 80 | |
| assertEquals("Tiger Mom base HP should be 80", 80f, def.baseHp, 0.01f) | |
| } |
I identified an inconsistency between the game engine's registry and the provided documentation (STALL_STATS.md and CUSTOMER_STATS.md). I have corrected the base stats for Chicken Rice, Durian, and Tiger Mom in
Registry.kt. I also added a unit testRegistryStatsTest.ktto ensure these values remain correct according to the spec, and documented the fix infixes.mdas FIX-017.PR created automatically by Jules for task 12173012964599937512 started by @candour
Summary by CodeRabbit
Bug Fixes
Tests