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

fromCodefunction

A game from its code or its JSON: the same as fromJSON, under the name that pairs with toCode.

Import it

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

Definition

function fromCode(text: string): ReadGame | null

Parameters

NameTypeDescription
textstring

The notation, encoded state or saved text to read.

Returns

ReadGame | null

The reconstructed game, or null when the code or JSON does not represent a supported legal game.

Examples

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

const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(fromCode(toCode("hearts", game))?.kind);
hearts

What it prints (run when this page was built)

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