#' Detects and return the existence of 4 Kind
#'
#' @param cards A list of objects from the S4 class 'card'.
#'
#' @return
#' @export
#'
#' @examples
exists_four_kind <- function(cards){
four <- exists_n_kind(cards,4)
if(four$logical){
four <- four$cards
cards <- remove_cards(cards,four)
} else return(list("logical" = FALSE))
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_card <- names(values)[1] %>% as.numeric() %>% cards[.]
cards <- c(four,top_card)
return(list("logical" = TRUE,"cards" = cards))
}
set.seed(1234)
cards <- new_cards(30,new_deck())[-31]
cards <- exists_four_kind(cards)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.