From 2a99f545efd17e7dc5b999a5fe1d354a8c294893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sat, 24 Jan 2026 13:00:51 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20Zeige=20Ergebnis=20statt=20Solve/Give=20?= =?UTF-8?q?Up=20Button=20bei=20bereits=20abgeschlossenen=20R=C3=A4tseln?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Verwende gameState.isSolved/isFailed direkt für UI-Logik - Behebt Problem, dass Solve/Give Up Button bei zurückkehrenden Rätseln angezeigt wurde - isSolved/isFailed werden jetzt direkt aus gameState gelesen für sofortige Konsistenz --- components/Game.tsx | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/components/Game.tsx b/components/Game.tsx index bbe18b0..a04ae6f 100644 --- a/components/Game.tsx +++ b/components/Game.tsx @@ -96,6 +96,10 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max if (gameState.isSolved && !gameState.yearGuessed && dailyPuzzle?.releaseYear) { setShowYearModal(true); } + } else { + // Reset states when gameState is null (e.g., during loading) + setHasWon(false); + setHasLost(false); } }, [gameState, dailyPuzzle]); @@ -163,6 +167,10 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max ); if (!gameState) return
{t('loadingState')}
; + + // Use gameState directly for isSolved/isFailed to ensure consistency when returning to completed puzzles + const isSolved = gameState?.isSolved ?? hasWon; + const isFailed = gameState?.isFailed ?? hasLost; const handleGuess = (song: any) => { if (isProcessingGuess) return; @@ -176,6 +184,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max if (song.id === dailyPuzzle.songId) { addGuess(song.title, true); setHasWon(true); + // gameState.isSolved will be updated by useGameState // Track puzzle solved event if (typeof window !== 'undefined' && window.plausible) { window.plausible('puzzle_solved', { @@ -196,6 +205,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max if (gameState.guesses.length + 1 >= maxAttempts) { setHasLost(true); setHasWon(false); + // gameState.isFailed will be updated by useGameState // Track puzzle lost event if (typeof window !== 'undefined' && window.plausible) { window.plausible('puzzle_solved', { @@ -236,6 +246,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max if (gameState.guesses.length + 1 >= maxAttempts) { setHasLost(true); setHasWon(false); + // gameState.isFailed will be updated by useGameState // Track puzzle lost event if (typeof window !== 'undefined' && window.plausible) { window.plausible('puzzle_solved', { @@ -260,6 +271,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max giveUp(); // Ensure game is marked as failed and score reset to 0 setHasLost(true); setHasWon(false); + // gameState.isFailed will be updated by useGameState // Track puzzle lost event if (typeof window !== 'undefined' && window.plausible) { window.plausible('puzzle_solved', { @@ -409,19 +421,19 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max if (i < gameState.guesses.length) { if (gameState.guesses[i] === 'SKIPPED') { emojiGrid += '⬛'; - } else if (hasWon && i === gameState.guesses.length - 1) { + } else if (isSolved && i === gameState.guesses.length - 1) { emojiGrid += '🟩'; } else { emojiGrid += '🟥'; } } else { // If game is lost, fill remaining slots with black squares - emojiGrid += hasLost ? '⬛' : '⬜'; + emojiGrid += isFailed ? '⬛' : '⬜'; } } - const speaker = hasWon ? '🔉' : '🔇'; - const bonusStar = (hasWon && gameState.yearGuessed && dailyPuzzle.releaseYear && gameState.scoreBreakdown.some(item => item.reason === 'Bonus: Correct Year')) ? '⭐' : ''; + const speaker = isSolved ? '🔉' : '🔇'; + const bonusStar = (isSolved && gameState.yearGuessed && dailyPuzzle.releaseYear && gameState.scoreBreakdown.some(item => item.reason === 'Bonus: Correct Year')) ? '⭐' : ''; const genreText = genre ? `${isSpecial ? t('special') : t('genre')}: ${genre}\n` : ''; // Use current domain from window.location to support both hoerdle.de and hördle.de @@ -534,7 +546,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max src={dailyPuzzle.audioUrl} unlockedSeconds={unlockedSeconds} startTime={dailyPuzzle.startTime} - autoPlay={lastAction === 'SKIP' || (lastAction === 'GUESS' && !hasWon && !hasLost)} + autoPlay={lastAction === 'SKIP' || (lastAction === 'GUESS' && !isSolved && !isFailed)} onReplay={addReplay} onHasPlayedChange={setHasPlayedAudio} /> @@ -543,7 +555,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
{gameState.guesses.map((guess, i) => { - const isCorrect = hasWon && i === gameState.guesses.length - 1; + const isCorrect = isSolved && i === gameState.guesses.length - 1; return (
#{i + 1} @@ -555,7 +567,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max })}
- {!hasWon && !hasLost && ( + {!isSolved && !isFailed && ( <>
@@ -586,13 +598,13 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max )} - {(hasWon || hasLost) && ( -
+ {(isSolved || isFailed) && ( +

- {hasWon ? t('won') : t('lost')} + {isSolved ? t('won') : t('lost')}

-
+
{t('score')}: {gameState.score}
@@ -610,7 +622,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max -

{hasWon ? t('comeBackTomorrow') : t('theSongWas')}

+

{isSolved ? t('comeBackTomorrow') : t('theSongWas')}