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 · Gin Rummy

GinGametype

A GAME OF GIN RUMMY: its table and moves (what is kept), and the hand they have reached. Two seats. size is the score that wins: 50, 100 or 150.

Import it

import type { GinGame } from "@johnmorrisdotca/toranpu/gin-rummy";

Definition

type GinGame = KeptCardGame<GinMove> & {
    hand: number;
    phase: "draw" | "discard" | "over";
    hands: CardId[][];
    stock: CardId[];
    discard: CardId[];
    taken: CardId | null;
    toPlay: number | null;
    picked: CardId[][];
    throws: number;
    scores: number[];
    results: GinResult[];
};

Members

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

Which hand this is, from 0: the first to play alternates.

phase"over" | "discard" | "draw"

Drawing a card, throwing one, or the game over.

handsstring[][]
stockstring[]

The stock, face down, top card first.

discardstring[]

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

takenstring | null

The card just taken from the discard pile, which may not be thrown straight back; null otherwise.

toPlaynumber | null
pickedstring[][]

The cards each seat has taken from the discard pile this hand and still holds: what the whole table watched them take.

throwsnumber

The cards thrown this hand so far: a new hand shows how the last was laid down until each player has thrown once.

scoresnumber[]
resultsGinResult[]

Examples

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { GinGame } from "@johnmorrisdotca/toranpu/gin-rummy";

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

What it prints (run when this page was built)

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