update stats on loss, not on reset

This commit is contained in:
ashastral 2022-03-02 19:19:22 -08:00
parent 61461e6d62
commit 4dd91ad03c

View file

@ -61,10 +61,6 @@ export function Game(props: GameProps) {
setGuesses([...puzzle.history]); setGuesses([...puzzle.history]);
setCurrentGuess(""); setCurrentGuess("");
setGameState(GameState.Playing); setGameState(GameState.Playing);
setTodayStats((oldStats) => ({
...oldStats,
tries: oldStats.tries + 1,
}));
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -181,6 +177,10 @@ export function Game(props: GameProps) {
} else if (guesses.length + 1 === puzzle.history.length + MAX_GUESSES) { } else if (guesses.length + 1 === puzzle.history.length + MAX_GUESSES) {
setHint(<p>Not quite! The answer could've been <strong>{game.possible_word().toUpperCase()}</strong>. (Enter to try again)</p>); setHint(<p>Not quite! The answer could've been <strong>{game.possible_word().toUpperCase()}</strong>. (Enter to try again)</p>);
setGameState(GameState.Lost); setGameState(GameState.Lost);
setTodayStats((oldStats) => ({
...oldStats,
tries: oldStats.tries + 1,
}));
} else { } else {
speak(describeClue(clue(result))); speak(describeClue(clue(result)));
} }