aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.tsx
diff options
context:
space:
mode:
authorBrendan F <EpicWolverine@users.noreply.github.com>2024-02-19 20:35:50 -0800
committerBrendan F <EpicWolverine@users.noreply.github.com>2024-02-19 20:35:50 -0800
commit647edc9389b24bda19503514170ed31301ea0a72 (patch)
tree2b76df7a0e6ada2ad0042d91b3b7b2a679e2f5e8 /src/app.tsx
parentaa3a3063cbbd449ecd8b0d6092fd83ea4db27984 (diff)
Add guess states and exact artist match as a yellow
Diffstat (limited to 'src/app.tsx')
-rw-r--r--src/app.tsx20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/app.tsx b/src/app.tsx
index 1aab160..7cc348a 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -2,7 +2,7 @@ import React from "react";
import _ from "lodash";
import { Song } from "./types/song";
-import { GuessType } from "./types/guess";
+import { GuessState, GuessType } from "./types/guess";
import { todaysSolution } from "./helpers";
@@ -13,8 +13,7 @@ import * as Styled from "./app.styled";
function App() {
const initialGuess = {
song: undefined,
- skipped: false,
- isCorrect: undefined,
+ state: undefined,
} as GuessType;
const [guesses, setGuesses] = React.useState<GuessType[]>(
@@ -121,8 +120,7 @@ function App() {
const newGuesses = [...guesses];
newGuesses[currentTry] = {
song: undefined,
- skipped: true,
- isCorrect: undefined,
+ state: GuessState.Skipped,
};
return newGuesses;
@@ -132,7 +130,12 @@ function App() {
}, [currentTry]);
const guess = React.useCallback(() => {
- const isCorrect = selectedSong === todaysSolution;
+ let state = GuessState.Incorrect;
+ if (selectedSong === todaysSolution) {
+ state = GuessState.Correct;
+ } else if (selectedSong?.artist === todaysSolution.artist) {
+ state = GuessState.PartiallyCorrect
+ }
if (!selectedSong) {
alert("Choose a song");
@@ -143,8 +146,7 @@ function App() {
const newGuesses = [...guesses];
newGuesses[currentTry] = {
song: selectedSong,
- skipped: false,
- isCorrect: isCorrect,
+ state: state,
};
return newGuesses;
@@ -153,7 +155,7 @@ function App() {
setCurrentTry((currentTry) => currentTry + 1);
setSelectedSong(undefined);
- if (isCorrect) {
+ if (state === GuessState.Correct) {
setDidGuess(true);
}
}, [guesses, selectedSong]);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage