KotobaPlaytype
A mounted game.
Import it
import type { KotobaPlay } from "@johnmorrisdotca/kotoba/play";
Definition
type KotobaPlay = {
readonly game: WordGame | null;
readonly ready: Promise<void>;
newGame(next?: KotobaNewGame): Promise<void>;
setLocale(locale: Language): void;
destroy(): void;
};
Members
| Name | Type | Description |
|---|---|---|
game | WordGame | null | The round being played, or null while a list is loading. |
ready | Promise<void> | Settles once the first round is dealt (or the list could not be had). |
newGame | (next?: KotobaNewGame): Promise<void> | Deal a new round, changing the choices given and keeping the rest. Settles once it is dealt. |
setLocale | (locale: Language): void | Change the language of the game's own words, at once. |
destroy | (): void | Take the game off the page and stop listening to the keyboard. |
Examples
import { startWordGame } from "@johnmorrisdotca/kotoba";
import type { KotobaPlay } from "@johnmorrisdotca/kotoba/play";
import { mountKotoba } from "@johnmorrisdotca/kotoba/play";
const game = startWordGame("en",5,"apple");
const host = document.createElement("div");
document.body.append(host);
const play: KotobaPlay = mountKotoba(host,{words:"en",size:5,hidden:"apple",keyboard:false});
await play.ready;
console.log(play.game?.status);
play.destroy();