feat: implement database-backed game settings with a new schema, service, and migration script.
Some checks failed
Deploy to Production / test (push) Failing after 26s
Some checks failed
Deploy to Production / test (push) Failing after 26s
This commit is contained in:
88
shared/db/schema/game-settings.ts
Normal file
88
shared/db/schema/game-settings.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import {
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
jsonb,
|
||||
} from 'drizzle-orm/pg-core';
|
||||
import { relations, type InferSelectModel, type InferInsertModel } from 'drizzle-orm';
|
||||
|
||||
export type GameSettings = InferSelectModel<typeof gameSettings>;
|
||||
export type GameSettingsInsert = InferInsertModel<typeof gameSettings>;
|
||||
|
||||
export interface LevelingConfig {
|
||||
base: number;
|
||||
exponent: number;
|
||||
chat: {
|
||||
cooldownMs: number;
|
||||
minXp: number;
|
||||
maxXp: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface EconomyConfig {
|
||||
daily: {
|
||||
amount: string;
|
||||
streakBonus: string;
|
||||
weeklyBonus: string;
|
||||
cooldownMs: number;
|
||||
};
|
||||
transfers: {
|
||||
allowSelfTransfer: boolean;
|
||||
minAmount: string;
|
||||
};
|
||||
exam: {
|
||||
multMin: number;
|
||||
multMax: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface InventoryConfig {
|
||||
maxStackSize: string;
|
||||
maxSlots: number;
|
||||
}
|
||||
|
||||
export interface LootdropConfig {
|
||||
activityWindowMs: number;
|
||||
minMessages: number;
|
||||
spawnChance: number;
|
||||
cooldownMs: number;
|
||||
reward: {
|
||||
min: number;
|
||||
max: number;
|
||||
currency: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface TriviaConfig {
|
||||
entryFee: string;
|
||||
rewardMultiplier: number;
|
||||
timeoutSeconds: number;
|
||||
cooldownMs: number;
|
||||
categories: number[];
|
||||
difficulty: 'easy' | 'medium' | 'hard' | 'random';
|
||||
}
|
||||
|
||||
export interface ModerationConfig {
|
||||
prune: {
|
||||
maxAmount: number;
|
||||
confirmThreshold: number;
|
||||
batchSize: number;
|
||||
batchDelayMs: number;
|
||||
};
|
||||
}
|
||||
|
||||
export const gameSettings = pgTable('game_settings', {
|
||||
id: text('id').primaryKey().default('default'),
|
||||
leveling: jsonb('leveling').$type<LevelingConfig>().notNull(),
|
||||
economy: jsonb('economy').$type<EconomyConfig>().notNull(),
|
||||
inventory: jsonb('inventory').$type<InventoryConfig>().notNull(),
|
||||
lootdrop: jsonb('lootdrop').$type<LootdropConfig>().notNull(),
|
||||
trivia: jsonb('trivia').$type<TriviaConfig>().notNull(),
|
||||
moderation: jsonb('moderation').$type<ModerationConfig>().notNull(),
|
||||
commands: jsonb('commands').$type<Record<string, boolean>>().default({}),
|
||||
system: jsonb('system').$type<Record<string, unknown>>().default({}),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const gameSettingsRelations = relations(gameSettings, () => ({}));
|
||||
Reference in New Issue
Block a user