Skip to content

A basic package for generating card decks and managing basic usage logic.

Notifications You must be signed in to change notification settings

IsLunyStudios/deck-cards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🃏 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()

About

A basic package for generating card decks and managing basic usage logic.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published