allow current word to be submitted even if its not in the dictionary

This commit is contained in:
blek 2023-09-21 13:04:04 +10:00
parent f32144a779
commit 9296adaa75
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 10 additions and 4 deletions

View File

@ -11,7 +11,7 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
import Keyboard from "./Keyboard.svelte"; import Keyboard from "./Keyboard.svelte";
import GameCreator from "./GameCreator.svelte"; import GameCreator from "./GameCreator.svelte";
import { decode } from "./lib/cipher"; import { V1 } from "./lib/cipher";
import { GameState, updateScriptInterface } from "./lib/scriptinterface"; import { GameState, updateScriptInterface } from "./lib/scriptinterface";
let targets = getForNWord(5); let targets = getForNWord(5);
@ -79,7 +79,7 @@
function submitGuess() { function submitGuess() {
if (word_position != word.length) return updateState(); if (word_position != word.length) return updateState();
if (!isIn(current_word())) { if (!isIn(current_word()) && current_word() != word) {
not_a_word = true; not_a_word = true;
setTimeout(() => {not_a_word = false}, 1000); setTimeout(() => {not_a_word = false}, 1000);
return updateState(); return updateState();
@ -131,11 +131,17 @@
let game_creator = false; let game_creator = false;
( (
function() { async function() {
const urlprops = new URLSearchParams(window.location.search); const urlprops = new URLSearchParams(window.location.search);
const challenge = urlprops.get('challenge'); const challenge = urlprops.get('challenge');
if (challenge !== null) { if (challenge !== null) {
word = decode(atob(decodeURIComponent(challenge))); let data = atob(decodeURIComponent(challenge)).split(';');
if (data.length != 3) return;
// @ts-expect-error
data[0] = parseInt(data[0]);
// @ts-expect-error
word = await V1.decode(data);
updateState(); updateState();
} }
} }