diff options
Diffstat (limited to 'game.cpp')
-rw-r--r-- | game.cpp | 43 |
1 files changed, 10 insertions, 33 deletions
@@ -558,7 +558,7 @@ void Game::userAI(Card **cards) cout << "You have a pair or better and can discard " << howManyUserCanDiscard << " card(s)" << endl; - userDiscardCards(cards, howManyUserCanDiscard); + userDiscardCards(cards, 3); return; } @@ -579,8 +579,7 @@ void Game::userAI(Card **cards) howManyUserCanDiscard = 3; cout << "You have 4 cards of the same suit, you should\n" - << "discard card of the different suit" - << howManyUserCanDiscard << " card(s)" << endl; + << "discard card of the different suit" << endl; userDiscardCards(cards, howManyUserCanDiscard); return; @@ -668,38 +667,16 @@ bool Game::hasTwoPairs(Card **cards) return false; } - char c1, c2; - int ret = 0; - int whitelist[4]; - whitelist[0] = 0; - whitelist[1] = 0; - whitelist[2] = 0; - whitelist[3] = 0; + int *cardsToDiscard = whichCardsToDiscard(cards); + int cnt = 0; - int i, j; + int i; + /* if there are 2 pairs, they should be 1 index that contains 1 */ for (i = 0; i < 5; i++) - { - if (whitelist[i] == 1) - continue; - - c1 = cards[i]->getType()[0]; + if (cardsToDiscard[i] == 1) + cnt++; - for (j = i+1; j < 5; j++) - { - if (whitelist[j] == 1) - continue; - - c2 = cards[j]->getType()[0]; - if (c1 == c2) - { - ret++; - whitelist[j] = 1; - whitelist[i] = 1; - } - } - } - - return (ret != 0); + return (cnt == 1); } /* second param, 0 = user, 1~3 designate opponent */ @@ -771,7 +748,7 @@ void Game::evaluateHand(Card **cards, int who) void Game::showHands(void) { - cout << "User has: " << *hands[getUserHand()] << " " << endl; + cout << "\nUser has: " << *hands[getUserHand()] << " " << endl; int i; for (i = 0; i < numOfOpponents; i++) |