#' Detects and return the existence of 4 Kind
#'
#' @param cards A list of objects from the S4 class 'card'.
#'
#' @return A logical representing if a 4-of-a-kind exists.
#' @export
#' @importFrom magrittr %>%
#'
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))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.