feat: add WinPanel and YesterdayCharacter components; refactor daily game page

- Introduced WinPanel component to display win/loss messages based on game outcome.
- Added YesterdayCharacter component to show the character from the previous day.
- Refactored daily game page to utilize new components for better code organization and readability.
- Updated server-side logic to fetch daily character ID and count wins more efficiently.
- Cleaned up character selection logic and hint availability tracking.
This commit is contained in:
2026-03-02 11:05:02 +01:00
parent 4d059d45ef
commit cf25a96719
7 changed files with 649 additions and 555 deletions

View File

@@ -1,7 +1,7 @@
import { db } from '$lib/server/db';
import { character, devilFruit, arc, user, config, characterHistory } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import type { PageServerLoad } from './$types';
import { getDailyCharacterId } from '$lib/server/dailyCharacter';
export const load: PageServerLoad = async () => {
const [characters, devilFruits, arcs, users, configEntries, history] = await Promise.all([
@@ -13,15 +13,9 @@ export const load: PageServerLoad = async () => {
db.select().from(characterHistory)
]);
// Get daily character ID from config
const dailyCharIdEntry = configEntries.find((c) => c.key === 'dailyCharacterId');
const dailyCharId = dailyCharIdEntry?.value;
// Count how many times today's daily character was won/found
const today = new Date().toISOString().split('T')[0];
const dailyCharacterWins = dailyCharId
? history.filter((h) => h.characterId === dailyCharId && h.date === today && h.won === 1).length
: 0;
const dailyCharacterId = await getDailyCharacterId();
// Return count of wins for the daily character , count is stored in won field of characterHistory
const dailyCharacterWins = history.filter((h) => h.characterId === dailyCharacterId && h.won).length;
return {
stats: {