Player profile level grows unboundedly: addXp and recordMatch have no level cap #65

Closed
opened 2026-09-15 04:49:09 +00:00 by Mark · 1 comment
Owner

Summary

Both addXp (src/data/profile.ts:156) and recordMatch (line 184) have level-up loops with no upper bound. A long-running player profile can reach level 1000+. Ranks plateau (Diamond at level 20+) but the level number keeps growing.

Where

  • src/data/profile.ts: addXp (line 156)
  • src/data/profile.ts: recordMatch (line 184)

Why this matters

  • Cosmetic but unbounded growth in localStorage
  • UI rendering and storage size degrade as profile ages
  • Defensive against corrupted profiles

Acceptance criteria

  • Define a MAX_LEVEL constant (suggested: 100)
  • Level-up loops terminate at MAX_LEVEL
  • Excess XP is retained for display purposes (e.g., 'Level 100 — 42,000 XP toward Prestige')
  • A 'Prestige' reset option can be added in a follow-up
## Summary Both addXp (src/data/profile.ts:156) and recordMatch (line 184) have level-up loops with no upper bound. A long-running player profile can reach level 1000+. Ranks plateau (Diamond at level 20+) but the level number keeps growing. ## Where - src/data/profile.ts: addXp (line 156) - src/data/profile.ts: recordMatch (line 184) ## Why this matters - Cosmetic but unbounded growth in localStorage - UI rendering and storage size degrade as profile ages - Defensive against corrupted profiles ## Acceptance criteria - Define a MAX_LEVEL constant (suggested: 100) - Level-up loops terminate at MAX_LEVEL - Excess XP is retained for display purposes (e.g., 'Level 100 — 42,000 XP toward Prestige') - A 'Prestige' reset option can be added in a follow-up
Mark closed this issue 2026-09-18 13:47:18 +00:00
Author
Owner

Fixed in commit 8f33946 on main.

Changes:

  • Added MAX_LEVEL = 100 constant in src/data/profile.ts
  • Factored out applyLevelUps() used by both addXp and recordMatch; terminates at MAX_LEVEL and retains excess XP for display
  • ProfileScreen XP bar now shows "N XP toward Prestige" once capped instead of the previous "MAX" label that fired at the rank plateau
  • Added src/data/profile.test.ts covering MAX_LEVEL constant, level cap, excess XP retention across multiple calls, and recordMatch at max

All 7 new tests pass; full suite unchanged except 3 pre-existing failures in src/engine/reactiveConditions.test.ts (verified against main before this change).

Fixed in commit 8f33946 on `main`. Changes: - Added `MAX_LEVEL = 100` constant in `src/data/profile.ts` - Factored out `applyLevelUps()` used by both `addXp` and `recordMatch`; terminates at MAX_LEVEL and retains excess XP for display - `ProfileScreen` XP bar now shows "N XP toward Prestige" once capped instead of the previous "MAX" label that fired at the rank plateau - Added `src/data/profile.test.ts` covering MAX_LEVEL constant, level cap, excess XP retention across multiple calls, and `recordMatch` at max All 7 new tests pass; full suite unchanged except 3 pre-existing failures in `src/engine/reactiveConditions.test.ts` (verified against `main` before this change).
Sign in to join this conversation.
No description provided.