int* Game::checkCards() const { for (int i = 0; i < players; i++) { if (!player[i].getActive()) //if the player folded skip { player[i].setHand(-1); continue; } if (checkRoyalFlush(i)) continue; if (checkStraightFlush(i)) continue; if (checkFourOfAKind(i)) continue; if (checkFullHouse(i)) continue; if (checkFlush(i)) continue; if (checkStraight(i)) continue; if (checkThreeOfAKind(i)) continue; if (checkTwoPair(i)) continue; if (checkOnePair(i)) continue; player[i].setHand(HighCard); sortCards(i); //for high card } sameHand(); int* winners; for (int k = 9, count = 0; k >= 0; k--) for (int i = 0; i < players; i++) { if (!player[i].getActive()) //if the player folded skip continue; if (player[i].getHand() == k) //if enters here it found the highest hand among all players { for (k = 0; k < players; k++) //then lets find if there's a tie if (player[i].getHand() == player[k].getHand() && i != k) ++count; if (count == 0) //if there's only one winner { winners = new int[2]; winners[0] = 1; //send how many winners are there winners[1] = i; return winners; } winners = new int[count + 2]; winners[0] = ++count; //send how many winners are there winners[1] = i; //save first winner found for (k = 0 , count = 1; k < players; k++) //k is the index of player, count is the index of the vec for winners if (player[i].getHand() == player[k].getHand() && i != k) winners[++count] = k; return winners; } } return nullptr; }
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; }