void getRank() { if(isRoyalFlush()) { rank = RoyalFlush; } else if(isStraightFlush()) { rank = StraightFlush; } else if(fourKindPair()) { rank = FourOfaKind; } else if(isFullHouse()) { rank = FullHouse; } else if(sameSuit()) { rank = Flush; } else if(consecutive()) { rank = Straight; } else if(threeKindPair()) { rank = ThreeOfaKind; } else if(twoKindTwoPairs()) { rank = TwoPairs; } else if(twoKindOnePair()) { rank = OnePair; } else { rank = HighCard; } }
// TODO // Hand* Util::determineHandType(std::vector<Card*>& p_cards) { determineDuplicateCards(p_cards); Hand * newHand = nullptr; uint handType = HIGHEST_CARD; if (isRoyalFlush(p_cards)) { newHand = new NonRepeatedHand(ROYAL_FLUSH, p_cards); } else if (isStraightFlush(p_cards)) { newHand = new NonRepeatedHand(STRAIGHT_FLUSH, p_cards); } else if (isFourOfAKind()) { newHand = new RepeatedHand(FOUR_OF_A_KIND, p_cards, m_occurences, m_occurencesVector); } else if (isFullHouse()) { newHand = new RepeatedHand(FULL_HOUSE, p_cards, m_occurences, m_occurencesVector); } else if (isFlush(p_cards)) { newHand = new NonRepeatedHand(FLUSH, p_cards); } else if (isStraight(p_cards)) { newHand = new NonRepeatedHand(STRAIGHT, p_cards); } else if (isThreeOfAKind()) { newHand = new RepeatedHand(THREE_OF_A_KIND, p_cards, m_occurences, m_occurencesVector); } else if (isTwoPairs()) { newHand = new RepeatedHand(TWO_PAIRS, p_cards, m_occurences, m_occurencesVector); } else if (isOnePair()) { newHand = new RepeatedHand(ONE_PAIR, p_cards, m_occurences, m_occurencesVector); } else { newHand = new NonRepeatedHand(HIGHEST_CARD, p_cards); } m_occurences.clear(); m_occurencesVector.clear(); return newHand; }
int score(const std::vector<std::string>& vec) { if (isRoyalFlush(vec)) return 900; if (isStraightFlush(vec)) return 800 + getHighCard(vec); if (isFourCard(vec)) return 700 + getHighCard(vec, 4); if (isFullHouse(vec)) return 600 + getHighCard(vec, 3); if (isFlush(vec)) return 500 + getHighCard(vec); if (isStraight(vec)) return 400 + getHighCard(vec); if (isThreeCard(vec)) return 300 + getHighCard(vec, 3); if (isTwoPair(vec)) return 200 + getHighCard(vec, 2); if (isOnePair(vec)) return 100 + getHighCard(vec, 1); return getHighCard(vec); }
PokerHand Hand::rank() const { if (isRoyalFlush()) return PokerHand::ROYAL_FLUSH; if (isStraightFlush()) return PokerHand::STRAIGHT_FLUSH; if (isFourOfAKind()) return PokerHand::FOUR_OF_A_KIND; if (isFullHouse()) return PokerHand::FULL_HOUSE; if (isFlush()) return PokerHand::FLUSH; if (isStraight()) return PokerHand::STRAIGHT; if (isThreeOfAKind()) return PokerHand::THREE_OF_A_KIND; if (isTwoPair()) return PokerHand::TWO_PAIR; if (isJacksOrBetter()) return PokerHand::JACKS_OR_BETTER; return PokerHand::NADA; }