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 · Cribbage

decodeCribbagefunction

Text read back into the game of Cribbage it records, by playing every move again through the rules; null for anything they cannot play out.

Import it

import { decodeCribbage } from "@johnmorrisdotca/toranpu/cribbage";

Definition

function decodeCribbage(text: string | null): CribbageGame | null

Parameters

NameTypeDescription
textstring | null

The notation, encoded state or saved text to read.

Returns

CribbageGame | null

Text read back into the game of Cribbage it records, by playing every move again through the rules; null for anything they cannot play out.

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { decodeCribbage, encodeCribbage } from "@johnmorrisdotca/toranpu/cribbage";

const names = Array.from({ length: CARD_GAME_TABLES.cribbage.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("cribbage", { players: names, seed: 42 })!;
console.log(decodeCribbage(encodeCribbage(game))?.phase);
crib

What it prints (run when this page was built)

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