R/high_cards.R

Defines functions high_cards

Documented in high_cards

#' Return the highest 5 cards
#'
#' @param cards A list of objects from the S4 class 'card'.
#'
#' @return A list containing the highest 5 cards.
#' @export
#'
#' @examples
high_cards <- function(cards){
  values <- c()
  for ( i in 1:length(cards)){
    values <- c(values,cards[[i]]@value)
  }
  names(values) <- paste(1:length(cards))
  values <- sort(values,decreasing=TRUE)
  top_cards <- names(values)[1:5] %>% as.numeric() %>% cards[.]
  return(cards)
}
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.