R/rank_hand.R

Defines functions rank_hand

rank_hand <- function(player){
  player <- player[[1]]
  cards <- c(player@hand,player@community)
  if (exists_s_flush(cards)$logical){
    hand_check <- exists_s_flush(cards)
    return(list("class" = "Straight Flush","cards" = hand_check$cards,"rank" = 1))
  } else if (exists_four_kind(cards)$logical){
    hand_check <- exists_four_kind(cards)
    return(list("class" = "Four of a kind","cards" = hand_check$cards,"rank" = 2))
  } else if (exists_full(cards)$logical){
    hand_check <- exists_full(cards)
    return(list("class" = "Full House","cards" = hand_check$cards,"rank" = 3))
  } else if (exists_flush(cards)$logical){
    hand_check <- exists_flush(cards)
    return(list("class" = "Flush","cards" = hand_check$cards,"rank" = 4))
  } else if (exists_straight(cards)$logical){
    hand_check <- exists_straight(cards)
    return(list("class" = "Straight","cards" = hand_check$cards,"rank" = 5))
  } else if (exists_three_kind(cards)$logical){
    hand_check <- exists_three_kind(cards)
    return(list("class" = "Three of a kind","cards" = hand_check$cards,"rank" = 6))
  } else if (exists_two_pair(cards)$logical){
    hand_check <- exists_two_pair(cards)
    return(list("class" = "Two pair","cards" = hand_check$cards,"rank" = 7))
  } else if (exists_pair(cards)$logical){
    hand_check <- exists_pair(cards)
    return(list("class" = "Pair","cards" = hand_check$cards,"rank" = 8))
  } else
    hand_check <- high_cards(cards)
    return(list("class" = "High card","cards" = hand_check$cards,"rank" = 9))
}
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.