Class: CardsJS

CardsJS(proxyopt, optionsopt)

CardsJS is a class that handles various card game types and their operations. It supports different game configurations like 'standard', 'euchre', 'pinochle', etc. It also provides utilities for shuffling cards, comparing ranks and suits, and generating ranks and suits.

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.
Source:

Classes

CardsJS

Members

padding :Object

Padding configuration for different types of decks.
Type:
  • Object
Source:

perspective :Object

A mapping of different perspectives for viewing a deck.
Type:
  • Object
Source:

playableArea

Gets the playable area for the deck.
Source:

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.
Source:
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.
Source:
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.
Source:
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.
Source:
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.
Source:
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.
Source:
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.
Source:
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.
Source:
Returns:
The shuffled deck.
Type
Array