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
| Name | Type | Description |
|---|---|---|
cards | readonly 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)