Skip to contents

Randomly selects a specified number of cards from a given deck. This function is typically used to deal the initial hand to a player or the dealer in a round of Blackjack.

Usage

deal_hand(deck, n = 2)

Arguments

deck

A card vector representing the deck to deal from, typically deck_cards()$cards.

n

Integer. Number of cards to deal (default is 2).

Value

A card vector containing the dealt hand.

Details

This function samples cards from a shuffled card vector. It does not remove dealt cards from the original deck — if needed, you can manage deck state manually using indexing.

Examples

deck <- deck_cards()
hand <- deal_hand(deck$cards, 2)
print(hand)
#> <card[2]>
#> [1] 9♦  10♥