bool isWinPlayer1(const std::string& line) { const std::vector<std::string> v = split(line, ' '); const std::vector<std::string> player1(v.begin(), v.begin()+5); const std::vector<std::string> player2(v.begin()+5, v.end()); const int score1 = score(player1); const int score2 = score(player2); if (score1 > score2) return true; else if (score1 == score2) return checkHighCard(player1, player2); else return false; }
Hand CheckerPlus::checkHand(vector<Card> handcard) { sort(handcard); Hand ret(NOT_THIS_RANK); if(checkStraightFlush(handcard,ret))return ret; else if(checkFour(handcard,ret))return ret; else if(checkFullHouse(handcard,ret))return ret; else if(checkFlush(handcard,ret))return ret; else if(checkStraight(handcard,ret))return ret; else if(checkFlush(handcard,ret))return ret; else if(checkTrip(handcard,ret))return ret; else if(checkTwoPairs(handcard,ret))return ret; else if(checkPair(handcard,ret))return ret; else checkHighCard(handcard,ret); return ret; }
bool Game::checkFlush(int i) const { int counter; for (int fh = 0; fh < 4; fh++) //check if all cards have the same suit { counter = 0; for (int c = 0; c < 5; c++) if (player[i].getCards()[c].getSuit() == deck->getSuits()[fh]) ++counter; if (counter == 5) { player[i].getCards()[7] = player[i].getCards()[checkHighCard(i)]; player[i].setHand(Flush); return true; } } return false; }