|
|
@@ -255,7 +255,7 @@ int CardsValue::cardsValueShort(int cards[4])
|
|
|
|
|
|
|
|
|
|
|
|
// Royal Flush, Straight Flush, Flush
|
|
|
|
// Royal Flush, Straight Flush, Flush
|
|
|
|
for(color_idx=0; color_idx<4; color_idx++) { // check all colors
|
|
|
|
for(color_idx=0; color_idx<4; color_idx++) { // check all colors
|
|
|
|
if(Tools::bitcount(cards[color_idx])>=5) { // check if at least 5 cards of one color
|
|
|
|
if(bitcount(cards[color_idx])>=5) { // check if at least 5 cards of one color
|
|
|
|
if((cards[color_idx] & straight[0]) == straight[0]) // check for Royal Flush
|
|
|
|
if((cards[color_idx] & straight[0]) == straight[0]) // check for Royal Flush
|
|
|
|
return 9;
|
|
|
|
return 9;
|
|
|
|
else { // check for Straight Flush
|
|
|
|
else { // check for Straight Flush
|
|
|
@@ -293,7 +293,7 @@ int CardsValue::cardsValueShort(int cards[4])
|
|
|
|
for(color_2_idx=color_1_idx+1; color_2_idx<3; color_2_idx++) {
|
|
|
|
for(color_2_idx=color_1_idx+1; color_2_idx<3; color_2_idx++) {
|
|
|
|
for(color_3_idx=color_2_idx+1; color_3_idx<4; color_3_idx++) {
|
|
|
|
for(color_3_idx=color_2_idx+1; color_3_idx<4; color_3_idx++) {
|
|
|
|
temp = cards[color_1_idx] & cards[color_2_idx] & cards[color_3_idx];
|
|
|
|
temp = cards[color_1_idx] & cards[color_2_idx] & cards[color_3_idx];
|
|
|
|
if(Tools::bitcount(temp) == 2) { // two times Three of a Kind
|
|
|
|
if(bitcount(temp) == 2) { // two times Three of a Kind
|
|
|
|
return 6; // Full House
|
|
|
|
return 6; // Full House
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if(temp) {
|
|
|
|
if(temp) {
|
|
|
@@ -315,7 +315,7 @@ int CardsValue::cardsValueShort(int cards[4])
|
|
|
|
for(color_1_idx=0; color_1_idx<3; color_1_idx++) {
|
|
|
|
for(color_1_idx=0; color_1_idx<3; color_1_idx++) {
|
|
|
|
for(color_2_idx=color_1_idx+1; color_2_idx<4; color_2_idx++) {
|
|
|
|
for(color_2_idx=color_1_idx+1; color_2_idx<4; color_2_idx++) {
|
|
|
|
temp = cards[color_1_idx] & cards[color_2_idx];
|
|
|
|
temp = cards[color_1_idx] & cards[color_2_idx];
|
|
|
|
if(Tools::bitcount(temp) >= 2) { // at least two times Two of a Kind
|
|
|
|
if(bitcount(temp) >= 2) { // at least two times Two of a Kind
|
|
|
|
return 2; // Two Pairs
|
|
|
|
return 2; // Two Pairs
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if(temp) { // search for second pair
|
|
|
|
if(temp) { // search for second pair
|
|
|
@@ -343,7 +343,7 @@ int CardsValue::cardsValue(int cards[4], int bestHand[4])
|
|
|
|
|
|
|
|
|
|
|
|
// Royal Flush, Straight Flush, Flush
|
|
|
|
// Royal Flush, Straight Flush, Flush
|
|
|
|
for(color_1_idx=0; color_1_idx<4; color_1_idx++) { // check all colors
|
|
|
|
for(color_1_idx=0; color_1_idx<4; color_1_idx++) { // check all colors
|
|
|
|
if(Tools::bitcount(cards[color_1_idx])>=5) { // check if at least 5 cards of one color
|
|
|
|
if(bitcount(cards[color_1_idx])>=5) { // check if at least 5 cards of one color
|
|
|
|
if((cards[color_1_idx] & straight[0]) == straight[0]) { // check for Royal Flush
|
|
|
|
if((cards[color_1_idx] & straight[0]) == straight[0]) { // check for Royal Flush
|
|
|
|
if(bestHand) bestHand[color_1_idx] = straight[0];
|
|
|
|
if(bestHand) bestHand[color_1_idx] = straight[0];
|
|
|
|
return 900000000; // Royal Flush
|
|
|
|
return 900000000; // Royal Flush
|
|
|
@@ -407,7 +407,7 @@ int CardsValue::cardsValue(int cards[4], int bestHand[4])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(temp1) {
|
|
|
|
if(temp1) {
|
|
|
|
if(Tools::bitcount(temp1) == 2) {
|
|
|
|
if(bitcount(temp1) == 2) {
|
|
|
|
// two times Three of a Kind
|
|
|
|
// two times Three of a Kind
|
|
|
|
if(bestHand) {
|
|
|
|
if(bestHand) {
|
|
|
|
kickerValue1 = determineKickerValue(temp1,0,0);
|
|
|
|
kickerValue1 = determineKickerValue(temp1,0,0);
|
|
|
@@ -459,7 +459,7 @@ int CardsValue::cardsValue(int cards[4], int bestHand[4])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(temp1) {
|
|
|
|
if(temp1) {
|
|
|
|
if(Tools::bitcount(temp1) >= 2) { // at least two times Two of a Kind
|
|
|
|
if(bitcount(temp1) >= 2) { // at least two times Two of a Kind
|
|
|
|
kickerValue1 = determineKickerValue(temp1,0,1);
|
|
|
|
kickerValue1 = determineKickerValue(temp1,0,1);
|
|
|
|
kickerValue2 = determineKickerValue(OR & ~kickerValue1.select,2,2);
|
|
|
|
kickerValue2 = determineKickerValue(OR & ~kickerValue1.select,2,2);
|
|
|
|
if(bestHand) {
|
|
|
|
if(bestHand) {
|
|
|
@@ -2572,6 +2572,16 @@ std::list<std::string> CardsValue::translateCardsValueCode(int cardsValueCode)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CardsValue::bitcount(int in)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int count=0 ;
|
|
|
|
|
|
|
|
while (in) {
|
|
|
|
|
|
|
|
count++ ;
|
|
|
|
|
|
|
|
in &= (in - 1) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return count ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
|
|
|
|
//int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|