From 4639fecf45290bfbc0b0286ee1267a4a46ddfec5 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Sun, 14 Dec 2025 14:16:16 +0100 Subject: [PATCH] feat: Implement gradual daily streak decay and rename currency from 'coins' to 'Astral Units'. --- src/commands/economy/daily.ts | 4 ++-- src/commands/economy/pay.ts | 4 ++-- src/modules/economy/economy.service.ts | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/commands/economy/daily.ts b/src/commands/economy/daily.ts index 6ca4082..fab06ed 100644 --- a/src/commands/economy/daily.ts +++ b/src/commands/economy/daily.ts @@ -13,9 +13,9 @@ export const daily = createCommand({ const embed = new EmbedBuilder() .setTitle("💰 Daily Reward Claimed!") - .setDescription(`You claimed **${result.amount}** coins!`) + .setDescription(`You claimed **${result.amount}** Astral Units!`) .addFields( - { name: "Current Streak", value: `🔥 ${result.streak} days`, inline: true }, + { name: "Activity Score", value: `🔥 ${result.streak}`, inline: true }, { name: "Next Reward", value: ``, inline: true } ) .setColor("Gold") diff --git a/src/commands/economy/pay.ts b/src/commands/economy/pay.ts index 06b4a3c..2603f9c 100644 --- a/src/commands/economy/pay.ts +++ b/src/commands/economy/pay.ts @@ -8,7 +8,7 @@ import { createErrorEmbed, createWarningEmbed } from "@lib/embeds"; export const pay = createCommand({ data: new SlashCommandBuilder() .setName("pay") - .setDescription("Transfer coins to another user") + .setDescription("Transfer Astral Units to another user") .addUserOption(option => option.setName("user") .setDescription("The user to pay") @@ -41,7 +41,7 @@ export const pay = createCommand({ const embed = new EmbedBuilder() .setTitle("💸 Transfer Successful") - .setDescription(`Successfully sent **${amount}** coins to <@${targetUser.id}>.`) + .setDescription(`Successfully sent **${amount}** Astral Units to <@${targetUser.id}>.`) .setColor("Green") .setTimestamp(); diff --git a/src/modules/economy/economy.service.ts b/src/modules/economy/economy.service.ts index d90cc1e..bb5ef1c 100644 --- a/src/modules/economy/economy.service.ts +++ b/src/modules/economy/economy.service.ts @@ -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}`,