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
| Name | Type | Description |
|---|---|---|
played | readonly string[] | The readings so far, oldest first; empty for the first word. |
reading | string | 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)