Skip to contents

Checks if a player's hand can be split and returns split hands if allowed.

Usage

player_split(hand)

Arguments

hand

A character vector of two cards (e.g., c("A♠", "A♥"))

Value

A list with:

can_split

Logical indicating if a split is allowed.

hands

A list containing either the original hand or two split hands.

Examples

# Example 1: Splitting a hand with a pair of Aces
player_split(c("A♠", "A♥"))
#> $can_split
#> [1] TRUE
#> 
#> $hands
#> $hands[[1]]
#> [1] "A♠"
#> 
#> $hands[[2]]
#> [1] "A♥"
#> 
#> 

# Example 2: Cannot split non-matching cards
player_split(c("A♠", "10♠"))
#> $can_split
#> [1] FALSE
#> 
#> $hands
#> $hands[[1]]
#> [1] "A♠"  "10♠"
#> 
#> 

# Example 3: Invalid hand with more than 2 cards (split not allowed)
player_split(c("10♠", "10♥", "5♣"))
#> $can_split
#> [1] FALSE
#> 
#> $hands
#> $hands[[1]]
#> [1] "10♠" "10♥" "5♣" 
#> 
#>