docs: add JSDoc to service public methods
One-line JSDoc on 82 methods across 11 service files for quick scanning without reading full implementations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,11 +8,7 @@ import { TimerKey, TimerType } from "@shared/lib/constants";
|
||||
import { UserError } from "@shared/lib/errors";
|
||||
|
||||
export const levelingService = {
|
||||
// Calculate total XP required to REACH a specific level (Cumulative)
|
||||
// Level 1 = 0 XP
|
||||
// Level 2 = Base * (1^Exp)
|
||||
// Level 3 = Level 2 + Base * (2^Exp)
|
||||
// ...
|
||||
/** Calculate the cumulative XP required to reach a specific level. */
|
||||
getXpToReachLevel: (level: number) => {
|
||||
let total = 0;
|
||||
for (let l = 1; l < level; l++) {
|
||||
@@ -21,7 +17,7 @@ export const levelingService = {
|
||||
return total;
|
||||
},
|
||||
|
||||
// Calculate level from Total XP
|
||||
/** Derive a user's level from their total accumulated XP. */
|
||||
getLevelFromXp: (totalXp: bigint) => {
|
||||
let level = 1;
|
||||
let xp = Number(totalXp);
|
||||
@@ -37,13 +33,12 @@ export const levelingService = {
|
||||
}
|
||||
},
|
||||
|
||||
// Get XP needed to complete the current level (for calculating next level threshold in isolation)
|
||||
// Used internally or for display
|
||||
/** Get the XP needed to advance from the given level to the next. */
|
||||
getXpForNextLevel: (currentLevel: number) => {
|
||||
return Math.floor(config.leveling.base * Math.pow(currentLevel, config.leveling.exponent));
|
||||
},
|
||||
|
||||
// Cumulative XP addition
|
||||
/** Add XP to a user, recalculating their level and emitting a quest event. */
|
||||
addXp: async (id: string, amount: bigint, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
// Get current state
|
||||
@@ -77,7 +72,7 @@ export const levelingService = {
|
||||
}, tx);
|
||||
},
|
||||
|
||||
// Handle chat XP with cooldowns
|
||||
/** Award random chat XP if the user is not on cooldown; applies active XP boost multipliers. */
|
||||
processChatXp: async (id: string, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
// check if an xp cooldown is in place
|
||||
|
||||
Reference in New Issue
Block a user