properly handle non-5 custom words

This commit is contained in:
blek 2023-09-21 13:08:25 +10:00
parent 8592d93446
commit 4bc83730ea
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 15 additions and 5 deletions

View File

@ -27,10 +27,6 @@
let green_letters: string[] = [];
let yellow_letters: string[] = [];
let unfit_letters: string[] = [];
for (let i = 0; i != guesses; i++) {
guessed.push(new Array(word.length).fill(''));
}
globalThis.ScriptInterface.gameState.set_current_word = word2 => {
if (!globalThis.ScriptInterface.scriptsAllowed())
@ -79,7 +75,11 @@
function submitGuess() {
if (word_position != word.length) return updateState();
if (!isIn(current_word()) && current_word() != word) {
if (
!isIn(current_word()) &&
current_word() != word &&
word.length > 3 && word.length < 11
) {
not_a_word = true;
setTimeout(() => {not_a_word = false}, 1000);
return updateState();
@ -142,6 +142,12 @@
// @ts-expect-error
word = await V1.decode(data);
guessed = [];
for (let i = 0; i != guesses; i++) {
guessed.push(new Array(word.length).fill(''));
}
updateState();
}
}
@ -201,6 +207,10 @@
unfit_letters = [];
updateState();
}
for (let i = 0; i != guesses; i++) {
guessed.push(new Array(word.length).fill(''));
}
</script>
<GameCreator bind:show={game_creator} />