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

playShiritorifunction

Judges one word against the readings played so far.

Import it

import { playShiritori } from "@johnmorrisdotca/kotoba";

Definition

function playShiritori(played: readonly string[], reading: string, rules?: ShiritoriRules): ShiritoriPlay

Parameters

NameTypeDescription
playedreadonly string[]

The readings so far, oldest first; empty for the first word.

readingstring

The reading of the word now said.

rules (optional)ShiritoriRules

House rules; the forgiving ones if left out.

Returns

ShiritoriPlay

Whether the word stands, where it leaves the chain, or why it was refused.

Examples

import { playShiritori } from "@johnmorrisdotca/kotoba";

console.log(playShiritori(["さくら"], "らくだ"), playShiritori(["さくら"], "いぬ"), playShiritori(["さくら"], "らいおん"));
{ ok: true, loses: false, next: 'た' } { ok: false, why: 'wrong-start' } { ok: true, loses: true, next: null }

What it prints (run when this page was built)

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