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 · Cards, hands and piles

mixCardsfunction

A hand mixed up, as a new list: the same cards in another order, never the order given (where a hand has two cards or more that differ), so a mix is always seen to change something. random is any source of numbers in [0, 1); unless given, Math.random.

Import it

import { mixCards } from "@johnmorrisdotca/toranpu/element";

Also exported from: @johnmorrisdotca/toranpu/element/define

Definition

function mixCards(cards: readonly string[], random?: () => number): string[]

Parameters

NameTypeDescription
cardsreadonly string[]

The cards in their current order.

random (optional)() => number

A source of numbers in [0, 1), such as seededRandom(seed).

Returns

string[]

A hand mixed up, as a new list: the same cards in another order, never the order given (where a hand has two cards or more that differ), so a mix is always seen to change something. random is any source of numbers in [0, 1); unless given, Math.random.

Examples

import { mixCards } from "@johnmorrisdotca/toranpu/element";
import { seededRandom } from "@johnmorrisdotca/toranpu/deck";

console.log(mixCards(["AS", "KH", "TD"], seededRandom(42)));
[ 'TD', 'AS', 'KH' ]

What it prints (run when this page was built)

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