KotobaPlay型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A mounted game.
インポート
import type { KotobaPlay } from "@johnmorrisdotca/kotoba/play";
定義
type KotobaPlay = {
readonly game: WordGame | null;
readonly ready: Promise<void>;
newGame(next?: KotobaNewGame): Promise<void>;
setLocale(locale: Language): void;
destroy(): void;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
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. |
例
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();この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。