v0.8.2
Class: Deck
A deck of Cards.
Supports shuffling, drawing cards, and resetting from the discard pile.
Table of contents
Constructors
Methods
Constructors
constructor
⢠new Deck(numberOfDecks?
): Deck
Parameters
Name | Type | Default value |
---|---|---|
numberOfDecks | number | 1 |
Returns
Methods
addToDiscard
⸠addToDiscard(card
): void
Adds a card to the discard pile.
Parameters
Name | Type | Description |
---|---|---|
card | Card | The card to add to the discard pile. |
Returns
void
drawCard
⸠drawCard(isVisible?
): null
| Card
Draws a card from the deck.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
isVisible | boolean | true | Whether the card should be visible. |
Returns
null
| Card
The drawn card or null if the deck is empty.
drawCards
⸠drawCards(count
, isVisible?
): Card
[]
Draws multiple cards from the deck.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
count | number | undefined | The number of cards to draw. |
isVisible | boolean | true | Whether the cards should be visible. |
Returns
Card
[]
An array of drawn cards or an empty array if the deck is empty.
getDiscardedCards
⸠getDiscardedCards(): number
Gets the number of discarded cards.
Returns
number
The number of discarded cards.
getRemainingCards
⸠getRemainingCards(): number
Gets the number of remaining cards in the deck.
Returns
number
The number of remaining cards in the deck.
resetFromDiscard
⸠resetFromDiscard(): void
Resets the deck from the discard pile.
Returns
void
shuffle
⸠shuffle(): void
Shuffles the deck.
Returns
void