diff options
Diffstat (limited to 'sorthand.cpp')
-rw-r--r-- | sorthand.cpp | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/sorthand.cpp b/sorthand.cpp index 0b09b7c..e713b7d 100644 --- a/sorthand.cpp +++ b/sorthand.cpp @@ -13,22 +13,25 @@ SortHand::SortHand() void SortHand::sortFourOfAKind(Card **cards, struct countAndType *maxCount) { +#if 0 int i; /* find the card that is different from other four */ for (i = 0; i < 5; i++) if (cards[i]->getType()[0] != maxCount->type) break; +#endif + int k; + for (k = 0; k < 5; k++) + if (cards[k]->getType()[0] == maxCount->type) + { + cards[k]->specialRank(); #ifdef DEBUG - cout << ANSI_COLOR_CYAN << "\ndebug: sortFourOfAKind(): " << cards[i]->getType() - << " is different from other 4 cards" << endl << ANSI_COLOR_RESET; + cout << ANSI_COLOR_CYAN << "\ndebug: sortFourOfAKind(): " + << cards[k]->getType() << " at cards[" << k + << "] gets special rank "<< endl << ANSI_COLOR_RESET; #endif - - /* put that card at the end */ - Card *tmp = cards[4]; - - cards[4] = cards[i]; - cards[i] = tmp; + } } void SortHand::sortThreeOfAKind(Card **cards, struct countAndType *threeCount) @@ -50,22 +53,7 @@ void SortHand::sortThreeOfAKind(Card **cards, struct countAndType *threeCount) << endl << ANSI_COLOR_RESET; #endif - /* put those cards at the end */ - Card *tmp = cards[4]; - Card *tmp2 = cards[3]; - - if (cards[i]->getRank() < cards[j]->getRank()) - { - cards[4] = cards[i]; - cards[3] = cards[j]; - } - else - { - cards[4] = cards[j]; - cards[3] = cards[i]; - } - - cards[i] = tmp; - cards[j] = tmp2; + cards[i]->specialRank(); + cards[j]->specialRank(); } |