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

KotobaPlayOptionstype

What a round is dealt from, and how the game looks and behaves. Every field may be left out.

Import it

import type { KotobaPlayOptions } from "@johnmorrisdotca/kotoba/play";

Definition

type KotobaPlayOptions = {
    words?: WordListName;
    size?: number;
    easy?: boolean;
    rows?: number;
    seed?: number;
    daily?: boolean | string;
    hidden?: string;
    locale?: Language;
    strings?: Partial<KotobaStrings>;
    theme?: Record<string, string>;
    keyboard?: boolean;
    keyboardTarget?: HTMLElement;
    onFinish?: (game: WordGame) => void;
    onChange?: (game: WordGame | null) => void;
    load?: (words: WordListName, size: number) => Promise<LoadedWordList | null>;
    now?: () => number;
};

Members

NameTypeDescription
words (optional)WordListName | undefined

The list: English, French, German or Japanese kana. Unless said, English.

size (optional)number | undefined

Letters, or kana, in the word. Unless said, five, or four kana.

easy (optional)boolean | undefined

Hide only one of the easy answers. Unless said, any answer.

rows (optional)number | undefined

How many guesses the round gives. Unless said, six.

seed (optional)number | undefined

A seed: the same seed picks the same word from the same list. Unless said, one is drawn.

daily (optional)string | boolean | undefined

The word of the day (dailyWord) instead of a random one: true for today in UTC, or a day written YYYY-MM-DD. Wins over seed.

hidden (optional)string | undefined

The word to find, whatever the lists say: a friend's, or one from your own source. Wins over daily and seed.

locale (optional)Language | undefined

The language of the game's own words: the prompts, the keys and the legend. Unless said, English.

strings (optional)Partial<KotobaStrings> | undefined

Words of your own, over locale's: any of KOTOBA_STRINGS' names.

theme (optional)Record<string, string> | undefined

CSS variables set on the game: { "--kt-hit": "#1a7f37" }.

keyboard (optional)boolean | undefined

Take the device's keyboard (letters, Enter, Backspace) as the keys on the screen. Unless said, yes.

keyboardTarget (optional)HTMLElement | undefined

Listen on this host instead of the document; embedded games use their own focused board.

onFinish (optional)((game: WordGame) => void) | undefined

Called once when a round ends, with the round: its guesses and its score.

onChange (optional)((game: WordGame | null) => void) | undefined

Called after every change of the round, and with null while a list is loading.

load (optional)((words: WordListName, size: number) => Promise<LoadedWordList | null>) | undefined

Where a list comes from. Unless said, loadWordList: the package's own modules.

now (optional)(() => number) | undefined

The time in milliseconds, for the clock a score reads. Unless said, Date.now.

Examples

import type { KotobaPlayOptions } from "@johnmorrisdotca/kotoba/play";
const optionsFor = (host: HTMLElement): KotobaPlayOptions => ({ keyboardTarget: host });
console.log(typeof optionsFor); // function
function

What it prints (run when this page was built)

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