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 · Marking, scores and game rules

WordGametype

A round.

Import it

import type { WordGame } from "@johnmorrisdotca/kotoba";

Definition

type WordGame = {
    language: WordGameLanguage;
    size: number;
    rows: number;
    hidden: string;
    guesses: readonly string[];
    typed: readonly string[];
    pending: string;
    status: WordGameStatus;
    startedAt: number | null;
    score: WordScore | null;
};

Members

NameTypeDescription
languageWordGameLanguage
sizenumber

How many letters, or kana, the word has.

rowsnumber

How many guesses the round gives.

hiddenstring

The word to find.

guessesreadonly string[]

The guesses made, each a whole word.

typedreadonly string[]

The letters, or kana, of the guess being typed.

pendingstring

Romaji typed and not yet a kana: k waiting for a vowel. Always empty for letters.

statusWordGameStatus
startedAtnumber | null

When the first key was pressed, in milliseconds, or null before it.

scoreWordScore | null

The score, once the round is over.

Examples

import { startWordGame } from "@johnmorrisdotca/kotoba";
import type { WordGame } from "@johnmorrisdotca/kotoba";

const game = startWordGame("en",5,"apple");
const value: WordGame = game;
console.log(value);
{
  language: 'en',
  size: 5,
  rows: 6,
  hidden: 'apple',
  guesses: [],
  typed: [],
  pending: '',
  status: 'playing',
  startedAt: null,
  score: null
}

What it prints (run when this page was built)

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