Skip to content

fix(xp): stop banking experience at the level cap - #430

Merged
Mathih13 merged 2 commits into
mainfrom
fix/xp-level-cap
Sep 4, 2026
Merged

Mathih13 merged 2 commits into
mainfrom
fix/xp-level-cap

Conversation

@Mathih13

@Mathih13 Mathih13 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Characters at level 60 could keep banking XP, and a large award could overflow the stored XP before leveling. XP progression now uses a wider intermediate value, discards the remainder when it reaches level 60, and stops capped kill awards before they drain rested XP or emit an XP event.

The shared non-grey kill calculation stays unchanged because Drain Soul rewards and Hunter pet progression also use it. This addresses the XP-cap finding in the performance and correctness report.

Verification:

  • 1,473 Module tests passed in an isolated build.
  • A new private Standalone test checks a large level-59 award, a later capped grant, and a tagged level-60 kill. It verifies zero XP, one level-up, unchanged rested XP and no later kill-XP event.
  • That runtime test fails against the baseline because it banks 999,999 XP at level 60, and passes with this change.
  • Pure progression tests cover a maximum-size award and the exact remainder across several levels. Offline preflight and diff checks pass.

The private tests use fresh in-memory processes. No existing realm was changed.

Implemented by GPT-5.6 Sol and GPT-6 through Codex, reviewed by GPT-6 through Codex.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed experience progression at the maximum level.
    • Excess experience is now discarded for capped characters.
    • Prevented additional level-ups and rewards after reaching the level cap.
    • Preserved experience remainders and correctly handled large or multi-level awards.
    • Ensured capped characters do not generate unnecessary experience events.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: cc869254-be79-49a1-a71b-ba8d1110a88d

📥 Commits

Reviewing files that changed from the base of the PR and between a447495 and 9c701ab.

📒 Files selected for processing (2)
  • module/src/xp.rs
  • module/tests/xp_cap.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

XP progression now uses shared logic for multi-level awards, remainder preservation, and level-60 capping. Capped characters receive no XP, rested XP drain, or XP event. Unit and ignored integration tests cover these rules.

Changes

XP progression cap

Layer / File(s) Summary
Shared progression and cap rules
module/src/xp.rs
Adds LEVEL_CAP and progression_after_award. The logic supports multiple level-ups, preserves remainders, discards capped XP, and handles zero thresholds.
Award and level-up integration
module/src/xp.rs
Uses shared progression results for XP awards and level-ups. Capped characters exit before rested XP drain or XP events, and capped state clears XP and the next-level threshold.
Runtime cap validation
module/tests/xp_cap.rs
Adds an ignored integration test for level-60 awards and creature-kill XP. Helpers verify capped player state and event behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 9c701

Level-60 characters now discard further XP and do not consume rested XP or emit XP events for capped awards. The cap, multi-level remainder, and kill behaviors are covered by the supplied tests, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing experience accumulation at the level cap.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/xp-level-cap

Comment @coderabbitai help to get the list of available commands.

@Mathih13

Mathih13 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@Mathih13
Mathih13 merged commit d6840e8 into main Sep 4, 2026
6 checks passed
@Mathih13
Mathih13 deleted the fix/xp-level-cap branch October 11, 2026 18:21
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.

1 participant