v0.10.0
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 | Object | The card to add to the discard pile. |
card.card | Card | - |
Returns
void
drawCard
▸ drawCard(isVisible?): null | Card
Draws a card from the deck.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
isVisible | Object | {} | Whether the card should be visible. |
isVisible.isVisible? | boolean | true | - |
Returns
null | Card
The drawn card or null if the deck is empty.
drawCards
▸ drawCards(«destructured»): Card[]
Draws multiple cards from the deck.
Parameters
| Name | Type | Default value |
|---|---|---|
«destructured» | Object | undefined |
› count | number | undefined |
› isVisible? | boolean | true |
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