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

submitWordGamefunction

The guess being typed sent in, now being the time in milliseconds. Kana still waiting as romaji are finished first (finishRomaji). A guess that is too short, or not in the list, is not taken: the round comes back with what was typed kept, and says why. A guess that is taken ends the round when it is the hidden word or the last guess, and the round is then scored.

Import it

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

Definition

function submitWordGame(game: WordGame, words: WordGameWords, now?: number): WordGameSubmit

Parameters

NameTypeDescription
gameWordGame

The current immutable word-game state.

wordsWordGameWords

The ordered nonempty word pool or accepted-guess dictionary specified by the signature.

now (optional)number

Host clock time in milliseconds.

Returns

WordGameSubmit

The guess being typed sent in, now being the time in milliseconds. Kana still waiting as romaji are finished first (finishRomaji). A guess that is too short, or not in the list, is not taken: the round comes back with what was typed kept, and says why. A guess that is taken ends the round when it is the hidden word or the last guess, and the round is then scored.

Examples

import { readWordLists, startWordGame, submitWordGame, typeWordGame } from "@johnmorrisdotca/kotoba";
import { EN_WORDS } from "@johnmorrisdotca/kotoba/words-en";

const wordLists = readWordLists(EN_WORDS,5)!;
const game = startWordGame("en",5,"apple");
const typed = [..."apple"].reduce((state,key)=>typeWordGame(state,key,1000),game);
const submitted = submitWordGame(typed,wordLists,20000);
console.log(submitted);
{
  game: {
    language: 'en',
    size: 5,
    rows: 6,
    hidden: 'apple',
    guesses: [ 'apple' ],
    typed: [],
    pending: '',
    status: 'won',
    startedAt: 1000,
    score: { placed: 300, elsewhere: 0, found: 425, speed: 50, total: 775 }
  },
  refused: null
}

What it prints (run when this page was built)

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