feat: Introduce dynamic JSON-based configuration for game settings and command toggling via a new admin command.

This commit is contained in:
syntaxbullet
2025-12-15 21:59:28 +01:00
parent 1eace32aa1
commit ac6283e60c
12 changed files with 257 additions and 48 deletions

View File

@@ -1,12 +1,12 @@
import { users, userTimers } from "@/db/schema";
import { eq, sql, and } from "drizzle-orm";
import { DrizzleClient } from "@/lib/DrizzleClient";
import { GameConfig } from "@/config/game";
import { config } from "@/lib/config";
export const levelingService = {
// Calculate XP required for a specific level
getXpForLevel: (level: number) => {
return Math.floor(GameConfig.leveling.base * Math.pow(level, GameConfig.leveling.exponent));
return Math.floor(config.leveling.base * Math.pow(level, config.leveling.exponent));
},
// Pure XP addition - No cooldown checks
@@ -72,13 +72,13 @@ export const levelingService = {
}
// Calculate random XP
const amount = BigInt(Math.floor(Math.random() * (GameConfig.leveling.chat.maxXp - GameConfig.leveling.chat.minXp + 1)) + GameConfig.leveling.chat.minXp);
const amount = BigInt(Math.floor(Math.random() * (config.leveling.chat.maxXp - config.leveling.chat.minXp + 1)) + config.leveling.chat.minXp);
// Add XP
const result = await levelingService.addXp(id, amount, txFn);
// Update/Set Cooldown
const nextReadyAt = new Date(now.getTime() + GameConfig.leveling.chat.cooldownMs);
const nextReadyAt = new Date(now.getTime() + config.leveling.chat.cooldownMs);
await txFn.insert(userTimers)
.values({