economy: forgot to add the streak to schema, and adjust shop logic with categories and type

This commit is contained in:
Ayden Jahola 2024-10-26 19:42:52 +01:00
parent 81cfdd4b21
commit e4e6135a21
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742
5 changed files with 37 additions and 2 deletions

View file

@ -22,10 +22,12 @@ module.exports = {
userEconomy = await UserEconomy.create({
userId: user.id,
guildId: guild.id,
streak: 0, // Initialize streak
});
}
const now = new Date();
if (userEconomy.lastDaily && now - userEconomy.lastDaily < oneDay) {
const remainingTime =
new Date(userEconomy.lastDaily.getTime() + oneDay) - now;
@ -49,8 +51,13 @@ module.exports = {
return;
}
let reward = dailyBaseReward + userEconomy.streak * streakBonus;
if (userEconomy.lastDaily && now - userEconomy.lastDaily >= oneDay) {
userEconomy.streak = 0;
}
userEconomy.streak += 1;
let reward = dailyBaseReward + userEconomy.streak * streakBonus;
userEconomy.lastDaily = now;
userEconomy.balance += reward;

View file

@ -31,7 +31,9 @@ module.exports = {
const price = Math.floor(item.price * discount);
const discountText = discount < 1 ? " (Discounted!)" : "";
return `${item.name} - **${price}** coins${discountText} - Rarity: ${item.rarity}`;
return `${item.name} - **${price}** coins${discountText} - Rarity: ${
item.rarity
} - Type: ${item.type} - Category: ${item.category || "N/A"}`;
});
const shopEmbed = new EmbedBuilder()

View file

@ -11,6 +11,8 @@ const shopItemSchema = new mongoose.Schema({
enum: ["Common", "Rare", "Epic", "Legendary"],
default: "Common",
},
type: { type: String, required: true },
category: { type: String },
});
module.exports = mongoose.model("ShopItem", shopItemSchema);

View file

@ -6,6 +6,7 @@ const userEconomySchema = new mongoose.Schema({
balance: { type: Number, default: 200 },
lastDaily: { type: Date, default: null },
lastWork: { type: Date, default: null },
streak: { type: Number, default: 0 },
});
module.exports = mongoose.model("UserEconomy", userEconomySchema);

View file

@ -2,6 +2,7 @@ const ShopItem = require("../models/ShopItem");
async function seedShopItems(guildId) {
const items = [
// Valorant Skins
{
itemId: "prime_vandal",
name: "Prime Vandal",
@ -9,6 +10,8 @@ async function seedShopItems(guildId) {
description:
"A futuristic skin for the Vandal with a sleek design and special effects.",
rarity: "Rare",
type: "Skin",
category: "Valorant",
},
{
itemId: "reaver_vandal",
@ -17,6 +20,8 @@ async function seedShopItems(guildId) {
description:
"One of the most popular Vandal skins with a haunting aesthetic and special animations.",
rarity: "Epic",
type: "Skin",
category: "Valorant",
},
{
itemId: "sovereign_ghost",
@ -25,6 +30,8 @@ async function seedShopItems(guildId) {
description:
"Golden elegance for the Ghost pistol with unique sound effects.",
rarity: "Common",
type: "Skin",
category: "Valorant",
},
{
itemId: "araxys_operator",
@ -33,6 +40,8 @@ async function seedShopItems(guildId) {
description:
"A top-tier sniper skin with alien-like animations and sound effects.",
rarity: "Legendary",
type: "Skin",
category: "Valorant",
},
{
itemId: "glitchpop_bulldog",
@ -41,7 +50,11 @@ async function seedShopItems(guildId) {
description:
"A flashy skin for the Bulldog with vibrant colors and cyberpunk vibe.",
rarity: "Rare",
type: "Skin",
category: "Valorant",
},
// CS2 Skins
{
itemId: "dragon_lore_awp",
name: "AWP Dragon Lore",
@ -49,6 +62,8 @@ async function seedShopItems(guildId) {
description:
"A legendary skin for the AWP with dragon designs, a rare and coveted item.",
rarity: "Legendary",
type: "Skin",
category: "CS2",
},
{
itemId: "ak47_redline",
@ -57,6 +72,8 @@ async function seedShopItems(guildId) {
description:
"A simple yet iconic AK-47 skin with red and black color scheme.",
rarity: "Common",
type: "Skin",
category: "CS2",
},
{
itemId: "m4a4_howl",
@ -65,6 +82,8 @@ async function seedShopItems(guildId) {
description:
"A rare and valuable skin for the M4A4 with a striking wolf design.",
rarity: "Epic",
type: "Skin",
category: "CS2",
},
{
itemId: "desert_eagle_kumicho_dragon",
@ -73,6 +92,8 @@ async function seedShopItems(guildId) {
description:
"A Desert Eagle skin with an intricate dragon design and a metallic finish.",
rarity: "Rare",
type: "Skin",
category: "CS2",
},
{
itemId: "usp_kill_confirmed",
@ -81,6 +102,8 @@ async function seedShopItems(guildId) {
description:
"A detailed skin for the USP-S with a unique comic-style design.",
rarity: "Epic",
type: "Skin",
category: "CS2",
},
];