Skip to contents

Perform surrender action

Usage

surrender_hand(hand, allow_surrender = TRUE)

Arguments

hand

A character vector of the player's current hand

allow_surrender

Logical. TRUE if game allows surrender at this point

Value

A list with status, payout, and message

Examples

# Example 1: Player surrenders with two cards and surrender is allowed
surrender_hand(c("10♠", "6♦"), TRUE)
#> $status
#> [1] "surrendered"
#> 
#> $payout
#> [1] 0.5
#> 
#> $message
#> [1] "Player surrendered. Half bet lost."
#> 

# Example 2: Surrender is not allowed
surrender_hand(c("10♠", "6♦"), FALSE)
#> $status
#> [1] "played"
#> 
#> $payout
#> [1] 0
#> 
#> $message
#> [1] "Surrender not allowed or invalid hand."
#> 

# Example 3: Hand has more than two cards (surrender invalid)
surrender_hand(c("10♠", "6♦", "2♣"), TRUE)
#> $status
#> [1] "played"
#> 
#> $payout
#> [1] 0
#> 
#> $message
#> [1] "Surrender not allowed or invalid hand."
#>