#THE OUPUT ALSO RETURNS THE DECK AT THE END OF THE VECTOR.
#' Preflop Deal
#'
#' @param n The number of players to be dealt into the round.
#' @param chips A vector of length n that gives the amount
#' of chips that each player starts with.
#'
#' @return A list in which each element is an object of the
#' S4 class "player", as well as the deck contained in the
#' last element.
#' @export
#'
#' @examples
preflop_deal <- function(n,chips){
deck <- new_deck()
players <- list()
for (i in 1:n){
player <- new("player",
hand = new_cards(2,deck),
chips = chips[i]
)
deck <- player@hand[[3]]
player@hand <- player@hand[-3]
players <- c(players,player)
}
names(players) <- paste("Player", 1:n)
return(c(players,deck))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.