@isluny/deck-cards
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i @isluny/deck-cards

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

9.96 kB

Total Files

8

Last publish

Collaborators

  • jvopinho