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

fromJSONfunction

A game from text that toJSON or toCode wrote, whichever game it is. Nothing in it is trusted: every move is played through the rules again, and a move the rules refuse means the text is not a game. Null for text that is not JSON, names no game, is of a later format than this version reads, or cannot be played out.

Import it

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

Definition

function fromJSON(text: string): ReadGame | null

Parameters

NameTypeDescription
textstring

The notation, encoded state or saved text to read.

Returns

ReadGame | null

A game from text that toJSON or toCode wrote, whichever game it is. Nothing in it is trusted: every move is played through the rules again, and a move the rules refuse means the text is not a game. null for text that is not JSON, names no game, is of a later format than this version reads, or cannot be played out.

Examples

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

const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(fromJSON(toJSON("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.