Determining if a hand of cards is a flush

144 views Asked by At

I am currently working on creating a poker game and need to check if each hand of cards qualifies as a winning hand. I have an array of 52 ACards with the following structure:

struct ACard{
    int num;
    const char *pic;
};

and I have declared the pic for each card as the following:

const char spade[4] = "\xe2\x99\xa0";
const char club[4] = "\xe2\x99\xa3";
const char heart[4] = "\xe2\x99\xa5";
const char diamond[4] = "\xe2\x99\xa6";

I have created a test hand to test my logic for each of the possible winning hands.

Here is my test hand for a flush with the logic to check it as well:

        testHand[0] = testDeck.cards[13];
        testHand[1] = testDeck.cards[17];
        testHand[2] = testDeck.cards[19];
        testHand[3] = testDeck.cards[22];
        testHand[4] = testDeck.cards[24];

        cout << "Testing Flush" << endl;
        printHand(testHand, testDeck);

        if((testHand[0].pic == "\xe2\x99\xa0" && testHand[1].pic == "\xe2\x99\xa0" && testHand[2].pic == "\xe2\x99\xa0" && testHand[3].pic == "\xe2\x99\xa0" && testHand[4].pic == "\xe2\x99\xa0") || (testHand[0].pic == "\xe2\x99\xa5" && testHand[1].pic == "\xe2\x99\xa5" && testHand[2].pic == "\xe2\x99\xa5" && testHand[3].pic == "\xe2\x99\xa5" && testHand[4].pic == "\xe2\x99\xa5") || (testHand[0].pic == "\xe2\x99\xa3" && testHand[1].pic == "\xe2\x99\xa3" && testHand[2].pic == "\xe2\x99\xa3" && testHand[3].pic == "\xe2\x99\xa3" && testHand[4].pic == "\xe2\x99\xa3") || (testHand[0].pic == "\xe2\x99\xa6" && testHand[1].pic == "\xe2\x99\xa6" && testHand[2].pic == "\xe2\x99\xa6" && testHand[3].pic == "\xe2\x99\xa6" && testHand[4].pic == "\xe2\x99\xa6")){
            cout << "Winner Winner Chicken Dinner! Flush!" << endl;
        }else{
            cout << "Incorrect Logic" << endl;
        }

When it hits the if statement, the logic is wrong so it prints Incorrect Logic. I have also tried checking if each pic is equal to the variables heart, diamond, club, or spade, and just checking if each each pic is equal to the next cards pic.

I could use some help with my logic within the if statement.

0

There are 0 answers