From 7ce90dc0693d078da6fec9ae2a4a0c8410c6f703 Mon Sep 17 00:00:00 2001 From: Daniel Kunkler Date: Mon, 24 Jan 2022 23:08:52 -0600 Subject: [PATCH 1/3] Changes to make easier levels --- src/App.tsx | 38 ++++++++++++++++++++++++++++++++------ src/Game.tsx | 16 ++++++++++------ src/clue.ts | 2 +- src/util.ts | 2 ++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d1ba9e5e1..5b7bc6c53 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import "./App.css"; -import { maxGuesses, seed } from "./util"; +import { Difficulty, maxGuesses, seed } from "./util"; import Game from "./Game"; import { useEffect, useState } from "react"; import { About } from "./About"; @@ -33,7 +33,28 @@ function App() { window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches; const [dark, setDark] = useSetting("dark", prefersDark); - const [difficulty, setDifficulty] = useSetting("difficulty", 0); + const [difficulty, setDifficulty] = useSetting("difficulty", 2); + const [titleFormat, setTitleFormat] = useState("inherit"); + + useEffect(() => { + switch (difficulty) { + case 0: + setTitleFormat("#23eb2a"); + break; + case 1: + setTitleFormat("#94eb97"); + break; + case 2: + setTitleFormat("inherit"); + break; + case 3: + case 4: + setTitleFormat("#e66"); + break; + default: + setTitleFormat("inherit"); + } + }, [difficulty]); useEffect(() => { document.body.className = dark ? "dark" : ""; @@ -60,8 +81,9 @@ function App() {

0 ? "#e66" : "inherit", - fontStyle: difficulty > 1 ? "italic" : "inherit", + color: titleFormat, + fontStyle: + difficulty === Difficulty.UltraHard ? "italic" : "inherit", }} > hell @@ -115,14 +137,16 @@ function App() { id="difficulty-setting" type="range" min="0" - max="2" + max="4" value={difficulty} onChange={(e) => setDifficulty(+e.target.value)} />
  - {["Normal", "Hard", "Ultra Hard"][difficulty]} + + {["Baby", "Easy", "Normal", "Hard", "Ultra Hard"][difficulty]} +
{ [ + `Guesses don't even need to be real words.`, + `Guesses must be valid dictionary words. Easy mode.`, `Guesses must be valid dictionary words.`, `Wordle's "Hard Mode". Green letters must stay fixed, and yellow letters must be reused.`, `An even stricter Hard Mode. Yellow letters must move away from where they were clued, and gray clues must be obeyed.`, diff --git a/src/Game.tsx b/src/Game.tsx index d30457a57..6166f31f3 100644 --- a/src/Game.tsx +++ b/src/Game.tsx @@ -27,12 +27,14 @@ interface GameProps { difficulty: Difficulty; } +const easyTargets = targetList.slice(0, targetList.indexOf("revel") + 1); // Slightly more frequent word on the list const targets = targetList.slice(0, targetList.indexOf("murky") + 1); // Words no rarer than this one const minWordLength = 4; const maxWordLength = 11; -function randomTarget(wordLength: number): string { - const eligible = targets.filter((word) => word.length === wordLength); +function randomTarget(wordLength: number, difficulty: number): string { + const target = difficulty < Difficulty.Normal ? easyTargets : targets; + const eligible = target.filter((word) => word.length === wordLength); let candidate: string; do { candidate = pick(eligible); @@ -77,7 +79,7 @@ function Game(props: GameProps) { ); const [target, setTarget] = useState(() => { resetRng(); - return challenge || randomTarget(wordLength); + return challenge || randomTarget(wordLength, props.difficulty); }); const [gameNumber, setGameNumber] = useState(1); const tableRef = useRef(null); @@ -90,7 +92,7 @@ function Game(props: GameProps) { const newWordLength = wordLength < minWordLength || wordLength > maxWordLength ? 5 : wordLength; setWordLength(newWordLength); - setTarget(randomTarget(newWordLength)); + setTarget(randomTarget(newWordLength, props.difficulty)); setGuesses([]); setCurrentGuess(""); setHint(""); @@ -143,7 +145,9 @@ function Game(props: GameProps) { setHint("Too short"); return; } - if (!dictionary.includes(currentGuess)) { + + // Baby will short circuit to false + if (props.difficulty && !dictionary.includes(currentGuess)) { setHint("Not a valid word"); return; } @@ -244,7 +248,7 @@ function Game(props: GameProps) { setGameState(GameState.Playing); setGuesses([]); setCurrentGuess(""); - setTarget(randomTarget(length)); + setTarget(randomTarget(length, props.difficulty)); setWordLength(length); setHint(`${length} letters`); }} diff --git a/src/clue.ts b/src/clue.ts index aeed2e1a0..074b6ca6c 100644 --- a/src/clue.ts +++ b/src/clue.ts @@ -63,7 +63,7 @@ export function violation( clues: CluedLetter[], guess: string ): string | undefined { - if (difficulty === Difficulty.Normal) { + if (difficulty <= Difficulty.Normal) { return undefined; } const ultra = difficulty === Difficulty.UltraHard; diff --git a/src/util.ts b/src/util.ts index 289799bbf..3a43a9777 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,8 @@ import dictionary from "./dictionary.json"; export enum Difficulty { + Baby, + Easy, Normal, Hard, UltraHard, From b4fb4eb3bae3a7c929c507e8b7a2d50b3d943a2d Mon Sep 17 00:00:00 2001 From: Daniel Kunkler Date: Mon, 7 Feb 2022 21:39:20 -0600 Subject: [PATCH 2/3] fix(game difficulty) Update the baby dictionary filter to be less ambiguous[feature request 44' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rory O’Kane --- src/Game.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Game.tsx b/src/Game.tsx index ff4eb9494..62226ef80 100644 --- a/src/Game.tsx +++ b/src/Game.tsx @@ -148,8 +148,7 @@ function Game(props: GameProps) { return; } - // Baby will short circuit to false - if (props.difficulty && !dictionary.includes(currentGuess)) { + if (props.difficulty !== Difficulty.Baby && !dictionary.includes(currentGuess)) { setHint("Not a valid word"); return; } From c5d9c1153d1811c2da729c9424e6cb7781753947 Mon Sep 17 00:00:00 2001 From: Daniel Kunkler Date: Mon, 7 Feb 2022 21:51:40 -0600 Subject: [PATCH 3/3] fix(app) removed extra line [fr 44] --- src/App.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 3ab21f59b..2cb35fc6d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -162,7 +162,6 @@ function App() { {["Baby", "Easy", "Normal", "Hard", "Ultra Hard"][difficulty]} - {["Normal", "Hard", "Ultra Hard"][difficulty]}