Skip to the content

Toranpuトランプ

Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

Reference · Games and state

toTextfunction

A game as a record a person can read: a heading, a numbered line a move with who made it, and how it stands. In English unless said.

It names every card, the ones passed face down too. It is a record for afterwards, not something to show a player while the game is on.

Import it

import { toText } from "@johnmorrisdotca/toranpu";

Definition

function toText<K extends CardGameKind>(kind: K, game: GameOf<K>, language?: Language): string

Parameters

NameTypeDescription
kindK

The named card game or sound kind.

gameGameOf<K>

The current native game; applying a move returns a new state.

language (optional)Language

English or Japanese for the displayed words.

Returns

string

A game as a record a person can read: a heading, a numbered line a move with who made it, and how it stands. In English unless said. It names every card, the ones passed face down too. It is a record for afterwards, not something to show a player while the game is on.

Examples

import { newGame, toText } from "@johnmorrisdotca/toranpu";

const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(toText("hearts", game));
Hearts for 4, seed 42: Aki, Ben, Cy, Dev
Not over. Aki to play.

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.15.0.