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 · Games and state

dealRoundfunction

Deals the cards one at a time round the table, from the first seat, as a dealer does: each to a seat, or every card when each is absent (so some seats hold one more than others). What is not dealt is the stock, in order, its top card first.

Import it

import { dealRound } from "@johnmorrisdotca/toranpu";

Definition

function dealRound(deck: readonly CardId[], seats: number, each?: number): { hands: CardId[][]; stock: CardId[]; }

Parameters

NameTypeDescription
deckreadonly string[]

The deck in its current order; the input is left unchanged.

seatsnumber

The seat count or seat state supplied by this API.

each (optional)number | undefined

The number of cards dealt to each hand.

Returns

{ hands: CardId[][]; stock: CardId[]; }

Deals the cards one at a time round the table, from the first seat, as a dealer does: each to a seat, or every card when each is absent (so some seats hold one more than others). What is not dealt is the stock, in order, its top card first.

Examples

import { FULL_DECK, dealRound } from "@johnmorrisdotca/toranpu";

console.log(dealRound(FULL_DECK, 4, 5).hands.map((hand) => hand.length));
[ 5, 5, 5, 5 ]

What it prints (run when this page was built)

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