feat: implement daily character guessing game with local storage and hint system

- 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.
This commit is contained in:
2026-03-01 03:59:16 +01:00
parent 6f7bae2307
commit b8b3f8bddc
23 changed files with 2988 additions and 620 deletions

View File

@@ -0,0 +1,33 @@
import { json } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { characterHistory } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import { sql } from 'drizzle-orm';
export async function POST({ request }) {
try {
const { characterId } = await request.json();
if (!characterId) {
return json({ error: 'Missing characterId' }, { status: 400 });
}
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayDate = today.toISOString().split('T')[0];
// Increment the won counter for today's entry
await db
.update(characterHistory)
.set({
won: sql`${characterHistory.won} + 1`,
updatedAt: Date.now()
})
.where(eq(characterHistory.date, todayDate));
return json({ success: true });
} catch (error) {
console.error('Error recording win:', error);
return json({ error: 'Failed to record win' }, { status: 500 });
}
}