A basic package for generating card decks and managing basic usage logic.
npm i @isluny/deck-cards
Create a basic deck
const { Deck } = require('@isluny/deck-cards')
const deck = new Deck()
Parameter | Type | Optional? | Default | Descrirption |
---|---|---|---|---|
options.numberOfFullDecks | number |
true |
1 |
Number of full decks |
options.allowedValues | CardValue [] |
true |
--- | If defined, there will only be cards with the specified values in the deck |
options.autoShuffle | boolean |
true |
true |
If true, when the deck is created or reset, the cards will be shuffled automatically |
Get the first card on top
const card = deck.draw()
Returns a array with top cards from the deck.
const cards = deck.drawMany(3)
We can shuffle the deck and randomize the positions
deck.shuffle()
You can disable the use of a card in the deck
deck.disableCard(`${CardValue.Ace}:${CardSuit.Spades}`);
CardValue Enum | CardSuit Enum
const deckAvailable = deck.len()
const deckUsed = deck.used()