feat: add /use command for inventory items with effects, implement XP boosts, and enhance scheduler for temporary role removal.
This commit is contained in:
@@ -65,7 +65,21 @@ export const levelingService = {
|
||||
}
|
||||
|
||||
// Calculate random XP
|
||||
const amount = BigInt(Math.floor(Math.random() * (config.leveling.chat.maxXp - config.leveling.chat.minXp + 1)) + config.leveling.chat.minXp);
|
||||
let amount = BigInt(Math.floor(Math.random() * (config.leveling.chat.maxXp - config.leveling.chat.minXp + 1)) + config.leveling.chat.minXp);
|
||||
|
||||
// Check for XP Boost
|
||||
const xpBoost = await txFn.query.userTimers.findFirst({
|
||||
where: and(
|
||||
eq(userTimers.userId, BigInt(id)),
|
||||
eq(userTimers.type, 'EFFECT'),
|
||||
eq(userTimers.key, 'xp_boost')
|
||||
)
|
||||
});
|
||||
|
||||
if (xpBoost && xpBoost.expiresAt > now) {
|
||||
const multiplier = (xpBoost.metadata as any)?.multiplier || 1;
|
||||
amount = BigInt(Math.floor(Number(amount) * multiplier));
|
||||
}
|
||||
|
||||
// Add XP
|
||||
const result = await levelingService.addXp(id, amount, txFn);
|
||||
|
||||
Reference in New Issue
Block a user