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

CrazyEightsGametype

A GAME OF CRAZY EIGHTS: its table and moves (what is kept), and the hand they have reached. size is the score that wins: 50, 100 or 200.

Import it

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

Definition

type CrazyEightsGame = KeptCardGame<CrazyEightsMove> & {
    hand: number;
    phase: "playing" | "over";
    hands: CardId[][];
    stock: CardId[];
    discard: CardId[];
    suit: CardSuit;
    toPlay: number | null;
    drawn: CardId | null;
    passes: number;
    turnovers: number;
    scores: number[];
    results: CrazyEightsResult[];
};

Members

NameTypeDescription
sizenumber
playersreadonly string[]
computersreadonly boolean[]
seednumber
movesreadonly CrazyEightsMove[]
handnumber

Which hand this is, from 0: it decides who plays first, round the table.

phase"playing" | "over"
handsstring[][]
stockstring[]

The stock, face down, top card first.

discardstring[]

The discard pile, face up, the top card last.

suitCardSuit

The suit to follow: the top card's, or the one called when an eight was played.

toPlaynumber | null
drawnstring | null

The card the player to move has just drawn, the only one they may now play; null before they draw.

passesnumber

Turns passed in a row with nothing to draw: when every player has, the hand is blocked.

turnoversnumber

How many times the discards have been shuffled into a new stock this hand.

scoresnumber[]

Each seat's points so far: the first to the game's size wins.

resultsCrazyEightsResult[]

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { CrazyEightsGame } from "@johnmorrisdotca/toranpu/crazy-eights";

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

What it prints (run when this page was built)

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