本文へ移動

Kotoba言葉

必要な単語一覧だけを読み込み、重複する文字を正しく判定し、日替わりやシード付きの単語ゲームを遊べます。

「Kotoba」は「言葉」です。 名前について(英語)

目次

リファレンス · 遊べるゲーム

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;
};

メンバー

名前型説明
gameWordGame | null

The round being played, or null while a list is loading.

readyPromise<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();

ソースを見るGitHub で編集@johnmorrisdotca/kotoba 1.2.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。