- Added character selection and history management using local storage. - Implemented hint system that unlocks based on the number of guesses. - Enhanced UI with animations for hint unlocks and special win conditions. - Created a server endpoint to record wins in the database.
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { error } from '@sveltejs/kit';
|
|
import { db } from '$lib/server/db';
|
|
import { config } from '$lib/server/db/schema';
|
|
import { getDailyModeCharacters, getOrCreateTodayCharacter, getYesterdayCharacter } from '$lib/server/daily-character';
|
|
import { like } from 'drizzle-orm';
|
|
|
|
export async function load() {
|
|
const characters = await getDailyModeCharacters();
|
|
const dailyCharacter = await getOrCreateTodayCharacter(characters);
|
|
|
|
if (!dailyCharacter) {
|
|
throw error(404, 'No daily character available. Please check if characters are configured in daily mode.');
|
|
}
|
|
|
|
const yesterdayCharacter = await getYesterdayCharacter(new Date(), characters);
|
|
|
|
// Load column visibility config
|
|
const columnConfig = await db
|
|
.select()
|
|
.from(config)
|
|
.where(like(config.key, 'characterHistory.column.%.visible'));
|
|
|
|
// Convert to object for easier access
|
|
const columnVisibility: Record<string, boolean> = {};
|
|
columnConfig.forEach(row => {
|
|
const match = row.key.match(/characterHistory\.column\.(.+)\.visible/);
|
|
if (match) {
|
|
columnVisibility[match[1]] = row.value === 'true';
|
|
}
|
|
});
|
|
|
|
return {
|
|
characters,
|
|
dailyCharacter,
|
|
yesterdayCharacter,
|
|
columnVisibility
|
|
};
|
|
}
|