1.0.3 β€’ Published 1 year ago

@isluny/deck-cards v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

πŸƒ 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()
ParameterTypeOptional?DefaultDescrirption
options.numberOfFullDecksnumbertrue1Number of full decks
options.allowedValuesCardValue[]true---If defined, there will only be cards with the specified values ​​in the deck
options.autoShufflebooleantruetrueIf 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()
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago