Perform a double down action for a player
double_down.RdPlayer adds exactly one card to their initial 2-card hand.
Value
A list with:
- new_hand
The player's hand after drawing one additional card.
- deck
The updated deck after removing one card.
- valid
Logical indicating whether the double down was valid (only valid for 2-card hands).
Examples
# Example setup
hand <- c("5♠", "6♦")
deck <- c("9♣", "10♦", "3♥") # top of deck is 9♣
# Perform double down
result <- double_down(hand, deck)
result$new_hand # Expected: c("5♠", "6♦", "9♣")
#> [1] "5♠" "6♦" "9♣"
result$deck # Expected: c("10♦", "3♥")
#> [1] "10♦" "3♥"
result$valid # Expected: TRUE
#> [1] TRUE
# Invalid example (hand is not 2 cards)
double_down(c("5♠", "6♦", "2♥"), deck)
#> $new_hand
#> [1] "5♠" "6♦" "2♥"
#>
#> $deck
#> [1] "9♣" "10♦" "3♥"
#>
#> $valid
#> [1] FALSE
#>