Skip to contents

Generates a shuffled deck of cards for use in Blackjack games. Supports combining multiple standard 52-card decks into one.

Usage

deck_cards(no_of_decks = 1)

Arguments

no_of_decks

Integer. Number of standard decks to include (default is 1).

Value

An object of class "blackjack_deck", which is a list with two elements:

cards

A shuffled card vector.

decks

The number of decks used to create the full shoe.

Details

Each card is represented using the custom card vector class. The returned object includes a shuffled vector of cards and metadata about the number of decks used. This function is typically used as the starting point for dealing hands in the game.

Examples

deck <- deck_cards()
print(deck)
#> $cards
#> <card[52]>
#>  [1] 3♦  10♣ Q♠  A♥  10♦ 3♠  J♥  4♣  4♠  K♦  5♠  2♠  A♦  7♠  10♥ 7♥  9♣  3♣  A♣ 
#> [20] 8♦  8♠  K♠  5♣  10♠ J♠  J♦  2♣  7♦  6♦  5♦  2♥  6♠  K♥  Q♦  Q♥  5♥  9♥  K♣ 
#> [39] A♠  J♣  3♥  6♥  2♦  4♥  8♥  6♣  Q♣  7♣  9♠  4♦  9♦  8♣ 
#> 
#> $decks
#> [1] 1
#> 
#> attr(,"class")
#> [1] "blackjack_deck"
print(deck$cards)
#> <card[52]>
#>  [1] 3♦  10♣ Q♠  A♥  10♦ 3♠  J♥  4♣  4♠  K♦  5♠  2♠  A♦  7♠  10♥ 7♥  9♣  3♣  A♣ 
#> [20] 8♦  8♠  K♠  5♣  10♠ J♠  J♦  2♣  7♦  6♦  5♦  2♥  6♠  K♥  Q♦  Q♥  5♥  9♥  K♣ 
#> [39] A♠  J♣  3♥  6♥  2♦  4♥  8♥  6♣  Q♣  7♣  9♠  4♦  9♦  8♣ 
head(deck$cards)
#> <card[6]>
#> [1] 3♦  10♣ Q♠  A♥  10♦ 3♠