allow uncommon words for first guess
This commit is contained in:
parent
0436347f7d
commit
b18c03234a
2 changed files with 10678 additions and 11 deletions
|
@ -5,7 +5,7 @@ import * as wasm from 'web-optimle';
|
|||
import { clue, describeClue, type Clue, type GuessResult } from './clue';
|
||||
import { gameName, speak } from './util';
|
||||
|
||||
import { DICTIONARY } from './dictionary';
|
||||
import { COMMON_WORDS, UNCOMMON_WORDS } from './dictionary';
|
||||
import * as PUZZLES from './puzzles.json';
|
||||
import { Row, RowState } from './Row';
|
||||
import { Keyboard } from './Keyboard';
|
||||
|
@ -41,14 +41,11 @@ export function Game(props: GameProps) {
|
|||
const [tryNumber, setTryNumber] = useState(1);
|
||||
const [hint, setHint] = useState<JSX.Element | string>(
|
||||
<p>
|
||||
Try to guarantee a win in <strong>2 guesses,</strong> no matter the word!
|
||||
<br />
|
||||
<br />
|
||||
Today's puzzle (#{puzzle.seed}) has {puzzle.solutions} solution{puzzle.solutions === 1 ? '' : 's'}.
|
||||
Try to guarantee a win in <strong>2 guesses</strong>!
|
||||
</p>
|
||||
);
|
||||
const tableRef = useRef<HTMLTableElement>(null);
|
||||
const game = useMemo(() => wasm.Game.new(DICTIONARY, puzzle.history), []);
|
||||
const game = useMemo(() => wasm.Game.new(COMMON_WORDS, puzzle.history), []);
|
||||
const reset = useCallback(() => {
|
||||
game.reset();
|
||||
setGuesses([...puzzle.history]);
|
||||
|
@ -103,9 +100,16 @@ export function Game(props: GameProps) {
|
|||
setHint("Too short");
|
||||
return;
|
||||
}
|
||||
if (!DICTIONARY.includes(currentGuess)) {
|
||||
setHint("Not a valid word");
|
||||
return;
|
||||
if (!COMMON_WORDS.includes(currentGuess)) {
|
||||
if (!UNCOMMON_WORDS.includes(currentGuess)) {
|
||||
setHint("Not a valid word");
|
||||
return;
|
||||
} else if (guesses.length === puzzle.history.length) {
|
||||
setHint("(Uncommon word allowed for first guess)");
|
||||
} else {
|
||||
setHint("(Uncommon word not allowed for second guess)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const g of guesses) {
|
||||
const c = clue(g);
|
||||
|
@ -223,6 +227,9 @@ export function Game(props: GameProps) {
|
|||
</button>
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
Today's puzzle (#{puzzle.seed}) has {puzzle.solutions} path{puzzle.solutions === 1 ? '' : 's'} to a win.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue