R/exists_n_kind.R

Defines functions exists_n_kind

Documented in exists_n_kind

#' Detects and return the existence of nKind
#'
#' @param cards A list of objects from the S4 class 'card'.
#'
#' @return A list containing a logical representing if there is a flush,
#' and the n-kind itself if there is one.
#' @export
#'
#' @examples
exists_n_kind <- function(cards,n){
  groups <- group_cards(cards)
  for (i in 1:length(groups)){
    cards <- groups[[i]]
    if (length(groups[[i]]) >= n) return(list("logical" = TRUE,"cards" = cards[1:n]))
  }
  return(list("logical"=FALSE))
}
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.