1.1 KiB
1.1 KiB
Leveling Module
- Level is derived, not stored. Total XP is the source of truth.
getLevelFromXp()recalculates level from cumulative XP on everyaddXp()call. Levels are monotonic — they never decrease. - XP curve is a power law:
xpForLevel(n) = floor(base * n^exponent)where defaults arebase: 100,exponent: 1.5. Config comes fromgameSettingsService(30s cache TTL). - Chat XP (
processChatXp()) awards random XP betweenminXp(5) andmaxXp(15) per message, gated by a 60-second per-user cooldown (TimerType.COOLDOWN, keyTimerKey.CHAT_XP). The cooldown is upserted atomically. - Quest/reward XP uses
addXp()directly — it bypasses the chat cooldown. - XP boost multipliers come from active
TimerType.EFFECTtimers with key'xp_boost'(metadata field:multiplier). - All XP values are
bigintin the DB but converted toNumberfor arithmetic. Watch for overflow at extremely high XP values. addXp()andprocessChatXp()run inside transactions. They emitXP_GAINED(fire-and-forget) which the quest system listens to — the weight equals the XP amount.