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
| Name | Type | Description |
|---|---|---|
cards | readonly string[] | The cards in their current order. |
card | string | The physical card or card id to read, draw or play. |
next | string | 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)