#include "13S_GameLogic.h" ////////////////////////////////////////////////////////////////////////// //静态变量 const uint8 C13SGameLogic::m_bCardListData[SSS_CARD_COUNT] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //方块 A - K 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //梅花 A - K 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //红桃 A - K 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //黑桃 A - K 0x41, 0x42, }; ////////////////////////////////////////////////////////////////////////// //构造函数 C13SGameLogic::C13SGameLogic() { zeromemory(btCardSpecialData, sizeof(btCardSpecialData)); m_bClassicRule = true; } //析构函数 C13SGameLogic::~C13SGameLogic() { } //获取类型 uint8 C13SGameLogic::GetCardType(uint8 bCardData[], uint8 bCardCount, uint8 btSpecialCard[]) { //数据校验 ASSERT(bCardCount == 3 || bCardCount == 5 || 13 == bCardCount); if (bCardCount != 3 && bCardCount != 5 && bCardCount != 13) return SSS_CT_INVALID; tag13SAnalyseData AnalyseData; memset(&AnalyseData, 0, sizeof(tag13SAnalyseData)); AnalyseCard(bCardData, bCardCount, AnalyseData); //开始分析 switch (bCardCount) { case 3: //三条类型 { //单牌类型 if (3 == AnalyseData.bOneCount) return SSS_CT_SINGLE; //对带一张 if (1 == AnalyseData.bTwoCount && 1 == AnalyseData.bOneCount) return SSS_CT_ONE_DOUBLE; //三张牌型 if (1 == AnalyseData.bThreeCount) return SSS_CT_THREE; //错误类型 return SSS_CT_INVALID; } case 5: //五张牌型 { bool bFlushNoA = false, bFlushFirstA = false, bFlushBackA = false; if (GetCardLogicValue(bCardData[0]) >= SSS_CARD_XW && GetCardLogicValue(bCardData[1])= GetCardLogicValue(bCardData[2]))//A连在前 { bFlushFirstA = true; for (uint8 i = 2; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if (1 != nValue && nValue != 2) { bFlushFirstA = false; break; } } } else if (5 >= GetCardLogicValue(bCardData[1]) && (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW || GetCardLogicValue(bCardData[0]) == SSS_CARD_XW))//A连在前 { bFlushFirstA = true; for (uint8 i = 1; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if (1 != nValue && nValue != 2) { bFlushFirstA = false; break; } } } else { bFlushNoA = true; bool bRes = false; for (uint8 i = 1; i<4; ++i) { uint8 A = GetCardLogicValue(bCardData[i]); uint8 B = GetCardLogicValue(bCardData[i + 1]); uint8 nValue = A - B; if (nValue == 2) { if (!bRes) //第一次进入 { bRes = true; continue; } //第二次进入 bFlushNoA = false; break; } if (1 != nValue) { bFlushNoA = false; break; } } } } else if (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW && GetCardLogicValue(bCardData[1]) == SSS_CARD_XW) { if (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW&& GetCardLogicValue(bCardData[1]) == SSS_CARD_XW) { bFlushBackA = true; uint8 bIndex = 0; for (uint8 i = 2; i<5; ++i) { if (GetCardLogicValue(bCardData[i]) >= 10) bIndex++; } if (GetCardLogicValue(bCardData[2]) != 14) { for (uint8 i = 2; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if ((1 != nValue && nValue != 2)/*|| bIndex!=3*/) { bFlushBackA = false; break; } } } else //16 15 14 12 10 16 15 14 11 10 16 15 14 13 10 { //16 15 14 12 11 16 15 14 13 11 //16 15 14 13 12 if (GetCardLogicValue(bCardData[4]) == 10 && bIndex == 3) { if (!(GetCardLogicValue(bCardData[3]) == 12 || GetCardLogicValue(bCardData[3]) == 11 || GetCardLogicValue(bCardData[3]) == 13)) { bFlushBackA = false; } } else if (GetCardLogicValue(bCardData[4]) == 11 && bIndex == 3) { if (!(GetCardLogicValue(bCardData[3]) == 12 || GetCardLogicValue(bCardData[3]) == 13)) { bFlushBackA = false; } } else if (GetCardLogicValue(bCardData[4]) == 12 && bIndex == 3) { if (!(GetCardLogicValue(bCardData[3]) == 13)) { bFlushBackA = false; } } else if (5 >= GetCardLogicValue(bCardData[3]) && (GetCardLogicValue(bCardData[3]) != GetCardLogicValue(bCardData[4]))) { bFlushFirstA = true; for (uint8 i = 3; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if (1 != nValue && nValue != 2 && nValue != 3) { bFlushFirstA = false; break; } } } else //zyy 3/18 2鬼带两张认成A在后顺子 修复 { for (uint8 i = 2; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if ((1 != nValue && nValue != 2)/*|| bIndex!=3*/) { bFlushBackA = false; break; } } } } //zyy 3/9 bFlushNoA = true; bool bRes1 = false; bool bRes2 = false; for (uint8 i = 2; i<4; ++i) { uint8 A = GetCardLogicValue(bCardData[i]); uint8 B = GetCardLogicValue(bCardData[i + 1]); uint8 nValue = A - B; if (nValue == 3) { if (!bRes1 && !bRes2) { bRes1 = true; bRes2 = true; continue; } bFlushNoA = false; break; } if (nValue == 2) { if (!bRes1) { bRes1 = true; continue; } else if (!bRes2) { bRes2 = true; continue; } bFlushNoA = false; break; } if (1 != nValue && nValue != 2 && nValue != 3) { bFlushNoA = false; break; } } } else if ((GetCardLogicValue(bCardData[4]) == 10 || GetCardLogicValue(bCardData[4]) == 11 || GetCardLogicValue(bCardData[4]) == 12) && GetCardLogicValue(bCardData[2] == 14)) { bFlushBackA = true; for (uint8 i = 2; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if (1 != nValue && nValue != 2 && nValue != 3) { bFlushBackA = false; break; } } } } else { //A连在后 if (14 == GetCardLogicValue(bCardData[0]) && 10 == GetCardLogicValue(bCardData[4])) bFlushBackA = true; else bFlushNoA = true; for (uint8 i = 0; i<4; ++i) { uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]); if (1 != nValue) { bFlushBackA = false; bFlushNoA = false; break; } } //A连在前 if (false == bFlushBackA && false == bFlushNoA && 14 == GetCardLogicValue(bCardData[0])) { bFlushFirstA = true; for (uint8 i = 1; i<4; ++i) if (1 != GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1])) bFlushFirstA = false; if (2 != GetCardLogicValue(bCardData[4])) bFlushFirstA = false; } } //同花五牌 if (false == bFlushBackA && false == bFlushNoA && false == bFlushFirstA) { if (true == AnalyseData.bStraight) return SSS_CT_FIVE_FLUSH; } else if (true == bFlushNoA) { //杂顺类型 if (false == AnalyseData.bStraight) return SSS_CT_FIVE_MIXED_FLUSH_NO_A; //同花顺牌 else return SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A; } else if (true == bFlushFirstA) { //杂顺类型 if (false == AnalyseData.bStraight) return SSS_CT_FIVE_MIXED_FLUSH_FIRST_A; //同花顺牌 else return SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A; } else if (true == bFlushBackA) { //杂顺类型 if (false == AnalyseData.bStraight) return SSS_CT_FIVE_MIXED_FLUSH_BACK_A; //同花顺牌 else return SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A; } //五带0张 if (1 == AnalyseData.bFiveCount) return SSS_CT_FIVE_BOMB; //四带单张 if (1 == AnalyseData.bFourCount && 1 == AnalyseData.bOneCount) return SSS_CT_FIVE_FOUR_ONE; //三条一对 if (1 == AnalyseData.bThreeCount && 1 == AnalyseData.bTwoCount) return SSS_CT_FIVE_THREE_DEOUBLE; //三条带单 if (1 == AnalyseData.bThreeCount && 2 == AnalyseData.bOneCount) return SSS_CT_THREE; //两对牌型 if (2 == AnalyseData.bTwoCount && 1 == AnalyseData.bOneCount) return SSS_CT_FIVE_TWO_DOUBLE; //只有一对 if (1 == AnalyseData.bTwoCount && 3 == AnalyseData.bOneCount) return SSS_CT_ONE_DOUBLE; //单牌类型 if (5 == AnalyseData.bOneCount && false == AnalyseData.bStraight) return SSS_CT_SINGLE; //错误类型 return SSS_CT_INVALID; } case 13://13张特殊牌型 { bool TwelveKing = false; //同花十三水 if (13 == AnalyseData.bOneCount && true == AnalyseData.bStraight) return SSS_CT_THIRTEEN_FLUSH; //十三水 if (13 == AnalyseData.bOneCount) return SSS_CT_THIRTEEN; //十二皇族 TwelveKing = true; for (int i = 0; i<13; i++) { if (GetCardLogicValue(bCardData[i])<11) { TwelveKing = false; break; } } if (TwelveKing) { return SSS_CT_TWELVE_KING; } //三同花顺 /*bool bThreeStraightFlush = false; bThreeStraightFlush = IsThreeFlushStraight(bCardData,bCardCount); if (bThreeStraightFlush) { return SSS_CT_THREE_STRAIGHTFLUSH; }*/ //三同花顺子 { uint8 bCardList[13] = { 0 }; memcpy(bCardList, bCardData, sizeof(uint8) * 13); SortCardList(bCardList, 13); uint8 bLeftCount = 13; uint8 cbStraightFlush[5] = { 0 }; uint8 bTempCount = 5; tag13SAnalyseType tagCardType = GetType(bCardList, bLeftCount); if (tagCardType.bStraightFlush) { for (uint8 i = 0; i= SSS_CARD_XW && GetCardLogicValue(bCardList[1]) 8 && GetCardLogicValue(bCardData[i]) != SSS_CARD_XW&&GetCardLogicValue(bCardData[i]) != SSS_CARD_DW) { AllSmall = false; break; } } if (AllSmall) { return SSS_CT_ALL_SMALL; } //凑一色 { uint8 Flush = 1; uint8 bStartIndex = 0; uint8 SColor = 0; uint8 bSameColorList[13] = { 0 }; memcpy(bSameColorList, bCardData, sizeof(uint8) * 13); SortCardList(bSameColorList, 13); if (GetCardLogicValue(bSameColorList[0]) >= SSS_CARD_XW && GetCardLogicValue(bSameColorList[1])= SSS_CARD_XW && GetCardLogicValue(bSameColorList[1]) >= SSS_CARD_XW) { bStartIndex = 2; } { SColor = GetCardColor(bSameColorList[bStartIndex]); for (int i = bStartIndex + 1; i<13; i++) { if (SColor == (GetCardColor(bSameColorList[i])) || SColor == ((GetCardColor(bSameColorList[i]) + 2) % 4)) { Flush++; } else { break; } } } if (13 - bStartIndex == Flush) { return SSS_CT_SAME_COLOR; } } //四套冲三 if (4 == AnalyseData.bThreeCount || (3 == AnalyseData.bThreeCount && 1 == AnalyseData.bFourCount) || (2 == AnalyseData.bThreeCount && 1 == AnalyseData.bFourCount && (AnalyseData.bTwoCount >= 1) && (GetCardLogicValue(bCardData[0]) == SSS_CARD_XW || GetCardLogicValue(bCardData[0]) == SSS_CARD_DW))) { return SSS_CT_FOUR_THREESAME; } //五对冲三 if ((5 == AnalyseData.bTwoCount && 1 == AnalyseData.bThreeCount) || (3 == AnalyseData.bTwoCount && 1 == AnalyseData.bFourCount && 1 == AnalyseData.bThreeCount) || (1 == AnalyseData.bTwoCount && 2 == AnalyseData.bFourCount && 1 == AnalyseData.bThreeCount)) { return SSS_CT_FIVEPAIR_THREE; } //六对半 if (6 == AnalyseData.bTwoCount || (4 == AnalyseData.bTwoCount && 1 == AnalyseData.bFourCount) || (2 == AnalyseData.bTwoCount && 2 == AnalyseData.bFourCount) || (3 == AnalyseData.bFourCount)) { return SSS_CT_SIXPAIR; } //三同花 { //定义变量 uint8 bCardList[13] = { 0 }; memcpy(bCardList, bCardData, sizeof(uint8) * 13); uint8 bLeftCCount = 13; uint8 bTempCard[3][5] = { 0 }; uint8 bTempCCount[3] = { 0 }; bool Flush = true; //摆牌开始 for (int i = 0; i < 3; i++) { if (!IsFlush(bCardList, bLeftCCount, bTempCard[i], bTempCCount[i], (i == 2 ? 3 : 5))) { Flush = false; break; } RemoveCard(bTempCard[i], bTempCCount[i], bCardList, bLeftCCount); bLeftCCount -= bTempCCount[i]; if (i<2) CopyMemory(&btSpecialCard[i * 5], bTempCard[i], bTempCCount[i]); else CopyMemory(&btSpecialCard[10], bTempCard[i], bTempCCount[i]); } if (Flush) { return SSS_CT_THREE_FLUSH; } } //三顺子 { uint8 bCardList[13] = { 0 }; memcpy(bCardList, bCardData, sizeof(uint8) * 13); SortCardList(bCardList, 13); uint8 bLeftCount = 13; uint8 cbStraight[5] = { 0 }; uint8 bTempCount = 5; bool Straight = true; tag13SAnalyseType tagCardType = GetType(bCardList, bLeftCount); if (tagCardType.bStraight) { int xxx = 0; for (uint8 i = 0; i<20; i++) { if (tagCardType.cbStraight[i * 5] == 0 && tagCardType.cbStraight[i * 5 + 1] == 0) { xxx = i; break; } } if (xxx>tagCardType.btStraight) { tagCardType.btStraight = xxx; } zeromemory(btSpecialCard, sizeof(uint8) * 13); for (uint8 i = 0; i= SSS_CARD_XW && GetCardLogicValue(bCardList[1]) = 1 && bCardCount <= 13); if (bCardCount<1 || bCardCount>13) return; //转换数值; uint8 bLogicVolue[13] = {0}; for (uint8 i = 0; i < bCardCount; i++) { bLogicVolue[i] = GetCardLogicValue(bCardData[i]); } if (enDescend == SortCardType) { //排序操作; bool bSorted = true; uint8 bTempData; uint8 bLast = bCardCount - 1; uint8 m_bCardCount = 1; do { bSorted = true; for (uint8 i = 0; ibLogicVolue[i + 1]) || ((bLogicVolue[i] == bLogicVolue[i + 1]) && (bCardData[i]>bCardData[i + 1]))) { //交换位置; bTempData = bCardData[i]; bCardData[i] = bCardData[i + 1]; bCardData[i + 1] = bTempData; bTempData = bLogicVolue[i]; bLogicVolue[i] = bLogicVolue[i + 1]; bLogicVolue[i + 1] = bTempData; bSorted = false; } } bLast--; } while (bSorted == false); } else if (enColor == SortCardType) { //排序操作; bool bSorted = true; uint8 bTempData, bLast = bCardCount - 1; uint8 m_bCardCount = 1; uint8 bColor[13] = {0}; for (uint8 i = 0; i < bCardCount; i++) { bColor[i] = GetCardColor(bCardData[i]); } do { bSorted = true; for (uint8 i = 0; i (sizeof(bTempCardData) / sizeof(bTempCardData[0]))) { return false; } CopyMemory(bTempCardData, bCardData, bCardCount*sizeof(bCardData[0])); //置零扑克; for (uint8 i = 0; ibFirstList:true bNextList cbFirstLogicValue; } } //表示不比水; return 2; } case SSS_CT_ONE_DOUBLE: //对带一张; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { cbNextLogicValue = GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]); cbFirstLogicValue = GetCardLogicValue(bFirstList[FirstAnalyseData.bOneFirst[0]]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } else { return 2; } } else { return cbNextLogicValue > cbFirstLogicValue; } } case SSS_CT_THREE: //三张牌型; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { return 2; } else { return cbNextLogicValue > cbFirstLogicValue; //比较数值; } } } } else { return bNextType>bFirstType; } } else if (5 == bFirstCount) { //开始对比; if (bNextType == bFirstType) { switch (bFirstType) { case SSS_CT_SINGLE: //单牌类型; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; for (uint8 i = 0; i < 5; ++i) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_ONE_DOUBLE: //对带一张; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //对比单张; for (uint8 i = 0; i<3; ++i) { cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[i]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[i]]; if (GetCardLogicValue(cbNextCardValue) != GetCardLogicValue(cbFirstCardValue)) { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } return 2; } else { return cbNextLogicValue > cbFirstLogicValue; //比较数值; } } case SSS_CT_FIVE_TWO_DOUBLE: //两对牌型; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[1]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[1]]; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]]; if (GetCardLogicValue(cbNextCardValue) != GetCardLogicValue(cbFirstCardValue)) { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } return 2; } else { //比较数值; return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } else { return cbNextLogicValue > cbFirstLogicValue; //比较数值; } } case SSS_CT_THREE: //三张牌型; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); //比较数值 } } case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A: //A在前顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; return 2; // 12345 怎么比 都是一样大; //如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW) { if (GetCardLogicValue(bNextList[2]) == GetCardLogicValue(bFirstList[2])) return 2; else return GetCardLogicValue(bNextList[2]) > GetCardLogicValue(bFirstList[2]); //比较数值 } if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0])) return 2; else return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); //比较数值 } case SSS_CT_FIVE_MIXED_FLUSH_NO_A: //没A杂顺 { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; //如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW) { if (GetCardLogicValue(bNextList[4]) == GetCardLogicValue(bFirstList[4])) return 2; else return GetCardLogicValue(bNextList[4]) > GetCardLogicValue(bFirstList[4]); //比较数值; } if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0])) return 2; else return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); //比较数值; } case SSS_CT_FIVE_MIXED_FLUSH_BACK_A: //A在后顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; return 2; // 10 J Q K 1 怎么比 都是一样大; //如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW) { if (GetCardLogicValue(bNextList[2]) == GetCardLogicValue(bFirstList[2])) return 2; else return GetCardLogicValue(bNextList[2]) > GetCardLogicValue(bFirstList[2]); //比较数值; } if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0])) return 2; else return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); //比较数值; } case SSS_CT_FIVE_FLUSH: //同花五牌; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; //比较数值; for (uint8 i = 0; i<5; ++i) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return 2; } case SSS_CT_FIVE_THREE_DEOUBLE: //三条一对; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { //比较数值; return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } case SSS_CT_FIVE_FOUR_ONE: //四带一张; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; //如果顺子有王 就比第三张; if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW) { if (GetCardLogicValue(bNextList[3]) == GetCardLogicValue(bFirstList[3])) { return 2; } else { return GetCardLogicValue(bNextList[3]) > GetCardLogicValue(bFirstList[3]); //比较数值; } } if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); //比较数值; } } case SSS_CT_FIVE_BOMB: //五相 //zyy五同需要比较第二张; { uint8 cbNextCardValue = bNextList[NextAnalyseData.bFiveFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFiveFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; if (GetCardLogicValue(bNextList[1]) == GetCardLogicValue(bFirstList[1])) { return 2; } else { //比较数值; return GetCardLogicValue(bNextList[1]) > GetCardLogicValue(bFirstList[1]); } } case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A: //没A同花顺 { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; //zyy 如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW) { //比较数值; //for(uint8 i=2; i<5; ++i) //if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) /// zyy 3/6 2017; if (GetCardLogicValue(bNextList[4]) != GetCardLogicValue(bFirstList[4])) { return GetCardLogicValue(bNextList[4]) > GetCardLogicValue(bFirstList[4]); } else { return 2; } } //比较数值; for (uint8 i = 0; i<5; ++i) { if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) { return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]); } } //比较花色; return 2; } case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A://A在前同花顺; case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A: //A在后同花顺; { //数据验证; //ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; return 2; // 10 J Q K 1 怎么比 都是一样大; } default: return false; } } else { //同花顺牌; //if( bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A || bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH) //{ // if(SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType || SSS_CT_FIVE_STRAIGHT_FLUSH==bFirstType) // { // if(bNextType!=bFirstType) // return bNextType > bFirstType ; // // //比较数值; // for(uint8 i=0; i<5; ++i) // if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) // return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]) ; // // //比较花色; // return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]) ; // } //} return bNextType>bFirstType; } } else { if (bNextType == bFirstType) { switch (bFirstType) { case SSS_CT_THIRTEEN_FLUSH: { return 2; } case SSS_CT_TWELVE_KING: { for (int i = 0; i < 13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_THREE_STRAIGHTFLUSH: { for (int i = 0; i < 13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_THREE_BOMB: { uint8 cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; for (int i = 0; i < 3; i++) { cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[i]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[i]]; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]]; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } case SSS_CT_ALL_BIG: { for (int i = 0; i < 13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_ALL_SMALL: { for (int i = 0; i<13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_SAME_COLOR: { for (int i = 0; i<13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_FOUR_THREESAME: { uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; for (int i = 0; i < 4; i++) { cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[i]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[i]]; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]]; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } case SSS_CT_FIVEPAIR_THREE: { uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; for (int i = 0; i < 5; i++) { cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[i]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[i]]; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } case SSS_CT_SIXPAIR: { uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; for (int i = 0; i < 6; i++) { cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[i]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[i]]; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]]; if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue)) { return 2; } else { return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); } } case SSS_CT_THREE_FLUSH: { for (int i = 0; i<13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case SSS_CT_THREE_STRAIGHT: { for (int i = 0; i<13; i++) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } } } else { return bNextType>bFirstType; } } } else { //开始对比; if (bNextType == bFirstType) { switch (bFirstType) { case SSS_CT_SINGLE: //单牌类型; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; for (uint8 i = 0; i cbFirstLogicValue; } } //比较花色; return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); } case SSS_CT_ONE_DOUBLE: //对带一张; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]]; cbNextLogicValue = GetCardLogicValue(cbNextCardValue); cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } return bNextCount < bFirstCount; } case SSS_CT_FIVE_TWO_DOUBLE: //两对牌型; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[1]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[1]]; cbNextLogicValue = GetCardLogicValue(cbNextCardValue); cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //对比单牌; cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]]; cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]]; cbNextLogicValue = GetCardLogicValue(cbNextCardValue); cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } //return bNextCount < bFirstCount ; } case SSS_CT_THREE: //三张牌型; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A: //A在前顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW) { cbNextLogicValue = GetCardLogicValue(bNextList[2]); cbFirstLogicValue = GetCardLogicValue(bFirstList[2]); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(bNextList[2]) > GetCardColor(bFirstList[2]); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } if (cbNextLogicValue == cbFirstLogicValue) { //比较花色 A5432 比较 5的花色; return GetCardColor(bNextList[1]) > GetCardColor(bFirstList[1]); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case SSS_CT_FIVE_MIXED_FLUSH_NO_A: //没A杂顺 { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW) { cbNextLogicValue = GetCardLogicValue(bNextList[2]); cbFirstLogicValue = GetCardLogicValue(bFirstList[2]); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(bNextList[2]) > GetCardColor(bFirstList[2]); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } if (cbNextLogicValue == cbFirstLogicValue) { return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); //比较花色 } else { return cbNextLogicValue > cbFirstLogicValue; //比较数值 } } case SSS_CT_FIVE_MIXED_FLUSH_BACK_A: //A在后顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW) { cbNextLogicValue = GetCardLogicValue(bNextList[2]); cbFirstLogicValue = GetCardLogicValue(bFirstList[2]); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(bNextList[2]) > GetCardColor(bFirstList[2]); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case SSS_CT_FIVE_FLUSH: //同花五牌; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; uint8 cbNextCardColor = GetCardColor(bNextList[0]); uint8 cbFirstCardColor = GetCardColor(bFirstList[0]); //先比花色; if (cbNextCardColor != cbFirstCardColor) { //比较花色; return cbNextCardColor > cbFirstCardColor; } //比较数值; for (uint8 i = 0; i<5; ++i) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return cbNextCardColor > cbFirstCardColor; } case SSS_CT_FIVE_THREE_DEOUBLE: //三条一对; { uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //数据验证; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case SSS_CT_FIVE_BOMB: //zyy { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; //比较数值; for (uint8 i = 0; i<5; ++i) { uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue && (cbNextLogicValue != 16 || cbNextLogicValue != 15)) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); } case SSS_CT_FIVE_FOUR_ONE: //四带一张; { //数据验证; uint8 cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]]; uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue); uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A: //没A同花顺; case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A://A在前同花顺; case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A: //A在后同花顺; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if (bNextList[0] == bFirstList[0]) return false; uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]); uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW) { BYTE cbNextCard1Color = GetCardColor(bNextList[1]); BYTE cbFirstCard1Color = GetCardColor(bFirstList[1]); //先比花色; if (cbNextCard1Color != cbFirstCard1Color) { //比较花色; return cbNextCard1Color > cbFirstCard1Color; } //比较数值; for (uint8 i = 2; i<5; ++i) { cbNextLogicValue = GetCardLogicValue(bNextList[i]); cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return cbNextCard1Color > cbFirstCard1Color; } BYTE cbNextCardColor = GetCardColor(bNextList[0]); BYTE cbFirstCardColor = GetCardColor(bFirstList[0]); //先比花色; if (cbNextCardColor != cbFirstCardColor) { //比较花色; return cbNextCardColor > cbFirstCardColor; } //比较数值; for (uint8 i = 0; i<5; ++i) { cbNextLogicValue = GetCardLogicValue(bNextList[i]); cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return cbNextCardColor > cbFirstCardColor; } default: // #ifdef _DEBUG // AfxMessageBox("错误扑克类型!") ; // #endif return false; } } else { //同花顺牌 //if( bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A || bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH) //{ // if(SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType || SSS_CT_FIVE_STRAIGHT_FLUSH==bFirstType) // { // if(bNextType!=bFirstType) // return bNextType > bFirstType ; // // //比较数值 // for(uint8 i=0; i<5; ++i) // if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) // return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]) ; // // //比较花色 // return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]) ; // // } //} if (m_bClassicRule) { return bNextType>bFirstType; } else { if ((bFirstType == SSS_CT_FIVE_MIXED_FLUSH_NO_A&&bNextType == SSS_CT_FIVE_MIXED_FLUSH_FIRST_A) || (bFirstType == SSS_CT_FIVE_MIXED_FLUSH_FIRST_A&&bNextType == SSS_CT_FIVE_MIXED_FLUSH_NO_A)) { return bNextTypebFirstType; } } } } return false; } /* * 分析扑克的单张,一对。。。的数目,并记录下每种类型扑克的第一张牌(也就是最大的牌)位置以便比较大小,同时判断同一花色是否有五张 */ //分析扑克 //分析扑克 void C13SGameLogic::AnalyseCard(const uint8 bCardDataList[], const uint8 bCardCount, tag13SAnalyseData& AnalyseData) { //排列扑克 uint8 bCardData[13]; CopyMemory(bCardData, bCardDataList, bCardCount); SortCardList(bCardData, bCardCount, enDescend); //变量定义 uint8 bSameCount = 1, bCardValueTemp = 0, bSameColorCount = 1, bFirstCardIndex = 0; //记录下标 //ASSERT(3 == bCardCount || 5 == bCardCount || 13 == bCardCount); //设置结果 memset(&AnalyseData, 0, sizeof(AnalyseData)); if (((GetCardLogicValue(bCardData[0]) == SSS_CARD_DW || GetCardLogicValue(bCardData[0]) == SSS_CARD_XW)) && GetCardLogicValue(bCardData[1])= SSS_CARD_XW && GetCardLogicValue(CardData[1]) = 2) { Type.bTwoPare = false; for (uint8 i = 0; i0 && ThreeSameCount>0) { for (uint8 i = 0; i= SSS_CARD_XW && GetCardLogicValue(CardData[1]) GetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1) { if (Straight == 4 && bUsedW == false) { Straight++; Index[Number++] = 0; } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j= 5) { if (bCardData[Index[j]] == bCardData[Index[j + 1]] || bCardData[Index[j]] == bCardData[Index[j + 2]] || bCardData[Index[j]] == bCardData[Index[j + 3]] || bCardData[Index[j]] == bCardData[Index[j + 4]] || bCardData[Index[j + 1]] == bCardData[Index[j + 2]] || bCardData[Index[j + 1]] == bCardData[Index[j + 3]] || bCardData[Index[j + 1]] == bCardData[Index[j + 4]] || bCardData[Index[j + 2]] == bCardData[Index[j + 3]] || bCardData[Index[j + 2]] == bCardData[Index[j + 4]] || bCardData[Index[j + 3]] == bCardData[Index[j + 4]] ) { continue; } Type.cbStraight[Num[3]++] = Index[j]; Type.cbStraight[Num[3]++] = Index[j + 1]; Type.cbStraight[Num[3]++] = Index[j + 2]; Type.cbStraight[Num[3]++] = Index[j + 3]; Type.cbStraight[Num[3]++] = Index[j + 4]; Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = j; k= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); continue; } if ((bStraight == GetCardLogicValue(CardData[i]) - 2) && (false == bUsedW))//保证鬼只使用一次 { Straight++; Index[Number++] = 0; Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); bUsedW = true; } } if (Straight == 4 && bUsedW == false) { Straight++; Index[Number++] = 0; } } else { Index[Number++] = 0; bStraight = GetCardLogicValue(CardData[bCardCount - 1]); Index[Number++] = bCardCount - 1; for (int i = bCardCount - 2; i >= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j<5; j++) { Type.cbStraight[Num[3]++] = Index[j]; } Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = 0; k<5; k++) { for (int m = 0; m= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j<5; j++) { Type.cbStraight[Num[3]++] = Index[j]; } Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = 0; k<5; k++) { for (int m = 0; mGetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1) { if (Straight == 4 && ((bUsedDW == false) || (bUsedXW == false))) { if (bUsedDW == false) { Straight++; Index[Number++] = 0; bUsedDW = true; } else if (bUsedXW == false) { Straight++; Index[Number++] = 1; bUsedXW = true; } } if (Straight == 3 && ((bUsedDW == false) && (bUsedXW == false))) { Straight++; Index[Number++] = 0; Straight++; Index[Number++] = 1; } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j= 5) { if (bCardData[Index[j]] == bCardData[Index[j + 1]] || bCardData[Index[j]] == bCardData[Index[j + 2]] || bCardData[Index[j]] == bCardData[Index[j + 3]] || bCardData[Index[j]] == bCardData[Index[j + 4]] || bCardData[Index[j + 1]] == bCardData[Index[j + 2]] || bCardData[Index[j + 1]] == bCardData[Index[j + 3]] || bCardData[Index[j + 1]] == bCardData[Index[j + 4]] || bCardData[Index[j + 2]] == bCardData[Index[j + 3]] || bCardData[Index[j + 2]] == bCardData[Index[j + 4]] || bCardData[Index[j + 3]] == bCardData[Index[j + 4]] ) { continue; } Type.cbStraight[Num[3]++] = Index[j]; Type.cbStraight[Num[3]++] = Index[j + 1]; Type.cbStraight[Num[3]++] = Index[j + 2]; Type.cbStraight[Num[3]++] = Index[j + 3]; Type.cbStraight[Num[3]++] = Index[j + 4]; Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = j; k= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); continue; } else if ((bStraight == GetCardLogicValue(CardData[i]) - 2) && ((false == bDWused) || (false == bDWused)))//保证大小鬼只使用一次 { if (bDWused == false) { bDWused = true; Straight++; Index[Number++] = 0; Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } else if (bXWused == false) { bXWused = true; Straight++; Index[Number++] = 1; Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } else if ((bStraight == GetCardLogicValue(CardData[i] - 3)) && (false == bDWused) && (false == bDWused))//保证大小鬼只使用一次 { Straight++; Index[Number++] = 0; Straight++; Index[Number++] = 1; Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } } else { Index[Number++] = rand() % 2;//大小鬼任取一张 bStraight = GetCardLogicValue(CardData[bCardCount - 1]); Index[Number++] = bCardCount - 1; for (int i = bCardCount - 2; i >= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j<5; j++) { Type.cbStraight[Num[3]++] = Index[j]; } Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = 0; k<5; k++) { for (int m = 0; m= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); continue; } else if ((bStraight == GetCardLogicValue(CardData[i]) - 2) && (false == bDWused))//保证大鬼只使用一次 { if (bDWused == false) { bDWused = true; Straight++; Index[Number++] = 0; Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } } } else { Index[Number++] = 0; Index[Number++] = 1; bStraight = GetCardLogicValue(CardData[bCardCount - 1]); Index[Number++] = bCardCount - 1; for (int i = bCardCount - 2; i >= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j<5; j++) { Type.cbStraight[Num[3]++] = Index[j]; } Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = 0; k<5; k++) { for (int m = 0; m= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { Straight++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j<5; j++) { Type.cbStraight[Num[3]++] = Index[j]; } Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = 0; k<5; k++) { for (int m = 0; mGetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1) { if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j= 5) { Type.cbStraight[Num[3]++] = Index[j]; Type.cbStraight[Num[3]++] = Index[j + 1]; Type.cbStraight[Num[3]++] = Index[j + 2]; Type.cbStraight[Num[3]++] = Index[j + 3]; Type.cbStraight[Num[3]++] = Index[j + 4]; Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = j; kGetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1) { if (Straight >= 5) { Type.bStraight = true; for (uint8 j = 0; j= 5) { Type.cbStraight[Num[3]++] = Index[j]; Type.cbStraight[Num[3]++] = Index[j + 1]; Type.cbStraight[Num[3]++] = Index[j + 2]; Type.cbStraight[Num[3]++] = Index[j + 3]; Type.cbStraight[Num[3]++] = Index[j + 4]; Type.btStraight++; //从手牌中找到和顺子5张中其中一张数值相同的牌,组成另一种顺子 for (int k = j; k= 0; i--) { if (bStraight == GetCardLogicValue(CardData[i]) - 1) { FrontA++; Index[Number++] = i; bStraight = GetCardLogicValue(CardData[i]); } } if (FrontA + BackA >= 5) { Type.bStraight = true; for (uint8 i = BackA; i>0; i--) { for (uint8 j = 1; j <= FrontA; j++) { if (i + j == 5) { for (uint8 k = 0; k= SSS_CARD_XW && GetCardLogicValue(CardData[1]) = 5) { Type.bFlush = true; //切换位置 for (uint8 j = 0; jIndex[k]) { SaveIndex = Index[j]; Index[j] = Index[k]; Index[k] = SaveIndex; } } } //同花顺 if (GetCardLogicValue(cbCardData[Index[0]]) >= SSS_CARD_XW) { if (((GetCardLogicValue(cbCardData[Index[1]]) == 14) && ((GetCardLogicValue(cbCardData[Index[2]]) == 5) || (GetCardLogicValue(cbCardData[Index[2]]) == 4))) || (4 >= (GetCardLogicValue(cbCardData[Index[1]]) - GetCardLogicValue(cbCardData[Index[4]])))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[0]; Type.cbStraightFlush[Num[7]++] = Index[1]; Type.cbStraightFlush[Num[7]++] = Index[2]; Type.cbStraightFlush[Num[7]++] = Index[3]; Type.cbStraightFlush[Num[7]++] = Index[4]; Type.btStraightFlush++; } } else { //同花A2345特殊处理 if (GetCardLogicValue(cbCardData[Index[0]]) == 14) { for (uint8 i = 1; i= 5) { if (4 == (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 4]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.cbStraightFlush[Num[7]++] = Index[i + 3]; Type.cbStraightFlush[Num[7]++] = Index[i + 4]; Type.btStraightFlush++; } else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.cbStraightFlush[Num[7]++] = Index[i + 3]; Type.btStraightFlush++; } } else if (SameColorCount - i == 4) { if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.cbStraightFlush[Num[7]++] = Index[i + 3]; Type.btStraightFlush++; } } } } for (uint8 j = 0; j= 5) { Type.cbFlush[Num[4]++] = Index[j]; Type.cbFlush[Num[4]++] = Index[j + 1]; Type.cbFlush[Num[4]++] = Index[j + 2]; Type.cbFlush[Num[4]++] = Index[j + 3]; Type.cbFlush[Num[4]++] = Index[j + 4]; Type.btFlush++; } else { break; } } } if (bCardCount - i<4) { break; } Number = 0; zeromemory(Index, sizeof(Index)); SameColorCount = 1; Index[Number++] = i; bCardColor = GetCardColor(CardData[i]); } } } else if (GetCardLogicValue(CardData[0]) == SSS_CARD_DW && GetCardLogicValue(CardData[1]) == SSS_CARD_XW) { uint8 SameColorCount = 1; uint8 bCardColor = GetCardColor(CardData[2]); Index[Number++] = 2; for (uint8 i = 3; i= 5) { Type.bFlush = true; for (uint8 j = 0; jIndex[k]) { SaveIndex = Index[j]; Index[j] = Index[k]; Index[k] = SaveIndex; } } } //同花顺 if (GetCardLogicValue(cbCardData[Index[0]]) == SSS_CARD_DW && GetCardLogicValue(cbCardData[Index[1]]) == SSS_CARD_XW) { if (((GetCardLogicValue(cbCardData[Index[2]]) == 14) && ((GetCardLogicValue(cbCardData[Index[3]]) == 5) || (GetCardLogicValue(cbCardData[Index[3]]) == 4) || (GetCardLogicValue(cbCardData[Index[3]]) == 3))) || (4 >= (GetCardLogicValue(cbCardData[Index[2]]) - GetCardLogicValue(cbCardData[Index[4]])))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[0]; Type.cbStraightFlush[Num[7]++] = Index[1]; Type.cbStraightFlush[Num[7]++] = Index[2]; Type.cbStraightFlush[Num[7]++] = Index[3]; Type.cbStraightFlush[Num[7]++] = Index[4]; Type.btStraightFlush++; } } else if (GetCardLogicValue(cbCardData[Index[0]]) >= SSS_CARD_XW && GetCardLogicValue(cbCardData[Index[1]]) = (GetCardLogicValue(cbCardData[Index[1]]) - GetCardLogicValue(cbCardData[Index[4]])))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[0]; Type.cbStraightFlush[Num[7]++] = Index[1]; Type.cbStraightFlush[Num[7]++] = Index[2]; Type.cbStraightFlush[Num[7]++] = Index[3]; Type.cbStraightFlush[Num[7]++] = Index[4]; Type.btStraightFlush++; } } else { //同花A2345特殊处理 if (GetCardLogicValue(cbCardData[Index[0]]) == 14) { for (uint8 i = 1; i= 5) { if (4 == (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 4]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.cbStraightFlush[Num[7]++] = Index[i + 3]; Type.cbStraightFlush[Num[7]++] = Index[i + 4]; Type.btStraightFlush++; } else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.cbStraightFlush[Num[7]++] = Index[i + 3]; Type.btStraightFlush++; } else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 2]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = 1; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.btStraightFlush++; } } else if (SameColorCount - i == 4) { if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.cbStraightFlush[Num[7]++] = Index[i + 3]; Type.btStraightFlush++; } else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 2]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = 1; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.btStraightFlush++; } } else if (SameColorCount - i == 3) { if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 2]]))) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = 0; Type.cbStraightFlush[Num[7]++] = 1; Type.cbStraightFlush[Num[7]++] = Index[i]; Type.cbStraightFlush[Num[7]++] = Index[i + 1]; Type.cbStraightFlush[Num[7]++] = Index[i + 2]; Type.btStraightFlush++; } } } } for (uint8 j = 0; j= 5) { Type.cbFlush[Num[4]++] = Index[j]; Type.cbFlush[Num[4]++] = Index[j + 1]; Type.cbFlush[Num[4]++] = Index[j + 2]; Type.cbFlush[Num[4]++] = Index[j + 3]; Type.cbFlush[Num[4]++] = Index[j + 4]; Type.btFlush++; } else { break; } } } if (bCardCount - i<3) { break; } Number = 0; zeromemory(Index, sizeof(Index)); SameColorCount = 1; Index[Number++] = i; bCardColor = GetCardColor(CardData[i]); } } } else { uint8 SameColorCount = 1; uint8 bCardColor = GetCardColor(CardData[0]); Index[Number++] = 0; for (uint8 i = 1; i= 5) { Type.bFlush = true; for (uint8 j = 0; jIndex[k]) { SaveIndex = Index[j]; Index[j] = Index[k]; Index[k] = SaveIndex; } } } for (uint8 j = 0; j= 5) { Type.cbFlush[Num[4]++] = Index[j]; Type.cbFlush[Num[4]++] = Index[j + 1]; Type.cbFlush[Num[4]++] = Index[j + 2]; Type.cbFlush[Num[4]++] = Index[j + 3]; Type.cbFlush[Num[4]++] = Index[j + 4]; Type.btFlush++; //同花A2345特殊处理 if (GetCardLogicValue(cbCardData[Index[j]]) == 14) { for (uint8 i = j + 1; i= 4) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[j];//A Type.cbStraightFlush[Num[7]++] = Index[i];//5 Type.cbStraightFlush[Num[7]++] = Index[i + 1];//4 Type.cbStraightFlush[Num[7]++] = Index[i + 2];//3 Type.cbStraightFlush[Num[7]++] = Index[i + 3];//2 Type.btStraightFlush++; } } } } if (GetCardLogicValue(cbCardData[Index[j]]) - GetCardLogicValue(cbCardData[Index[j + 4]]) == 4) { Type.bStraightFlush = true; Type.cbStraightFlush[Num[7]++] = Index[j]; Type.cbStraightFlush[Num[7]++] = Index[j + 1]; Type.cbStraightFlush[Num[7]++] = Index[j + 2]; Type.cbStraightFlush[Num[7]++] = Index[j + 3]; Type.cbStraightFlush[Num[7]++] = Index[j + 4]; Type.btStraightFlush++; } } else { break; } } } if (bCardCount - i<5) { break; } Number = 0; zeromemory(Index, sizeof(Index)); SameColorCount = 1; Index[Number++] = i; bCardColor = GetCardColor(CardData[i]); } } } return Type; } bool C13SGameLogic::AppendCard(const uint8 bAppendCard[], uint8 bAppendCount, uint8 bCardData[], uint8 &bCardCount) { //ASSERT(bAppendCount + bCardCount <= 13); for (int i = 0; i0) { Number++; } else { break; } } } return Number; } bool C13SGameLogic::IsSameCardData(uint8 btFirstCard[], uint8 btNextCard[], uint8 btFirstCount, uint8 btNextCount) { if (btNextCount != btFirstCount) { return false; } for (int i = 0; i 3); //定义变量 uint8 bKCount = 0; std::vector evCardList[15]; //0位存王牌,1位保留,其他位按逻辑值存放 std::vector evColorList[4]; //方梅红黑 uint8 bCardArray[13] = { 0 }; memcpy(bCardArray, cbCardData, sizeof(uint8)*cbCardCount); SortCardList(bCardArray, cbCardCount, enDescend); //分析扑克 for (int i = 0; i < cbCardCount; i++) { //保存王牌 if (bCardArray[i] == 0x41 || bCardArray[i] == 0x42) { evCardList[0].push_back(bCardArray[i]); continue; } //保存其他 uint8 bLogicNum = GetCardLogicValue(bCardArray[i]); uint8 bColor = GetCardColor(bCardArray[i]); //ASSERT(bLogicNum>1 && bLogicNum<15 && bColor >= 0 && bColor <= 3); //ASSERT(std::find(evCardList[bLogicNum].begin(), evCardList[bLogicNum].end(), bCardArray[i]) != evCardList[bLogicNum].end()); evCardList[bLogicNum].push_back(bCardArray[i]); evColorList[bColor].push_back(bCardArray[i]); } //ASSERT(evCardList[0].size() <= 2); //寻找同花 uint8 bPossibleCard[4][5] = { 0 }; //各个能组成同花的牌组 std::vector maxCardColorList; for (int i = 0; i < 4; i++) { if (evColorList[i].size() + evCardList[0].size() >= bNeedCCount) { if (evColorList[i].size() >= bNeedCCount) { for (int k = 0; k < bNeedCCount; k++) { bPossibleCard[i][k] = evColorList[i].at(k); } } else { int j = 0; for (; j < bNeedCCount - evColorList[i].size(); j++) { bPossibleCard[i][j] = evCardList[0].at(j); } for (int k = 0; k < evColorList[i].size(); k++) { bPossibleCard[i][j + k] = evColorList[i].at(k); } } maxCardColorList.push_back(i); } } if (maxCardColorList.size() != 0) { uint8 bMax = maxCardColorList.at(0); for (int i = 1; i < maxCardColorList.size(); i++) { uint8 bColor = maxCardColorList.at(i); if (CompareCard(bPossibleCard[bMax], bPossibleCard[bColor], bNeedCCount, bNeedCCount, m_bClassicRule)) { bMax = bColor; } } memcpy(bMaxCardData, bPossibleCard[bMax], sizeof(uint8)*bNeedCCount); bMaxCardCount = bNeedCCount; return true; } return false; } // 获取牌型图片路径; std::string C13SGameLogic::getCardTypeImagePath(uint8 cbCardType) { switch (cbCardType) { case SSS_CT_SINGLE: { return "Games/13S/CardType/N_SanPai.png"; } case SSS_CT_ONE_DOUBLE: { return "Games/13S/CardType/N_YiDui.png"; } case SSS_CT_FIVE_TWO_DOUBLE: { return "Games/13S/CardType/N_LiangDui.png"; } case SSS_CT_THREE: { return "Games/13S/CardType/N_SanTiao.png"; } case SSS_CT_FIVE_MIXED_FLUSH_NO_A: case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A: case SSS_CT_FIVE_MIXED_FLUSH_BACK_A: { return "Games/13S/CardType/N_ShunZi.png"; } case SSS_CT_FIVE_FLUSH: { return "Games/13S/CardType/N_TongHua.png";; } case SSS_CT_FIVE_THREE_DEOUBLE: { return "Games/13S/CardType/N_HuLu.png"; } case SSS_CT_FIVE_FOUR_ONE: { return "Games/13S/CardType/N_TieZhi.png"; } case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A: case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A: case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A: { return "Games/13S/CardType/N_TongHuaShun.png"; } case SSS_CT_FIVE_BOMB: { break; } case SSS_CT_THREE_STRAIGHT: { return "Games/13S/CardType/S_SanShunZi.png"; } case SSS_CT_THREE_FLUSH: { return "Games/13S/CardType/S_SanTongHua.png"; } case SSS_CT_SIXPAIR: { return "Games/13S/CardType/S_LiuDuiBan.png"; } case SSS_CT_FIVEPAIR_THREE: { return "Games/13S/CardType/S_WuDuiSanTiao.png"; } case SSS_CT_FOUR_THREESAME: { return "Games/13S/CardType/S_SiTaoBanTiao.png"; } case SSS_CT_SAME_COLOR: { return "Games/13S/CardType/S_CouYiSe.png"; } case SSS_CT_ALL_SMALL: { return "Games/13S/CardType/S_QuanXiao.png"; } case SSS_CT_ALL_BIG: { return "Games/13S/CardType/S_QuanDa.png"; } case SSS_CT_THREE_BOMB: { return "Games/13S/CardType/S_SanFenTianXia.png"; } case SSS_CT_THREE_STRAIGHTFLUSH: { return "Games/13S/CardType/S_SanTongHuaShun.png"; } case SSS_CT_TWELVE_KING: { return "Games/13S/CardType/S_ShiErHuangZu.png"; } case SSS_CT_THIRTEEN: { return "Games/13S/CardType/S_YiTiaoLong.png"; } case SSS_CT_THIRTEEN_FLUSH: { return "Games/13S/CardType/S_ZhiZunQingLong.png"; } default: break; } return ""; } // 获取牌型声音路径; std::string C13SGameLogic::getCardTypeSoundPath(uint8 cbGender, uint8 cbCardType) { std::string strPath = "Games/13S/Sound/"; if (0 == cbGender) { strPath += "man/m_"; } else { strPath += "woman/f_"; } switch (cbCardType) { case SSS_CT_SINGLE: { strPath += "wulong.mp3"; break; } case SSS_CT_ONE_DOUBLE: { strPath += "duizi.mp3"; break; } case SSS_CT_FIVE_TWO_DOUBLE: { strPath += "liangdui.mp3"; break; } case SSS_CT_THREE: { strPath += "santiao.mp3"; break; } case SSS_CT_FIVE_MIXED_FLUSH_NO_A: case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A: case SSS_CT_FIVE_MIXED_FLUSH_BACK_A: { strPath += "shunzi.mp3"; break; } case SSS_CT_FIVE_FLUSH: { strPath += "tonghua.mp3"; break; } case SSS_CT_FIVE_THREE_DEOUBLE: { strPath += "hulu.mp3"; break; } case SSS_CT_FIVE_FOUR_ONE: { strPath += "tiezhi.mp3"; break; } case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A: case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A: case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A: { strPath += "tonghuashun.mp3"; break; } case SSS_CT_FIVE_BOMB: { break; } case SSS_CT_THREE_STRAIGHT: { strPath += "sanshunzi.mp3"; break; } case SSS_CT_THREE_FLUSH: { strPath += "santonghua.mp3"; break; } case SSS_CT_SIXPAIR: { strPath += "liuduiban.mp3"; break; } case SSS_CT_FIVEPAIR_THREE: { strPath += "wuduisantiao.mp3"; break; } case SSS_CT_FOUR_THREESAME: { strPath += "sitaosantiao.mp3"; break; } case SSS_CT_SAME_COLOR: { strPath += "couyisi.mp3"; break; } case SSS_CT_ALL_SMALL: { strPath += "quanxiao.mp3"; break; } case SSS_CT_ALL_BIG: { strPath += "quanda.mp3"; break; } case SSS_CT_THREE_BOMB: { strPath += "sanfentianxia.mp3"; break; } case SSS_CT_THREE_STRAIGHTFLUSH: { strPath += "santonghuashun.mp3"; break; } case SSS_CT_TWELVE_KING: { strPath += "12huangzu.mp3"; break; } case SSS_CT_THIRTEEN: { strPath += "yitiaolong.mp3"; break; } case SSS_CT_THIRTEEN_FLUSH: { strPath += "qinglong.mp3"; break; } default: break; } return strPath; } //////////////////////////////////////////////////////////////////////////