Round veterancy values to nearest integer#7075
Conversation
📝 WalkthroughWalkthroughThe MaxHealth buff effect now rounds the value returned by Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lua/sim/Buff.lua (1)
304-305: Add boundary regression coverage for rounding behavior.Please add/extend tests for
.49,.50,.51boundaries (including the documented 15599→15600 scenario) to lock in this behavior and prevent regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lua/sim/Buff.lua` around lines 304 - 305, The rounding logic in Buff.lua uses val = math.floor(val + 0.5) but lacks tests to lock in boundary behavior; add unit tests that exercise the rounding at .49, .50 and .51 boundaries and the documented 15599→15600 case. Specifically, create tests that call the function/method that produces/consumes the local variable val (referencing the rounding site where val = math.floor(val + 0.5)) with inputs that produce fractional parts .49, .50 and .51 and assert they round to the expected integers (e.g., x.49 -> x, x.50 -> x+1, x.51 -> x+1), and add an explicit test for the 15599.* inputs that verifies 15599.50 rounds to 15600 (and nearby .49/.51 behave accordingly) to prevent regression.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lua/sim/Buff.lua`:
- Around line 304-305: The rounding logic in Buff.lua uses val = math.floor(val
+ 0.5) but lacks tests to lock in boundary behavior; add unit tests that
exercise the rounding at .49, .50 and .51 boundaries and the documented
15599→15600 case. Specifically, create tests that call the function/method that
produces/consumes the local variable val (referencing the rounding site where
val = math.floor(val + 0.5)) with inputs that produce fractional parts .49, .50
and .51 and assert they round to the expected integers (e.g., x.49 -> x, x.50 ->
x+1, x.51 -> x+1), and add an explicit test for the 15599.* inputs that verifies
15599.50 rounds to 15600 (and nearby .49/.51 behave accordingly) to prevent
regression.
Example:
Checklist
Summary by CodeRabbit