R/deal_to_players.R

Defines functions deal_to_players

Documented in deal_to_players

#' Deal the flop cards to all the players
#'
#' @param n The number of players to deal to.
#' @param ncard The number of cards to deal to each player.
#' @param players A list of elements from the S4 class "player"
#' @param deck The deck from which the cards are to be dealt from.
#'
#' @return A list containing the players, as well as a last element
#' containing the deck.
#' @export
#' @examples
deal_to_players <- function(n,ncards,players,deck){
  cards <- new_cards(ncards,deck)
  deck <- cards[[ncards+1]]
  cards <- cards[-(ncards+1)]
  for (i in 1:n){
    for(j in 1:ncards){
      players[[i]]@community <- c(players[[i]]@community,cards[j])
    }
  }
  return(c(players,deck))
}
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.