@isluny/deck-cards
v1.0.3
Published
A basic package for generating card decks and managing basic usage logic.
Downloads
9
Readme
🃏 Deck Cards
A basic package for generating card decks and managing basic usage logic.
Installation
npm i @isluny/deck-cards
Creating & Using a Deck
Starting
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 |
Methods
Draw
Get the first card on top
const card = deck.draw()
Draw Many
Returns a array with top cards from the deck.
const cards = deck.drawMany(3)
Shuffle
We can shuffle the deck and randomize the positions
deck.shuffle()
Disable a Card
You can disable the use of a card in the deck
deck.disableCard(`${CardValue.Ace}:${CardSuit.Spades}`);
CardValue Enum | CardSuit Enum
Get number of card available
const deckAvailable = deck.len()
Get number of card used
const deckUsed = deck.used()