string StraightFlashPokerDecisionMaker::decideOrDelegate(PokerHand& a, PokerHand& b){ string response(""); bool aHasStraightFlash = hasFlash(a) && hasStraight(a); bool bHasStraightFlash = hasFlash(b) && hasStraight(b); if(aHasStraightFlash && !bHasStraightFlash){ stringstream ss; ss << a.owner() << " wins. - with straight flash"; response = ss.str(); } else if (!aHasStraightFlash && bHasStraightFlash){ stringstream ss; ss << b.owner() << " wins. - with straight flash"; response = ss.str(); } return response; }
bool hasStraightFlush(vector<Card> cards) { if(hasFlush(cards) && hasStraight(cards)) { return true; } return false; }
//Returns the rank of the hand. 0 is the lowest (a high card) and 8 is the highest(straight flush). int Hand::getHandRankValue() { if (hasStraight() == true && hasFlush() == true) { return 8; } else if (hasFourOfAKind() == true) { return 7; } else if (hasFullHouse() == true) { return 6; } else if (hasFlush() == true) { return 5; } else if (hasStraight() == true) { return 4; } else if (hasThreeOfAKind() != -1) { return 3; } else if (hasTwoPair() != -1) { return 2; } else if (hasPair() != -1) { return 1; } else //High card { return 0; } }
string Hand::getHandRankName() { if (hasStraight() == true && hasFlush() == true) { return "Straight Flush"; } else if (hasFourOfAKind() == true) { return "Four-of-a-Kind"; } else if (hasFullHouse() == true) { return "Full House"; } else if (hasFlush() == true) { return "Flush"; } else if (hasStraight() == true) { return "Straight"; } else if (hasThreeOfAKind() != -1) { return "Three-of-a-Kind"; } else if (hasTwoPair() != -1) { return "Two Pair"; } else if (hasPair() != -1) { return "Pair"; } else //High card { return "High Card"; } }
void Player::setPowerOfHand() { if (hasStraightFlush(this->hand)) { this->powerOfHand = StraightFlush; } else if (hasFourOfAKind(this->hand)){ this->powerOfHand = FourOfAKind; } else if(hasFullHouse(this->hand)){ this->powerOfHand = FullHouse; } else if(hasFlush(this->hand)){ this->powerOfHand = Flush; } else if(hasStraight(this->hand)){ this->powerOfHand = Straight; } else if(hasThreeOfAKind(this->hand)){ this->powerOfHand = ThreeOfAKind; } else if(hasTwoPairs(this->hand)){ this->powerOfHand = TwoPairs; } else if (hasOnePair(this->hand)) { this->powerOfHand = OnePair; } else { this->powerOfHand = HighCard; } }