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 · Crazy Eights

decodeCrazyEightsfunction

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

Import it

import { decodeCrazyEights } from "@johnmorrisdotca/toranpu/crazy-eights";

Definition

function decodeCrazyEights(text: string | null): CrazyEightsGame | null

Parameters

NameTypeDescription
textstring | null

The notation, encoded state or saved text to read.

Returns

CrazyEightsGame | null

Text read back into the game of Crazy Eights 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 { decodeCrazyEights, encodeCrazyEights } from "@johnmorrisdotca/toranpu/crazy-eights";

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

What it prints (run when this page was built)

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