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

replaceCardfunction

A hand with one card tossed out and another given in its stead, at the front or the end: as a new list. Unchanged where it holds no such card.

Import it

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

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

Definition

function replaceCard(cards: readonly string[], card: string, next: string, lands?: CardLands): string[]

Parameters

NameTypeDescription
cardsreadonly string[]

The cards in their current order.

cardstring

The physical card or card id to read, draw or play.

nextstring

The replacement card or next state.

lands (optional)CardLands

Where a replacement card is placed in the hand.

Returns

string[]

A hand with one card tossed out and another given in its stead, at the front or the end: as a new list. Unchanged where it holds no such card.

Examples

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

console.log(replaceCard(["AS", "KH"], "AS", "2D"));
[ 'KH', '2D' ]

What it prints (run when this page was built)

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