forked from syntaxbullet/AuroraBot-discord
feat: Implement gradual daily streak decay and rename currency from 'coins' to 'Astral Units'.
This commit is contained in:
@@ -100,11 +100,11 @@ export const economyService = {
|
||||
|
||||
let streak = (user.dailyStreak || 0) + 1;
|
||||
|
||||
// If previous cooldown exists and expired more than 24h ago (meaning >48h since last claim), reset streak
|
||||
// If previous cooldown exists and expired more than 24h ago (meaning >48h since last claim), reduce streak by one for each day passed minimum 1
|
||||
if (cooldown) {
|
||||
const timeSinceReady = now.getTime() - cooldown.expiresAt.getTime();
|
||||
if (timeSinceReady > 24 * 60 * 60 * 1000) {
|
||||
streak = 1;
|
||||
streak = Math.max(1, streak - Math.floor(timeSinceReady / (24 * 60 * 60 * 1000)));
|
||||
}
|
||||
} else {
|
||||
streak = 1;
|
||||
@@ -113,9 +113,6 @@ export const economyService = {
|
||||
const bonus = (BigInt(streak) - 1n) * GameConfig.economy.daily.streakBonus;
|
||||
|
||||
const totalReward = GameConfig.economy.daily.amount + bonus;
|
||||
|
||||
// Update User w/ Economy Service (reuse modifyUserBalance if we split it out, but here manual is fine for atomic combined streak update)
|
||||
// Actually, we can just update directly here as we are already refining specific fields like streak.
|
||||
await txFn.update(users)
|
||||
.set({
|
||||
balance: sql`${users.balance} + ${totalReward}`,
|
||||
|
||||
Reference in New Issue
Block a user