TEST(OmahaHighHandEvaluator, RankEval) { OmahaHighHandEvaluator oeval; CardSet hand("2c3c"); CardSet board("2c3c4c"); PokerEvaluation eval = oeval.evaluateRanks(hand, board); EXPECT_EQ(TWO_PAIR, eval.type()); EXPECT_EQ(Rank("3"), eval.majorRank()); EXPECT_EQ(Rank("2"), eval.minorRank()); }
void PokerHand::sortEval () const { PokerHand oldh = *this; PokerHand newh; PokerEvaluation eval = cardSet().evaluateHigh (); Rank r; bool dominor = true; Rank straighttop = Rank::Five(); oldh.sortRanks (); switch (eval.type ()) { // these types have major only case ONE_PAIR: case THREE_OF_A_KIND: case FOUR_OF_A_KIND: dominor = false; // these have major and minor case TWO_PAIR: case FULL_HOUSE: r = eval.majorRank (); while (oldh.cardSet().contains (r)) { Card c = oldh.cardSet().find (r); newh.append (c); oldh.remove (c); } if (dominor) { r = eval.minorRank (); while (oldh.cardSet().contains (r)) { Card c = oldh.cardSet().find (r); newh.append (c); oldh.remove (c); } } // we pass through here, no break case NO_PAIR: case THREE_FLUSH: case THREE_STRAIGHT_FLUSH: case FLUSH: newh.append (oldh); break; // straights may require the ace to swing low case THREE_STRAIGHT: straighttop = Rank::Three(); case STRAIGHT: case STRAIGHT_FLUSH: newh = oldh; r = eval.majorRank (); if (r == straighttop) { Card c = newh.cardSet().find (Rank::Ace()); newh.remove (c); newh.append (c); } break; } for (int i=0; i<_ncards; i++) _cards[i] = newh._cards[i]; }