Fix: hasLost/hasWon korrekt beim Reload initialisieren
This commit is contained in:
@@ -49,8 +49,8 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
|
|||||||
const t = useTranslations('Game');
|
const t = useTranslations('Game');
|
||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
const { gameState, statistics, addGuess, giveUp, addReplay, addYearBonus, skipYearBonus } = useGameState(genre, maxAttempts, isSpecial);
|
const { gameState, statistics, addGuess, giveUp, addReplay, addYearBonus, skipYearBonus } = useGameState(genre, maxAttempts, isSpecial);
|
||||||
const [hasWon, setHasWon] = useState(false);
|
const [hasWon, setHasWon] = useState(gameState?.isSolved ?? false);
|
||||||
const [hasLost, setHasLost] = useState(false);
|
const [hasLost, setHasLost] = useState(gameState?.isFailed ?? false);
|
||||||
const [shareText, setShareText] = useState(`🔗 ${t('share')}`);
|
const [shareText, setShareText] = useState(`🔗 ${t('share')}`);
|
||||||
const [lastAction, setLastAction] = useState<'GUESS' | 'SKIP' | null>(null);
|
const [lastAction, setLastAction] = useState<'GUESS' | 'SKIP' | null>(null);
|
||||||
const [isProcessingGuess, setIsProcessingGuess] = useState(false);
|
const [isProcessingGuess, setIsProcessingGuess] = useState(false);
|
||||||
@@ -87,12 +87,12 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (gameState && dailyPuzzle) {
|
if (gameState) {
|
||||||
setHasWon(gameState.isSolved);
|
setHasWon(gameState.isSolved);
|
||||||
setHasLost(gameState.isFailed);
|
setHasLost(gameState.isFailed);
|
||||||
|
|
||||||
// Show year modal if won but year not guessed yet and release year is available
|
// Show year modal if won but year not guessed yet and release year is available
|
||||||
if (gameState.isSolved && !gameState.yearGuessed && dailyPuzzle.releaseYear) {
|
if (gameState.isSolved && !gameState.yearGuessed && dailyPuzzle?.releaseYear) {
|
||||||
setShowYearModal(true);
|
setShowYearModal(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user