cards 1.0.13
Install from the command line:
Learn more about npm packages
$ npm install @bhoos/cards@1.0.13
Install via package.json:
"@bhoos/cards": "1.0.13"
About this version
A cards library that provides a standard Card
data type, using
a combination of Rank
, Suit
and book number
.
-
comparatorStd
:
A standard card comparison function for sorting used in marriage. -
comparatorCB
:
A card comparison function for sorting used in callbreak.
-
generateDeck(books: number, mans: number, supermans: number): Card[]
:
Create an array of cards with standard cards and special cards (man, superman). -
shuffleCard(cards: Card[]): Card[]
:
A fisher-yates based card shuffling, that does an in-place shuffling of cards. -
pickCard(cards: Card[], count: number): Card[]
:
Pick thecount
number of cards from the given array. The picked cards are removed from the original source as well. -
Card.getByCode(code: string)
:
All cards are represented by standard 2 digit codes (optionally followed by/book
). ACard
object can be retrieved from a code string (1H
,2C
,5D
,TS
,QD
,JS
,KH
represents, Ace of Heart, Two of clubs, five of diamonds, Ten of spades, Queen of diamonds, Jack of spades, King of hearts, respectivly).
-
serializeCard(serializer: Serializer, card: Card)
An efficient card serialization function that represents a card using a single byte number (0 - 255). This limits the number of books to 3 and upto 56 special cards with 8 unique types.
-
isSequence(cards: Card[])
:
Checks if the given array of cards make a pure sequence (straight). The cards do not require to be in any specific order. -
isPair(cards: Card[])
:
Checks if the given array of cards make a pair of different suit. -
isDublee(cards: Card[])
:
Checks if the given array of cards make a pair of same suit. -
isSet(cards: Card[])
:
Checks if the given array of cards make a triplet or quadruplet (also called as trial) of the same rank with different suits. -
isTunnella(cards: Card[])
:
Checks if the given array of cards make a triplet of the same ranks and same suit.