Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Impossible Mode (Issue 84) #96

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ table.Game-rows > tbody {
color: white !important;
}

.letter-red {
border: 2px solid rgba(0, 0, 0, 0.3);
background-color: #ff0000;
color: white !important;
}

body.dark {
background-color: #404040;
color: #e0e0e0;
Expand Down
6 changes: 4 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function App() {
style={{
color: difficulty > 0 ? "#e66" : "inherit",
fontStyle: difficulty > 1 ? "italic" : "inherit",
fontStyle: difficulty > 2 ? "bold" : "inherit", // I have no idea what this syntax means. I'm just mimicing and hoping for the best
}}
>
hell
Expand Down Expand Up @@ -126,13 +127,13 @@ function App() {
id="difficulty-setting"
type="range"
min="0"
max="2"
max="3"
value={difficulty}
onChange={(e) => setDifficulty(+e.target.value)}
/>
<div>
<label htmlFor="difficulty-setting">Difficulty:</label>
<strong>{["Normal", "Hard", "Ultra Hard"][difficulty]}</strong>
<strong>{["Normal", "Hard", "Ultra Hard", "IMPOSSIBLE"][difficulty]}</strong>
<div
style={{
fontSize: 14,
Expand All @@ -146,6 +147,7 @@ function App() {
`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.`,
`By far the hardest mode. You are only given a full row of red if you guess incorrectly, with absolutely no feedback. There's a reason it's called Impossible.`
][difficulty]
}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ function Game(props: GameProps) {
<button
onClick={() => {
const emoji = props.colorBlind
? ["⬛", "🟦", "🟧"]
: ["⬛", "🟨", "🟩"];
? ["⬛", "🟦", "🟧", "🟧"]
: ["⬛", "🟨", "🟩", "🟧"];
share(
"Result copied to clipboard!",
guesses
Expand Down
8 changes: 8 additions & 0 deletions src/clue.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Difficulty, englishNumbers, ordinal } from "./util";

const impossible = difficulty === Difficulty.Impossible;
export enum Clue {
Absent,
Elsewhere,
Correct,
Red,
}

export interface CluedLetter {
Expand All @@ -20,6 +22,9 @@ export function clue(word: string, target: string): CluedLetter[] {
});
return word.split("").map((letter, i) => {
let j: number;
if (impossible && word !== target) { // Make sure the guess doesn't match the target word before filling with red
return { clue: Clue.Red, letter };
}
if (target[i] === letter) {
return { clue: Clue.Correct, letter };
} else if ((j = elusive.indexOf(letter)) > -1) {
Expand All @@ -37,6 +42,8 @@ export function clueClass(clue: Clue): string {
return "letter-absent";
} else if (clue === Clue.Elsewhere) {
return "letter-elsewhere";
} else if (clue === Clue.Red) {
return "letter-red";
} else {
return "letter-correct";
}
Expand All @@ -58,6 +65,7 @@ export function describeClue(clue: CluedLetter[]): string {
.join(", ");
}

// Impossible difficulty has no need for restricting usable guesses
export function violation(
difficulty: Difficulty,
clues: CluedLetter[],
Expand Down
1 change: 1 addition & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum Difficulty {
Normal,
Hard,
UltraHard,
Impossible,
}

export const maxGuesses = 6;
Expand Down