R/preflop_deal.R

Defines functions preflop_deal

Documented in preflop_deal

#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))
}
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.