R/exists_full.R

Defines functions exists_full

Documented in exists_full

#' Detect the existance of a full house
#'
#' @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 full house itself if there is one.
#' @export
#'
exists_full <- function(cards){
  three_kind <- exists_n_kind(cards,3)
  if(!three_kind$logical) return(list("logical" = FALSE))
  three_kind <- three_kind$cards
  #Now need to remove the 3 of a kind from `cards` to test
  #for a pair.
  cards <- remove_cards(cards,three_kind)
  pair <- exists_n_kind(cards,2)
  if (pair$logical){
    pair <- pair$cards
    cards <- c(three_kind,pair)
    return(list("logical" = TRUE,"cards" = cards))
  }
  return(list("logical" = FALSE))
}
dfcorbin/pokersim2 documentation built on Jan. 15, 2020, 12:20 a.m.