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

CribbageGametype

A GAME OF CRIBBAGE: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is. Two seats; size is the score that wins, 61 or 121.

Import it

import type { CribbageGame } from "@johnmorrisdotca/toranpu/cribbage";

Definition

type CribbageGame = KeptCardGame<CribbageMove> & {
    deal: number;
    phase: CribbagePhase;
    hands: CardId[][];
    kept: CardId[][];
    crib: CardId[];
    cut: CardId;
    starter: CardId | null;
    count: number;
    run: CribbagePlay[];
    pegged: CribbagePlay[];
    peg: CribbagePeg | null;
    toPlay: number | null;
    scores: [
        number,
        number
    ];
    results: CribbageHandScore[];
};

Members

NameTypeDescription
sizenumber
playersreadonly string[]
computersreadonly boolean[]
seednumber
movesreadonly CribbageMove[]
dealnumber

Which hand this is, from 0: the deal goes to the other player each time.

phaseCribbagePhase
handsstring[][]

The cards each seat still holds: six dealt, four kept, then played away in the pegging.

keptstring[][]

The four cards each seat kept, as they will be shown.

cribstring[]
cutstring

The card to be cut once the crib is laid: face down until then, so never shown.

starterstring | null

The starter, once cut.

countnumber

The pegging count, 0 to 31.

runCribbagePlay[]

The cards played since the count last went back to nought.

peggedCribbagePlay[]

Every card played in the pegging this hand.

pegCribbagePeg | null

What the last card played scored, if it scored.

toPlaynumber | null
scores[number, number]
resultsCribbageHandScore[]

Each hand shown, one row a hand.

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { CribbageGame } from "@johnmorrisdotca/toranpu/cribbage";

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

What it prints (run when this page was built)

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