From 015862ce0c8e0d10bef7c23538c5fe088dbcd222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sun, 23 Nov 2025 22:23:51 +0100 Subject: [PATCH] Fix: Prevent bonus round reappearance on reload and enable autoplay after wrong guess --- components/Game.tsx | 5 +++-- lib/gameState.ts | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/components/Game.tsx b/components/Game.tsx index ed8ada8..d32c62a 100644 --- a/components/Game.tsx +++ b/components/Game.tsx @@ -28,7 +28,7 @@ interface GameProps { const DEFAULT_UNLOCK_STEPS = [2, 4, 7, 11, 16, 30, 60]; export default function Game({ dailyPuzzle, genre = null, isSpecial = false, maxAttempts = 7, unlockSteps = DEFAULT_UNLOCK_STEPS }: GameProps) { - const { gameState, statistics, addGuess, giveUp, addReplay, addYearBonus } = useGameState(genre, maxAttempts); + const { gameState, statistics, addGuess, giveUp, addReplay, addYearBonus, skipYearBonus } = useGameState(genre, maxAttempts); const [hasWon, setHasWon] = useState(false); const [hasLost, setHasLost] = useState(false); const [shareText, setShareText] = useState('🔗 Share'); @@ -146,6 +146,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max }; const handleYearSkip = () => { + skipYearBonus(); setShowYearModal(false); // Send notification now that game is fully complete sendGotifyNotification(gameState.guesses.length, 'won', dailyPuzzle.id, genre, gameState.score); @@ -253,7 +254,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max src={dailyPuzzle.audioUrl} unlockedSeconds={unlockedSeconds} startTime={dailyPuzzle.startTime} - autoPlay={lastAction === 'SKIP'} + autoPlay={lastAction === 'SKIP' || (lastAction === 'GUESS' && !hasWon && !hasLost)} onReplay={addReplay} /> diff --git a/lib/gameState.ts b/lib/gameState.ts index 407c729..f2eaf9d 100644 --- a/lib/gameState.ts +++ b/lib/gameState.ts @@ -257,5 +257,18 @@ export function useGameState(genre: string | null = null, maxAttempts: number = saveState(newState); }; - return { gameState, statistics, addGuess, giveUp, addReplay, addYearBonus }; + const skipYearBonus = () => { + if (!gameState) return; + + const newBreakdown = [...gameState.scoreBreakdown, { value: 0, reason: 'Bonus: Skipped' }]; + + const newState = { + ...gameState, + scoreBreakdown: newBreakdown, + yearGuessed: true + }; + saveState(newState); + }; + + return { gameState, statistics, addGuess, giveUp, addReplay, addYearBonus, skipYearBonus }; }