本文へ移動

Kotoba言葉

必要な単語一覧だけを読み込み、重複する文字を正しく判定し、日替わりやシード付きの単語ゲームを遊べます。

「Kotoba」は「言葉」です。 名前について(英語)

目次

リファレンス · 判定・得点・ゲームのルール

WordGame型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A round.

インポート

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

定義

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;
};

メンバー

名前型説明
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.

例

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
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/kotoba 1.2.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。