Constructor
new CardsJS(proxyopt, optionsopt)
Initializes a new CardsJS instance with the provided options.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
proxy |
Object |
<optional> |
{} | Optional proxy object to override default settings. |
options |
Object |
<optional> |
{} | Custom options for the CardsJS instance. |
Classes
Members
padding :Object
Padding configuration for different types of decks.
Type:
- Object
perspective :Object
A mapping of different perspectives for viewing a deck.
Type:
- Object
playableArea
Gets the playable area for the deck.
Methods
(static) acesHigh(defaultOrder) → {Array}
Adjust the order of the ranks to treat aces as high.
Parameters:
Name | Type | Description |
---|---|---|
defaultOrder |
Array | The default rank order. |
Returns:
The new rank order with aces treated as high.
- Type
- Array
(static) compareByRank(cardA, cardB) → {number}
Comparator function to compare cards by their rank.
Parameters:
Name | Type | Description |
---|---|---|
cardA |
Card | The first card. |
cardB |
Card | The second card. |
Returns:
The result of the comparison.
- Type
- number
(static) compareByRankThenSuit(cardA, cardB) → {number}
Comparator function to compare cards first by rank, then by suit.
Parameters:
Name | Type | Description |
---|---|---|
cardA |
Card | The first card. |
cardB |
Card | The second card. |
Returns:
The result of the comparison.
- Type
- number
(static) compareBySuit(cardA, cardB) → {number}
Comparator function to compare cards by their suit.
Parameters:
Name | Type | Description |
---|---|---|
cardA |
Card | The first card. |
cardB |
Card | The second card. |
Returns:
The result of the comparison.
- Type
- number
(static) compareBySuitThenRank(cardA, cardB) → {number}
Comparator function to compare cards first by suit, then by rank.
Parameters:
Name | Type | Description |
---|---|---|
cardA |
Card | The first card. |
cardB |
Card | The second card. |
Returns:
The result of the comparison.
- Type
- number
(static) generateRanks(ranksopt) → {Array}
Generate an array of ranks from 1 to the specified number.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ranks |
number |
<optional> |
13 | The number of ranks to generate. |
Returns:
The array of ranks.
- Type
- Array
(static) generateSuits(suitsopt) → {Array}
Generate an array of suit indexes.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
suits |
number |
<optional> |
4 | The number of suits to generate. |
Returns:
The array of suit indexes.
- Type
- Array
(static) shuffle(deck) → {Array}
Fisher-Yates shuffle to randomize the order of cards in a deck.
Parameters:
Name | Type | Description |
---|---|---|
deck |
Array | The deck of cards to shuffle. |
Returns:
The shuffled deck.
- Type
- Array