Esempio n. 1
0
    void takeCard(Card& c){
	Card * temp = new Card(c);
	Cards.push_back(temp);
	Cards.back()->rotate((horizontal?0.0f:90.0f));
	Cards.back()->setFaceUp(visible);
	std::sort(Cards.begin(), Cards.end(), CardCompare(kozer));
	scale(area);
	updatePositions();
    }
Esempio n. 2
0
/*
 * Compare two hands and return:
 *   < 0 if hand1 < hand2
 *     0 if hand1 = hand2
 *   > 0 if hand1 > hand2
 */
int HandCompare(Card* hand1, Card* hand2) {
    HandType hand1_type = HandClassify(hand1);
    HandType hand2_type = HandClassify(hand2);
    int diff = hand1_type - hand2_type;

    if (diff != 0)
        return diff;

    // Tie breaker when two hands of the same type.
    // Find the strongest hand by going card-by-card
    // until one card is higher.  If no card is higher
    // we have a tie.
    for (size_t i = 0; i < HAND_LENGTH; ++i) {
        int cmp = CardCompare(&hand1[i], &hand2[i]);
        if (cmp != 0)
            return cmp;
    }
    return 0;
}