Floating XP/gold text does not round amounts (damage does) #1052

Closed
opened 2026-08-13 05:38:32 +00:00 by spikerj · 1 comment
Owner

createDamageText / createPlayerDamageText render -${Math.round(damage)}, but createExperienceText and createGoldText interpolate the raw number:

  • XP: `+${exp} XP`
  • gold: `+${gold} G`

A fractional grant (e.g. 10.6 XP or 3.25 gold from a scaled drop) therefore paints +10.6 XP / +3.25 G while damage for the same tick would show a whole number. The original game.js port this file claims to match rounded the combat number; XP/gold were left unrounded in the TypeScript port.

Fix: Math.round (or Math.floor if the economy is integer-only) on both XP and gold labels so HUD text cannot show fractions the rest of the combat UI never does.

Found by Wave 7 coverage tests (floating-text-system.leftovers.spec.ts).

`createDamageText` / `createPlayerDamageText` render `-${Math.round(damage)}`, but `createExperienceText` and `createGoldText` interpolate the raw number: - XP: `` `+${exp} XP` `` - gold: `` `+${gold} G` `` A fractional grant (e.g. 10.6 XP or 3.25 gold from a scaled drop) therefore paints `+10.6 XP` / `+3.25 G` while damage for the same tick would show a whole number. The original `game.js` port this file claims to match rounded the combat number; XP/gold were left unrounded in the TypeScript port. Fix: `Math.round` (or `Math.floor` if the economy is integer-only) on both XP and gold labels so HUD text cannot show fractions the rest of the combat UI never does. Found by Wave 7 coverage tests (`floating-text-system.leftovers.spec.ts`).
Author
Owner

Resolved in spikersoft-angular PR #819 (merged to master). Floating XP/gold text rounds amounts the same way damage does. Closing.

Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). Floating XP/gold text rounds amounts the same way damage does. Closing.
Sign in to join this conversation.