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

newGamefunction

A new game of that kind, or null when the game is not offered for that table (too many players, or a size it does not play to).

const game = newGame("hearts", { players: ["You", "Ann", "Ben", "Cy"], computers: [false, true, true, true] });

Import it

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

Definition

function newGame<K extends CardGameKind>(kind: K, options: NewGameOptions): GameOf<K> | null

Parameters

NameTypeDescription
kindK

The named card game or sound kind.

optionsNewGameOptions

Options for this call; omitted fields retain their documented defaults.

Returns

GameOf<K> | null

A new game of that kind, or null when the game is not offered for that table (too many players, or a size it does not play to). ts const game = newGame("hearts", { players: ["You", "Ann", "Ben", "Cy"], computers: [false, true, true, true] });

Examples

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

console.log(newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })?.hands.map((hand) => hand.length));
[ 13, 13, 13, 13 ]

What it prints (run when this page was built)

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