diff --git a/src/game.rs b/src/game.rs index a45dda5..827c5c5 100644 --- a/src/game.rs +++ b/src/game.rs @@ -229,4 +229,10 @@ impl Game { } + pub fn add_word(&mut self, word: String) { + let word = word.to_uppercase(); + + self.dictionary.insert(word, -1.0); + } + } \ No newline at end of file diff --git a/src/wasm.rs b/src/wasm.rs index 40c3b8e..cc42b0a 100644 --- a/src/wasm.rs +++ b/src/wasm.rs @@ -126,5 +126,9 @@ impl GameWasm { } + pub fn add_word(&mut self, word: String) { + self.0.add_word(word); + } + } \ No newline at end of file diff --git a/ui/src/Game.tsx b/ui/src/Game.tsx index fc17b7b..b3fce4c 100644 --- a/ui/src/Game.tsx +++ b/ui/src/Game.tsx @@ -124,6 +124,11 @@ export function Game(props: {wasm: GameWasm, settings: Settings}) { } + function addWordFn(word: string) { + props.wasm.add_word(word); + logDispatch(
{word} was added to dictionary.
); + } + return <> {(result.value as string)}); + const message = result.value as string; + if (message.endsWith("is not a valid word")) { + // extract out word + const word = message.split(" ")[0]; + logDispatch(
{message}
); + } else { + logDispatch(
{message}
); + } + } else { let total_points = 0; @@ -202,5 +215,17 @@ export function Game(props: {wasm: GameWasm, settings: Settings}) { }}>Return Tiles ; - } + +function AddWordButton(props: {word: string, addWordFn: (x: string) => void}) { + const [isClicked, setIsClicked] = useState(false); + + return +} \ No newline at end of file