Skip to content

cards 1.0.12

Install from the command line:
Learn more about npm packages
$ npm install @bhoos/cards@1.0.12
Install via package.json:
"@bhoos/cards": "1.0.12"

About this version

Bhoos Cards

A cards library that provides a standard Card data type, using a combination of Rank, Suit and book number.

Card datatype

Comparator APIs

  • comparatorStd:
    A standard card comparison function for sorting used in marriage.
  • comparatorCB:
    A card comparison function for sorting used in callbreak.

Utility APIs

  • 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 the count 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). A Card 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).

Card Serialization

  • 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.

Algorithm APIs

  • 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.

Details

  • cards
  • @Bhoos Bhoos
  • almost 3 years ago
  • MIT
  • 9 dependencies

Assets

  • cards-1.0.12-npm.tgz

Download activity

  • Total downloads 77
  • Last 30 days 0
  • Last week 0
  • Today 0