Skip to content

Commit 4aa4f66

Browse files
committed
Don't count the last game round as a skip
1 parent e19c35a commit 4aa4f66

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/App.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ export default function App() {
8080
case "post-game": {
8181
const wordsGuessed = countIf(
8282
state.finishedRounds,
83-
(round) => round.didGuess,
83+
(round) => round.status === "guessed",
84+
);
85+
const wordsSkipped = countIf(
86+
state.finishedRounds,
87+
(round) => round.status === "skipped",
8488
);
85-
const wordsSkipped = state.finishedRounds.length - wordsGuessed;
8689

8790
return (
8891
<Container finishedRounds={state.finishedRounds}>

src/Rounds.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ type Props = {
1212
export default function Rounds({ currentRound, finishedRounds }: Props) {
1313
return (
1414
<div className={`${styles.container} centered-container flex-col`}>
15-
{finishedRounds.map(({ wordUnscrambled: word, didGuess }, index) => (
15+
{finishedRounds.map(({ wordUnscrambled: word, status }, index) => (
1616
<Word
1717
key={index}
1818
word={word}
19-
color={didGuess ? "positive" : "negative"}
19+
color={
20+
status === "guessed"
21+
? "positive"
22+
: status === "skipped"
23+
? "negative"
24+
: undefined
25+
}
2026
/>
2127
))}
2228
{currentRound && <Word word={currentRound.wordScrambled} />}

src/hooks/useAppState.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scrambleString from "../util/scrambleString";
77
export type Round = Readonly<{
88
wordUnscrambled: string;
99
wordScrambled: string;
10-
didGuess: boolean;
10+
status?: "guessed" | "skipped";
1111
}>;
1212

1313
function getNewRound(
@@ -21,7 +21,6 @@ function getNewRound(
2121
return {
2222
wordUnscrambled: word,
2323
wordScrambled: scrambleString(word, bannedWords),
24-
didGuess: false,
2524
};
2625
} catch {
2726
console.warn("Struggled to scramble " + word);
@@ -59,7 +58,9 @@ function getNewRoundState(state: InGameState, didGuess: boolean): InGameState {
5958
currentRound: getNewRound(state.wordPack, state.bannedWords),
6059
finishedRounds: [
6160
...state.finishedRounds,
62-
didGuess ? { ...state.currentRound, didGuess: true } : state.currentRound,
61+
didGuess
62+
? { ...state.currentRound, status: didGuess ? "guessed" : "skipped" }
63+
: state.currentRound,
6364
],
6465
guess: "",
6566
};

0 commit comments

Comments
 (0)