Fix: Prevent bonus round reappearance on reload and enable autoplay after wrong guess

This commit is contained in:
Hördle Bot
2025-11-23 22:23:51 +01:00
parent 4d807c77d0
commit 015862ce0c
2 changed files with 17 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ interface GameProps {
const DEFAULT_UNLOCK_STEPS = [2, 4, 7, 11, 16, 30, 60]; 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) { 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 [hasWon, setHasWon] = useState(false);
const [hasLost, setHasLost] = useState(false); const [hasLost, setHasLost] = useState(false);
const [shareText, setShareText] = useState('🔗 Share'); const [shareText, setShareText] = useState('🔗 Share');
@@ -146,6 +146,7 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
}; };
const handleYearSkip = () => { const handleYearSkip = () => {
skipYearBonus();
setShowYearModal(false); setShowYearModal(false);
// Send notification now that game is fully complete // Send notification now that game is fully complete
sendGotifyNotification(gameState.guesses.length, 'won', dailyPuzzle.id, genre, gameState.score); 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} src={dailyPuzzle.audioUrl}
unlockedSeconds={unlockedSeconds} unlockedSeconds={unlockedSeconds}
startTime={dailyPuzzle.startTime} startTime={dailyPuzzle.startTime}
autoPlay={lastAction === 'SKIP'} autoPlay={lastAction === 'SKIP' || (lastAction === 'GUESS' && !hasWon && !hasLost)}
onReplay={addReplay} onReplay={addReplay}
/> />
</div> </div>

View File

@@ -257,5 +257,18 @@ export function useGameState(genre: string | null = null, maxAttempts: number =
saveState(newState); 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 };
} }