Skip to the content

Kotoba言葉

Load only the word lists you need, mark repeated letters correctly and play a daily or seeded word game.

Kotoba is the Japanese word for words. About the name

Contents

Reference · Playable game

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

NameTypeDescription
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.

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

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kotoba 1.2.0.