I think this is the right rule
This commit is contained in:
parent
e07726f71c
commit
e9a29122c9
17
src/App.tsx
17
src/App.tsx
|
@ -38,6 +38,7 @@ function App() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.body.className = dark ? "dark" : "";
|
document.body.className = dark ? "dark" : "";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// Avoid transition on page load
|
||||||
document.body.style.transition = "0.3s background-color ease-out";
|
document.body.style.transition = "0.3s background-color ease-out";
|
||||||
}, 1);
|
}, 1);
|
||||||
}, [dark]);
|
}, [dark]);
|
||||||
|
@ -58,14 +59,10 @@ function App() {
|
||||||
<div className="App-container">
|
<div className="App-container">
|
||||||
<h1>
|
<h1>
|
||||||
<span
|
<span
|
||||||
style={
|
style={{
|
||||||
difficulty > 0
|
color: difficulty > 0 ? "#e66" : "inherit",
|
||||||
? {
|
fontStyle: difficulty > 1 ? "italic" : "inherit",
|
||||||
color: "#e66",
|
}}
|
||||||
textShadow: difficulty > 1 ? "0px 0px 5px #e66" : "none",
|
|
||||||
}
|
|
||||||
: {}
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
hell
|
hell
|
||||||
</span>
|
</span>
|
||||||
|
@ -136,9 +133,9 @@ function App() {
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
[
|
[
|
||||||
`No restrictions on guesses.`,
|
`Guesses must be valid dictionary words.`,
|
||||||
`Wordle's "Hard Mode". Green letters must stay fixed, and yellow letters must be reused.`,
|
`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.`,
|
`An even stricter Hard Mode. Yellow letters must move away from where they were clued, and gray clues must be obeyed.`,
|
||||||
][difficulty]
|
][difficulty]
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
16
src/clue.ts
16
src/clue.ts
|
@ -1,4 +1,4 @@
|
||||||
import { Difficulty, ordinal } from "./util";
|
import { Difficulty, englishNumbers, ordinal } from "./util";
|
||||||
|
|
||||||
export enum Clue {
|
export enum Clue {
|
||||||
Absent,
|
Absent,
|
||||||
|
@ -71,9 +71,17 @@ export function violation(
|
||||||
const upper = letter.toUpperCase();
|
const upper = letter.toUpperCase();
|
||||||
const nth = ordinal(i + 1);
|
const nth = ordinal(i + 1);
|
||||||
if (clue === Clue.Absent) {
|
if (clue === Clue.Absent) {
|
||||||
// if (difficulty === Difficulty.UltraHard && guess.includes(letter)) {
|
if (difficulty === Difficulty.UltraHard) {
|
||||||
// return "Guess can't contain " + upper;
|
const max = clues.filter(
|
||||||
// }
|
(c) => c.letter === letter && c.clue !== Clue.Absent
|
||||||
|
).length;
|
||||||
|
const count = guess.split(letter).length - 1;
|
||||||
|
if (count > max) {
|
||||||
|
const amount = max ? `more than ${englishNumbers[max]} ` : "";
|
||||||
|
const s = max > 1 ? "s" : "";
|
||||||
|
return `Guess can't contain ${amount}${upper}${s}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (clue === Clue.Correct) {
|
} else if (clue === Clue.Correct) {
|
||||||
if (guess[i] !== letter) {
|
if (guess[i] !== letter) {
|
||||||
return nth + " letter must be " + upper;
|
return nth + " letter must be " + upper;
|
||||||
|
|
|
@ -59,3 +59,6 @@ export function speak(
|
||||||
export function ordinal(n: number): string {
|
export function ordinal(n: number): string {
|
||||||
return n + ([, "st", "nd", "rd"][(n % 100 >> 3) ^ 1 && n % 10] || "th");
|
return n + ([, "st", "nd", "rd"][(n % 100 >> 3) ^ 1 && n % 10] || "th");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const englishNumbers =
|
||||||
|
"zero one two three four five six seven eight nine ten eleven".split(" ");
|
||||||
|
|
Loading…
Reference in a new issue