我目前正致力于制作扑克游戏,并且需要检查每一张牌是否有资格作为获胜牌。我有一个52 ACards
的数组,具有以下结构:
struct ACard{
int num;
const char *pic;
};
我已将每张卡的pic
声明如下:
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";
我已经创建了一个测试手来测试每个可能的获胜手的逻辑。
这是我的测试手,用于刷新逻辑以检查它:
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;
}
当它命中if语句时,逻辑错误,因此它打印Incorrect Logic
。我还尝试检查每个pic
是否等于变量heart, diamond, club, or spade
,并检查每个pic
是否等于下一张卡pic
。
我可以在if语句中使用我的逻辑帮助。