Skip to content

Round veterancy values to nearest integer#7075

Merged
BlackYps merged 3 commits intoFAForever:developfrom
NoryGit:vet_rounding
Apr 10, 2026
Merged

Round veterancy values to nearest integer#7075
BlackYps merged 3 commits intoFAForever:developfrom
NoryGit:vet_rounding

Conversation

@NoryGit
Copy link
Copy Markdown
Contributor

@NoryGit NoryGit commented Apr 1, 2026

Example:

  • Old HP of T2 Cybran ACU with 3 vets: 15599
  • New HP of T2 Cybran ACU with 3 vets: 15600

Checklist

Summary by CodeRabbit

  • Bug Fixes
    • Max health calculations now round to whole numbers (no fractional HP), fixing veterancy health bonus inconsistencies and ensuring consistent unit HP values.
  • Documentation
    • Added a changelog entry documenting the rounding fix with an example comparison.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

The MaxHealth buff effect now rounds the value returned by BuffCalculate(...) using math.round(val) before calling unit:SetMaxHealth(val). A changelog snippet documenting the rounding fix for veterancy/max-health was added.

Changes

Cohort / File(s) Summary
MaxHealth Buff Rounding
lua/sim/Buff.lua
Round val from BuffCalculate(...) with math.round(val) before applying via unit:SetMaxHealth(val).
Changelog Snippet
changelog/snippets/fix.7075.md
Add changelog entry describing veterancy/max-health rounding fix and example values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

area: balance idea

Poem

🐰 I hopped through code by lantern's glow,
Rounded health so numbers grow.
No halves remain, all whole and neat,
Small fixes make the balance sweet. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides a concrete example of the change's effect but omits the 'Description of the proposed changes' and 'Testing done' sections from the template. Add a clear description of what the changes do and document the testing performed to verify the rounding behavior works correctly.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: rounding veterancy values to the nearest integer, which is the core modification applied to the BuffEffects.MaxHealth effect in the Buff.lua file.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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 (1)
lua/sim/Buff.lua (1)

304-305: Add boundary regression coverage for rounding behavior.

Please add/extend tests for .49, .50, .51 boundaries (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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c320f551-2cc5-4173-bbe7-3fea3e8a35ac

📥 Commits

Reviewing files that changed from the base of the PR and between 132476b and 0a9d41c.

📒 Files selected for processing (1)
  • lua/sim/Buff.lua

@NoryGit NoryGit changed the title Round veterancy values to nearest integer (0.5 rounds up) Round veterancy values to nearest integer Apr 5, 2026
@BlackYps BlackYps merged commit 97dc88f into FAForever:develop Apr 10, 2026
6 checks passed
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.

3 participants