Announce Winner Function
announce_winner.RdThis function announces the winner(s) of the game based on hand scores.
Examples
# Dealer has 18
dealer_score <- 18
# Case 1: Player1 beats dealer, Player2 busts, Player3 ties
scores <- c(Player1 = 20, Player2 = 23, Player3 = 18)
announce_winner(scores, dealer_score)
#> Player1 Player2 Player3
#> "Win" "Lose" "Tie"
# Expected output:
# Player1 "Win"
# Player2 "Lose"
# Player3 "Tie"
# Case 2: Dealer busts, only players with <= 21 win
announce_winner(c(Player1 = 17, Player2 = 22), dealer_score = 25)
#> Player1 Player2
#> "Win" "Lose"
# Expected:
# Player1 "Win", Player2 "Lose"
# Case 3: Dealer and all players bust
announce_winner(c(P1 = 22, P2 = 30), dealer_score = 26)
#> P1 P2
#> "Lose" "Lose"
# Expected: both "Lose" (players bust regardless of dealer bust)