#include "StdAfx.h" #include "GameLogic.h" ////////////////////////////////////////////////////////////////////////// //静态变量 const BYTE CGameLogic::m_bCardListData[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, }; ////////////////////////////////////////////////////////////////////////// //构造函数 CGameLogic::CGameLogic() { ZeroMemory(btCardSpecialData,sizeof(btCardSpecialData)); m_bClassicRule = true; } //析构函数 CGameLogic::~CGameLogic() { } //获取类型 BYTE CGameLogic::GetCardType(BYTE bCardData[], BYTE bCardCount,BYTE btSpecialCard[]) { //数据校验 ASSERT(bCardCount==3 || bCardCount==5||13==bCardCount) ; if(bCardCount!=3 && bCardCount!=5&&bCardCount!=13) return CT_INVALID ; tagAnalyseData AnalyseData ; memset(&AnalyseData , 0 , sizeof(tagAnalyseData)) ; //ASSERT(3==bCardCount || 5==bCardCount) ; AnalyseCard(bCardData , bCardCount , AnalyseData) ; //开始分析 switch (bCardCount) { case 3: //三条类型 { //单牌类型 if(3==AnalyseData.bOneCount) return CT_SINGLE; //对带一张 if(1==AnalyseData.bTwoCount && 1==AnalyseData.bOneCount) return CT_ONE_DOUBLE ; //三张牌型 if(1==AnalyseData.bThreeCount) return CT_THREE ; //错误类型 return CT_INVALID ; } case 5: //五张牌型 { bool bFlushNoA = false , bFlushFirstA = false , bFlushBackA = false ; if (GetCardLogicValue(bCardData[0])>= CARD_XW && GetCardLogicValue(bCardData[1])=GetCardLogicValue(bCardData[2]))//A连在前 { bFlushFirstA = true; for (BYTE i=2; i<4; ++i) { BYTE 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])==CARD_DW || GetCardLogicValue(bCardData[0])==CARD_XW))//A连在前 { bFlushFirstA = true; for (BYTE i=1; i<4; ++i) { BYTE nValue=GetCardLogicValue(bCardData[i])-GetCardLogicValue(bCardData[i+1]); if (1 != nValue && nValue != 2) { bFlushFirstA = false; break; } } } else { bFlushNoA = true; bool bRes=false; for (BYTE i=1; i<4; ++i) { BYTE A=GetCardLogicValue(bCardData[i]); BYTE B=GetCardLogicValue(bCardData[i+1]); BYTE 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])== CARD_DW && GetCardLogicValue(bCardData[1])==CARD_XW) { if (GetCardLogicValue(bCardData[0])==CARD_DW&& GetCardLogicValue(bCardData[1])==CARD_XW) { bFlushBackA = true; BYTE bIndex = 0; for (BYTE i=2; i<5; ++i) { if (GetCardLogicValue(bCardData[i])>=10) bIndex++; } if (GetCardLogicValue(bCardData[2]) != 14) { for (BYTE i=2; i<4; ++i) { BYTE 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 (BYTE i=3; i<4; ++i) { BYTE 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 (BYTE i=2; i<4; ++i) { BYTE 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 (BYTE i=2; i<4; ++i) { BYTE A=GetCardLogicValue(bCardData[i]); BYTE B=GetCardLogicValue(bCardData[i+1]); BYTE 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(BYTE i=2 ; i<4 ; ++i) { BYTE 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(BYTE i=0 ; i<4 ; ++i) { BYTE 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 (BYTE 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 CT_FIVE_FLUSH ; } else if(true==bFlushNoA) { //杂顺类型 if(false==AnalyseData.bStraight) return CT_FIVE_MIXED_FLUSH_NO_A; //同花顺牌 else return CT_FIVE_STRAIGHT_FLUSH_NO_A ; } else if(true==bFlushFirstA) { //杂顺类型 if(false==AnalyseData.bStraight) return CT_FIVE_MIXED_FLUSH_FIRST_A; //同花顺牌 else return CT_FIVE_STRAIGHT_FLUSH_FIRST_A ; } else if(true==bFlushBackA) { //杂顺类型 if(false==AnalyseData.bStraight) return CT_FIVE_MIXED_FLUSH_BACK_A; //同花顺牌 else return CT_FIVE_STRAIGHT_FLUSH_BACK_A ; } //五带0张 if (1==AnalyseData.bFiveCount) return CT_FIVE_BOMB; //四带单张 if(1==AnalyseData.bFourCount && 1==AnalyseData.bOneCount) return CT_FIVE_FOUR_ONE ; //三条一对 if(1==AnalyseData.bThreeCount && 1==AnalyseData.bTwoCount) return CT_FIVE_THREE_DEOUBLE ; //三条带单 if(1==AnalyseData.bThreeCount && 2==AnalyseData.bOneCount) return CT_THREE ; //两对牌型 if(2==AnalyseData.bTwoCount && 1==AnalyseData.bOneCount) return CT_FIVE_TWO_DOUBLE ; //只有一对 if(1==AnalyseData.bTwoCount && 3==AnalyseData.bOneCount) return CT_ONE_DOUBLE ; //单牌类型 if(5==AnalyseData.bOneCount && false==AnalyseData.bStraight) return CT_SINGLE ; //错误类型 return CT_INVALID; } case 13://13张特殊牌型 { bool TwelveKing=false; //同花十三水 if(13==AnalyseData.bOneCount&&true==AnalyseData.bStraight) return CT_THIRTEEN_FLUSH; //十三水 if(13==AnalyseData.bOneCount) return CT_THIRTEEN; //十二皇族 TwelveKing=true; for(int i=0;i<13;i++) { if(GetCardLogicValue(bCardData[i])<11) { TwelveKing=false; break; } } if(TwelveKing) { return CT_TWELVE_KING; } //三同花顺 /*bool bThreeStraightFlush = false; bThreeStraightFlush = IsThreeFlushStraight(bCardData,bCardCount); if (bThreeStraightFlush) { return CT_THREE_STRAIGHTFLUSH; }*/ //三同花顺子 { BYTE bCardList[13] = {0}; memcpy(bCardList,bCardData,sizeof(BYTE)*13); SortCardList(bCardList,13); BYTE bLeftCount = 13; BYTE cbStraightFlush[5] = {0}; BYTE bTempCount = 5; tagAnalyseType tagCardType = GetType(bCardList,bLeftCount); if (tagCardType.bStraightFlush) { for (BYTE i = 0;i=CARD_XW && GetCardLogicValue(bCardList[1]) 8&&GetCardLogicValue(bCardData[i]) != CARD_XW&&GetCardLogicValue(bCardData[i]) != CARD_DW) { AllSmall=false; break; } } if(AllSmall) { return CT_ALL_SMALL; } //凑一色 { BYTE Flush=1; BYTE bStartIndex = 0; BYTE SColor=0; BYTE bSameColorList[13] = {0}; memcpy(bSameColorList, bCardData, sizeof(BYTE)*13); SortCardList(bSameColorList,13); if (GetCardLogicValue(bSameColorList[0])>= CARD_XW && GetCardLogicValue(bSameColorList[1])= CARD_XW && GetCardLogicValue(bSameColorList[1])>=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 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])==CARD_XW||GetCardLogicValue(bCardData[0])==CARD_DW))) { return 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 CT_FIVEPAIR_THREE; } //六对半 if(6==AnalyseData.bTwoCount||(4==AnalyseData.bTwoCount&&1==AnalyseData.bFourCount)||(2==AnalyseData.bTwoCount&&2==AnalyseData.bFourCount) ||(3==AnalyseData.bFourCount)) { return CT_SIXPAIR; } //三同花 { //定义变量 BYTE bCardList[13] = {0}; memcpy(bCardList, bCardData, sizeof(BYTE)*13); BYTE bLeftCCount = 13; BYTE bTempCard[3][5] = {0}; BYTE 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 CT_THREE_FLUSH; } } //三顺子 { BYTE bCardList[13] = {0}; memcpy(bCardList,bCardData,sizeof(BYTE)*13); SortCardList(bCardList,13); BYTE bLeftCount = 13; BYTE cbStraight[5] = {0}; BYTE bTempCount = 5; bool Straight = true; tagAnalyseType tagCardType = GetType(bCardList,bLeftCount); if (tagCardType.bStraight) { int xxx = 0; for(BYTE 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(BYTE)*13); for (BYTE i = 0;i=CARD_XW && GetCardLogicValue(bCardList[1]) =1 && bCardCount<=13) ; if(bCardCount<1 || bCardCount>13) return ; //转换数值 BYTE bLogicVolue[13]; for (BYTE 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; BYTE bTempData,bLast=bCardCount-1; BYTE m_bCardCount=1; BYTE bColor[13]; for (BYTE i=0;iCountArray(bTempCardData)) return false; CopyMemory(bTempCardData,bCardData,bCardCount*sizeof(bCardData[0])); //置零扑克 for (BYTE i=0;ibFirstList:true bNextList cbFirstLogicValue; } } //表示不比水; return 2; } case CT_ONE_DOUBLE: //对带一张; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_THREE: //三张牌型; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_SINGLE: //单牌类型; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; for (BYTE i = 0; i < 5; ++i) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_ONE_DOUBLE: //对带一张; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //对比单张; for(BYTE 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 CT_FIVE_TWO_DOUBLE: //两对牌型; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_THREE: //三张牌型; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; BYTE 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 CT_FIVE_MIXED_FLUSH_FIRST_A: //A在前顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; return 2; // 12345 怎么比 都是一样大; //zyy 如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == CARD_DW||GetCardLogicValue(bNextList[0]) == CARD_XW ||GetCardLogicValue(bFirstList[0]) == CARD_DW||GetCardLogicValue(bFirstList[0]) == 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 CT_FIVE_MIXED_FLUSH_NO_A: //没A杂顺 { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; //zyy 如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == CARD_DW||GetCardLogicValue(bNextList[0]) == CARD_XW ||GetCardLogicValue(bFirstList[0]) == CARD_DW||GetCardLogicValue(bFirstList[0]) == 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 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 怎么比 都是一样大; //zyy 如果顺子有王 就比第二张; if (GetCardLogicValue(bNextList[0]) == CARD_DW||GetCardLogicValue(bNextList[0]) == CARD_XW ||GetCardLogicValue(bFirstList[0]) == CARD_DW||GetCardLogicValue(bFirstList[0]) == 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 CT_FIVE_FLUSH: //同花五牌; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; //比较数值; for (BYTE i = 0; i<5; ++i) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return 2; } case CT_FIVE_THREE_DEOUBLE: //三条一对; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; BYTE 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 CT_FIVE_FOUR_ONE: //四带一张; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; //zyy 如果顺子有王 就比第三张; if (GetCardLogicValue(bNextList[0]) == CARD_DW||GetCardLogicValue(bNextList[0]) == CARD_XW ||GetCardLogicValue(bFirstList[0]) == CARD_DW||GetCardLogicValue(bFirstList[0]) == 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 CT_FIVE_BOMB: //五相 //zyy五同需要比较第二张; { BYTE cbNextCardValue = bNextList[NextAnalyseData.bFiveFirst[0]]; BYTE 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 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]) == CARD_DW||GetCardLogicValue(bNextList[0]) == CARD_XW ||GetCardLogicValue(bFirstList[0]) == CARD_DW||GetCardLogicValue(bFirstList[0]) == CARD_XW) { //比较数值; //for(BYTE 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 (BYTE i = 0; i<5; ++i) { if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i])) { return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]); } } //比较花色; return 2; } case CT_FIVE_STRAIGHT_FLUSH_FIRST_A://A在前同花顺; case 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==CT_FIVE_STRAIGHT_FLUSH_FIRST_A || bNextType==CT_FIVE_STRAIGHT_FLUSH) //{ // if(CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType || CT_FIVE_STRAIGHT_FLUSH==bFirstType) // { // if(bNextType!=bFirstType) // return bNextType > bFirstType ; // // //比较数值; // for(BYTE 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 CT_THIRTEEN_FLUSH: { return 2; } case CT_TWELVE_KING: { for (int i = 0; i < 13; i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_THREE_STRAIGHTFLUSH: { for (int i = 0; i < 13; i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_THREE_BOMB: { BYTE cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]]; BYTE 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]]; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_ALL_BIG: { for (int i = 0; i < 13; i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_ALL_SMALL: { for(int i=0;i<13;i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_SAME_COLOR: { for(int i=0;i<13;i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_FOUR_THREESAME: { BYTE cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; BYTE 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]]; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_FIVEPAIR_THREE: { BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE 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]]; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_SIXPAIR: { BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE 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]]; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_THREE_FLUSH: { for(int i=0;i<13;i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } case CT_THREE_STRAIGHT: { for(int i=0;i<13;i++) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } return 2; } } } else { return bNextType>bFirstType; } } } else { //开始对比; if(bNextType==bFirstType) { switch(bFirstType) { case CT_SINGLE: //单牌类型; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; for(BYTE i=0 ; i<3 ; ++i) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); } case CT_ONE_DOUBLE: //对带一张; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; ASSERT(cbNextCardValue!=cbFirstCardValue) ; if(cbNextCardValue==cbFirstCardValue) return false ; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_FIVE_TWO_DOUBLE: //两对牌型; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]]; ASSERT(cbNextCardValue!=cbFirstCardValue) ; if(cbNextCardValue==cbFirstCardValue) return false ; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE 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 CT_THREE: //三张牌型; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if(cbNextCardValue==cbFirstCardValue) return false ; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case CT_FIVE_MIXED_FLUSH_FIRST_A: //A在前顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; BYTE cbNextLogicValue = GetCardLogicValue(bNextList[0]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == CARD_DW||cbNextLogicValue == CARD_XW ||cbFirstLogicValue == CARD_DW||cbFirstLogicValue == 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 CT_FIVE_MIXED_FLUSH_NO_A: //没A杂顺 { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; BYTE cbNextLogicValue = GetCardLogicValue(bNextList[0]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == CARD_DW||cbNextLogicValue == CARD_XW||cbFirstLogicValue == CARD_DW||cbFirstLogicValue == 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 CT_FIVE_MIXED_FLUSH_BACK_A: //A在后顺子; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; BYTE cbNextLogicValue = GetCardLogicValue(bNextList[0]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == CARD_DW||cbNextLogicValue == CARD_XW||cbFirstLogicValue == CARD_DW||cbFirstLogicValue == 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 CT_FIVE_FLUSH: //同花五牌; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; BYTE cbNextCardColor = GetCardColor(bNextList[0]); BYTE cbFirstCardColor = GetCardColor(bFirstList[0]); //先比花色; if (cbNextCardColor!=cbFirstCardColor) { //比较花色; return cbNextCardColor > cbFirstCardColor; } //比较数值; for(BYTE i=0; i<5; ++i) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return cbNextCardColor > cbFirstCardColor; } case CT_FIVE_THREE_DEOUBLE: //三条一对; { BYTE cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]]; //数据验证; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if(cbNextCardValue==cbFirstCardValue) return false ; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case CT_FIVE_BOMB: //zyy { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; //比较数值; for(BYTE i=0; i<5; ++i) { BYTE cbNextLogicValue = GetCardLogicValue(bNextList[i]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[i]); if (cbNextLogicValue != cbFirstLogicValue && (cbNextLogicValue != 16 || cbNextLogicValue != 15)) { return cbNextLogicValue > cbFirstLogicValue; } } //比较花色; return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); } case CT_FIVE_FOUR_ONE: //四带一张; { //数据验证; BYTE cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]]; BYTE cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]]; //CC_//ASSERT(cbNextCardValue != cbFirstCardValue); if (cbNextCardValue == cbFirstCardValue) return false; BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardValue); BYTE cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue); if (cbNextLogicValue == cbFirstLogicValue) { //比较花色; return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue); } else { //比较数值; return cbNextLogicValue > cbFirstLogicValue; } } case CT_FIVE_STRAIGHT_FLUSH_NO_A: //没A同花顺; case CT_FIVE_STRAIGHT_FLUSH_FIRST_A://A在前同花顺; case CT_FIVE_STRAIGHT_FLUSH_BACK_A: //A在后同花顺; { //数据验证; //CC_//ASSERT(bNextList[0] != bFirstList[0]); if(bNextList[0]==bFirstList[0]) return false ; BYTE cbNextLogicValue = GetCardLogicValue(bNextList[0]); BYTE cbFirstLogicValue = GetCardLogicValue(bFirstList[0]); //zyy 如果顺子有王 就比第二张; if (cbNextLogicValue == CARD_DW||cbNextLogicValue == CARD_XW||cbFirstLogicValue == CARD_DW||cbFirstLogicValue == CARD_XW) { BYTE cbNextCard1Color = GetCardColor(bNextList[1]); BYTE cbFirstCard1Color = GetCardColor(bFirstList[1]); //先比花色; if (cbNextCard1Color != cbFirstCard1Color) { //比较花色; return cbNextCard1Color > cbFirstCard1Color; } //比较数值; for(BYTE 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(BYTE 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==CT_FIVE_STRAIGHT_FLUSH_FIRST_A || bNextType==CT_FIVE_STRAIGHT_FLUSH) //{ // if(CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType || CT_FIVE_STRAIGHT_FLUSH==bFirstType) // { // if(bNextType!=bFirstType) // return bNextType > bFirstType ; // // //比较数值 // for(BYTE 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 == CT_FIVE_MIXED_FLUSH_NO_A&&bNextType == CT_FIVE_MIXED_FLUSH_FIRST_A) || (bFirstType == CT_FIVE_MIXED_FLUSH_FIRST_A&&bNextType == CT_FIVE_MIXED_FLUSH_NO_A)) { return bNextType < bFirstType; } else { return bNextType > bFirstType; } } } } return false; } /* * 分析扑克的单张,一对。。。的数目,并记录下每种类型扑克的第一张牌(也就是最大的牌)位置以便比较大小,同时判断同一花色是否有五张 */ //分析扑克 //分析扑克 void CGameLogic::AnalyseCard(const BYTE bCardDataList[] , const BYTE bCardCount , tagAnalyseData& AnalyseData) { //排列扑克 BYTE bCardData[13] ; CopyMemory(bCardData , bCardDataList , bCardCount) ; SortCardList(bCardData , bCardCount , enDescend) ; //变量定义 BYTE bSameCount = 1 , bCardValueTemp=0, bSameColorCount = 1 , bFirstCardIndex = 0 ; //记录下标 ASSERT(3==bCardCount || 5==bCardCount||13==bCardCount) ; //设置结果 memset(&AnalyseData,0,sizeof(AnalyseData)); if (((GetCardLogicValue(bCardData[0])==CARD_DW || GetCardLogicValue(bCardData[0]) == CARD_XW)) && GetCardLogicValue(bCardData[1])=CARD_XW && GetCardLogicValue(CardData[1]) =2) { Type.bTwoPare=false; for(BYTE i=0;i0&&ThreeSameCount>0) { for(BYTE i=0;i=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(BYTE 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(BYTE 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(BYTE 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(BYTE 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(BYTE 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(BYTE 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(BYTE 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(BYTE 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(BYTE 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(BYTE i=BackA;i>0;i--) { for(BYTE j=1;j<=FrontA;j++) { if(i+j==5) { for(BYTE k=0;k=CARD_XW && GetCardLogicValue(CardData[1]) =5) { Type.bFlush=true; //切换位置 for(BYTE j=0;jIndex[k]) { SaveIndex=Index[j]; Index[j]=Index[k]; Index[k]=SaveIndex; } } } //同花顺 if (GetCardLogicValue(cbCardData[Index[0]])>=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 (BYTE 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(BYTE 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]) ==CARD_DW && GetCardLogicValue(CardData[1]) ==CARD_XW) { BYTE SameColorCount=1; BYTE bCardColor = GetCardColor(CardData[2]) ; Index[Number++]=2; for(BYTE i=3;i=5) { Type.bFlush=true; for(BYTE j=0;jIndex[k]) { SaveIndex=Index[j]; Index[j]=Index[k]; Index[k]=SaveIndex; } } } //同花顺 if (GetCardLogicValue(cbCardData[Index[0]]) ==CARD_DW && GetCardLogicValue(cbCardData[Index[1]]) ==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]])>=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 (BYTE 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(BYTE 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 { BYTE SameColorCount=1; BYTE bCardColor = GetCardColor(CardData[0]) ; Index[Number++]=0; for(BYTE i=1;i=5) { Type.bFlush=true; for(BYTE j=0;jIndex[k]) { SaveIndex=Index[j]; Index[j]=Index[k]; Index[k]=SaveIndex; } } } for(BYTE 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 (BYTE 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 CGameLogic::AppendCard( const BYTE bAppendCard[],BYTE bAppendCount,BYTE bCardData[],BYTE &bCardCount ) { ASSERT(bAppendCount+bCardCount<=13); for(int i=0;i0) { Number++; } else { break; } } } return Number; } //void CGameLogic::TheBestCard(tagAnalyseType tagCardType,BYTE btHandCardData[],BYTE btHandCardCount,BYTE btFrontCard[],BYTE btMidCard[],BYTE btBackCard[] ) //{ // if(btHandCardCount!=13) // { // return; // } // BYTE btCardCount=btHandCardCount; // BYTE btCardData[13]; // CopyMemory(btCardData,btHandCardData,sizeof(btCardData)); // BYTE btCardData1[13]; // BYTE btCardData2[13]; // ZeroMemory(btCardData1,sizeof(btCardData1)); // ZeroMemory(btCardData2,sizeof(btCardData2)); // BYTE btCardCount1=0; // BYTE btCardCount2=0; // BYTE FrontCard[3]; // BYTE MidCard[5]; // BYTE BackCard[5]; // BYTE btAllShuiShu=0; // ZeroMemory(FrontCard,sizeof(FrontCard)); // ZeroMemory(MidCard,sizeof(MidCard)); // ZeroMemory(BackCard,sizeof(BackCard)); // BYTE FrontFrontCard[3]; // BYTE FrontMidCard[5]; // BYTE FrontBackCard[5]; // BYTE btFrontAllShuiShu=0; // ZeroMemory(FrontFrontCard,sizeof(FrontFrontCard)); // ZeroMemory(FrontMidCard,sizeof(FrontMidCard)); // ZeroMemory(FrontBackCard,sizeof(FrontBackCard)); // bool bCycling=true; // bool bFront=false; // bool bMid=false; // bool bBack=false; // bool bFirst=true; // BYTE btFront=0; // BYTE btMid=0; // BYTE btBack=0; // tagAnalyseType tagCardType1; // tagAnalyseType tagCardType2; // ZeroMemory(&tagCardType1,sizeof(tagCardType1)); // ZeroMemory(&tagCardType2,sizeof(tagCardType2)); // BYTE btTemp[13]; // ZeroMemory(btTemp,sizeof(btTemp)); // // if(tagCardType.bStraightFlush) //有同花顺 // { // for(int i=0;ibtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // // } // else if(tagCardType1.bFourSame) //有铁支 // { // for(int j=0;j=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbThreeSame[0]])) // { // btTemp[0]=MidCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else if(tagCardType2.bTwoPare)//剩下两对 // { // MidCard[4]=btCardData2[tagCardType2.cbTwoPare[3]]; // FrontCard[0]=btCardData2[tagCardType2.cbTwoPare[0]]; // FrontCard[1]=btCardData2[tagCardType2.cbTwoPare[1]]; // FrontCard[2]=btCardData2[tagCardType2.cbTwoPare[2]]; // } // else if(tagCardType2.bOnePare)//剩下一对 // { // for(int k=3;k>=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbOnePare[0]])) // { // btTemp[0]=MidCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else //剩下散牌 // { // MidCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // else // { // if(tagCardType1.bGourd) //有葫芦 // { // bool bThreeSame=false; // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // bThreeSame=true; // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // if(bThreeSame==false) //前敦不能为三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // // } // else if(tagCardType1.bFlush) //有同花 // { // bool bThreeSame=false; // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // bThreeSame=true; // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // if(bThreeSame==false) //前敦不能为三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // if(tagCardType1.bStraight) //有顺子 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // } // // } // else if(tagCardType1.bStraight) //有顺子 // { // bool bThreeSame=false; // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // bThreeSame=true; // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // if(bThreeSame==false) //前敦不能为三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // } // } // else if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // else if(tagCardType1.bTwoPare) //有两对 // { // if(tagCardType1.btOnePare>=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbOnePare[0]])) // { // btTemp[0]=MidCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else //剩下散牌 // { // MidCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // // } // else if(tagCardType1.bOnePare) //有一对 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // else //散牌 // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // MidCard[0]=btCardData1[0]; // MidCard[1]=btCardData1[4]; // MidCard[2]=btCardData1[5]; // MidCard[3]=btCardData1[6]; // MidCard[4]=btCardData1[7]; // // FrontCard[0]=btCardData1[1]; // FrontCard[1]=btCardData1[2]; // FrontCard[2]=btCardData1[3]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // // } // } // else if(tagCardType.bFourSame) //铁支 // { // for(int i=0;i=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbTwoPare[0]]) // &&GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbTwoPare[2]])) // { // btTemp[0]=BackCard[4]=btCardData2[k]; // break; // } // } // //RemoveCard(btTemp,1,btCardData2,btCardCount2); // MidCard[4]=btCardData2[tagCardType2.cbTwoPare[3]]; // FrontCard[0]=btCardData2[tagCardType2.cbTwoPare[0]]; // FrontCard[1]=btCardData2[tagCardType2.cbTwoPare[1]]; // FrontCard[2]=btCardData2[tagCardType2.cbTwoPare[2]]; // } // else if(tagCardType2.bOnePare)//剩下一对 // { // btTemp[0]=FrontCard[0]=btCardData2[tagCardType2.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData2[tagCardType2.cbOnePare[1]]; // RemoveCard(btTemp,2,btCardData2,btCardCount2); // FrontCard[2]=btCardData2[0]; // BackCard[4]=btCardData2[2]; // MidCard[4]=btCardData2[1]; // } // else //剩下散牌 // { // BackCard[4]=btCardData2[4]; // MidCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // else // { // if(tagCardType1.bGourd) //有葫芦 // { // bool bThreeSame=false; // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // bThreeSame=true; // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // if(bThreeSame==false) //前敦不能为三条 // { // for(int j=0;j=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbOnePare[0]])) // { // btTemp[0]=BackCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else //剩下散牌 // { // // BackCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // // } // else if(tagCardType1.bFlush) //有同花 // { // bool bThreeSame=false; // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // bThreeSame=true; // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // if(bThreeSame==false) //前敦不能为三条 // { // for(int j=0;j=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbOnePare[0]])) // { // btTemp[0]=BackCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else //剩下散牌 // { // //这里有问题 zyy // BackCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // if(tagCardType1.bStraight) //有顺子 // { // for(int j=0;j=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbOnePare[0]])) // { // btTemp[0]=BackCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else //剩下散牌 // { // // BackCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // } // // } // else if(tagCardType1.bStraight) //有顺子 // { // bool bThreeSame=false; // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // bThreeSame=true; // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // if(bThreeSame==false) //前敦不能为三条 // { // for(int j=0;j=0;k--) // { // if(GetCardLogicValue(btCardData2[k])!=GetCardLogicValue(btCardData2[tagCardType2.cbOnePare[0]])) // { // btTemp[0]=BackCard[4]=btCardData2[k]; // break; // } // } // RemoveCard(btTemp,1,btCardData2,btCardCount2); // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // else //剩下散牌 // { // BackCard[4]=btCardData2[3]; // CopyMemory(FrontCard,btCardData2,sizeof(FrontCard)); // } // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // } // } // else if(tagCardType1.bThreeSame) //有三条 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // else if(tagCardType1.bTwoPare) //有两对 // { // if(tagCardType1.btOnePare>=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[4]=btCardData1[2]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // // } // else if(tagCardType1.bOnePare) //有一对 // { // for(int j=0;jbtFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // else //散牌 // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // BackCard[4]=btCardData1[8]; // MidCard[0]=btCardData1[0]; // MidCard[1]=btCardData1[4]; // MidCard[2]=btCardData1[5]; // MidCard[3]=btCardData1[6]; // MidCard[4]=btCardData1[7]; // // FrontCard[0]=btCardData1[1]; // FrontCard[1]=btCardData1[2]; // FrontCard[2]=btCardData1[3]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&&(btAllShuiShu>btFrontAllShuiShu // ||(CompareCard(FrontFrontCard,FrontCard,3,3,false)&&btAllShuiShu==btFrontAllShuiShu))) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // } // // } // } // // else if(tagCardType.bGourd) //有葫芦 // { // bool bThreeSame=false; // for(int i=0;i=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[3]=btCardData1[2]; // BackCard[4]=btCardData1[3]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[4]=btCardData1[2]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[3]=btCardData1[2]; // BackCard[4]=btCardData1[3]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[4]=btCardData1[2]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[3]=btCardData1[2]; // BackCard[4]=btCardData1[3]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;j=3) // { // btCardCount1=btCardCount; // CopyMemory(btCardData1,btCardData,sizeof(btCardData[0])*btCardCount1); // btTemp[0]=FrontCard[0]=btCardData1[tagCardType1.cbOnePare[0]]; // btTemp[1]=FrontCard[1]=btCardData1[tagCardType1.cbOnePare[1]]; // btTemp[2]=MidCard[0]=btCardData1[tagCardType1.cbOnePare[2]]; // btTemp[3]=MidCard[1]=btCardData1[tagCardType1.cbOnePare[3]]; // btTemp[4]=MidCard[2]=btCardData1[tagCardType1.cbOnePare[4]]; // btTemp[5]=MidCard[3]=btCardData1[tagCardType1.cbOnePare[5]]; // RemoveCard(btTemp,6,btCardData1,btCardCount1); // FrontCard[2]=btCardData1[0]; // MidCard[4]=btCardData1[1]; // BackCard[4]=btCardData1[2]; // if(bFirst) // { // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=ThreeDunAllShuiShu(FrontFrontCard,FrontMidCard,FrontBackCard); // bFirst=false; // } // } // else // { // btAllShuiShu=ThreeDunAllShuiShu(FrontCard,MidCard,BackCard); // if(CompareCard(FrontCard,MidCard,3,5,false)&&CompareCard(MidCard,BackCard,5,5,false)&& // IsBiggerThanFront(FrontFrontCard,FrontMidCard,FrontBackCard,FrontCard,MidCard,BackCard)) // { // CopyMemory(FrontFrontCard,FrontCard,sizeof(FrontCard)); // CopyMemory(FrontMidCard,MidCard,sizeof(MidCard)); // CopyMemory(FrontBackCard,BackCard,sizeof(BackCard)); // btFrontAllShuiShu=btAllShuiShu; // } // } // } // else // { // for(int j=0;jGetCardType(btFrontMidCard,5,btSpecialCard)) // { // btCompare++; // } // else if(GetCardType(btMidCard,5,btSpecialCard)GetCardType(btFrontBackCard,5,btSpecialCard)) // { // btCompare++; // } // else if(GetCardType(btBackCard,5,btSpecialCard)btFrontWin) // { // return true; // } // else if(btWin==btFrontWin) // { // if(btCompare>=1) // { // return true; // } // else // { // if(btCanWin>btFrontCanWin) // { // return true; // } // else // { // return false; // } // } // } // else // { // return false; // } // } // else if(btShuiShu==btFrontShuiShu+1) // { // if(btFrontWin-btWin>=4) // { // return false; // } // else // { // return true; // } // } // else if(btShuiShu+1==btFrontShuiShu) // { // if(btWin-btFrontWin>=4) // { // return true; // } // else // { // return false; // } // } // else if(btShuiShu>btFrontShuiShu) // { // return true; // } // else if(btShuiShu 3); //定义变量 BYTE bKCount = 0; CList evCardList[15]; //0位存王牌,1位保留,其他位按逻辑值存放 CList evColorList[4]; //方梅红黑 BYTE bCardArray[13] = {0}; memcpy(bCardArray, cbCardData, sizeof(BYTE)*cbCardCount); SortCardList(bCardArray, cbCardCount, enDescend); //分析扑克 for (int i = 0; i < cbCardCount; i++) { //保存王牌 if (bCardArray[i] == 0x41 || bCardArray[i] == 0x42) { evCardList[0].AddTail(bCardArray[i]); continue; } //保存其他 BYTE bLogicNum = GetCardLogicValue(bCardArray[i]); BYTE bColor = GetCardColor(bCardArray[i]); ASSERT(bLogicNum>1 && bLogicNum<15 && bColor>=0 && bColor<=3); ASSERT(evCardList[bLogicNum].Find(bCardArray[i]) == NULL); evCardList[bLogicNum].AddTail(bCardArray[i]); evColorList[bColor].AddTail(bCardArray[i]); } ASSERT(evCardList[0].GetCount() <= 2); //寻找同顺 if (bNeedCCount == 5) { for (int i = 0; i < 4; i++) { if (evColorList[i].GetCount()+evCardList[0].GetCount() >= 5) //同花+王牌数大于等于5 { BYTE bCount = 0; if (evCardList[0].GetCount() >= 0 && evColorList[i].GetCount() >= 5) //不带王 { if (GetCardValue(evColorList[i].GetHead()) == 1 && //A在后同花顺 GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-4))) != 5) { BYTE bFstCard = evColorList[i].GetAt(evColorList[i].FindIndex(0)); BYTE bLstCard = evColorList[i].GetAt(evColorList[i].FindIndex(4)); if (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 4) { for (int k = 0; k < 5; k++) bMaxCardData[k] = evColorList[i].GetAt(evColorList[i].FindIndex(k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_BACK_A; } } else if (GetCardValue(evColorList[i].GetHead()) == 1 && //检查A2345顺 GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-4))) == 5) { bMaxCardData[0] = evColorList[i].GetHead(); for (int k = 1; k < 5; k++) bMaxCardData[k] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_FIRST_A; } else { for (int j = 0; j < evColorList[i].GetCount()-4; j++) { BYTE bFstCard = evColorList[i].GetAt(evColorList[i].FindIndex(j)); BYTE bLstCard = evColorList[i].GetAt(evColorList[i].FindIndex(j+4)); if (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 4) { for (int k = 0; k < 5; k++) bMaxCardData[k] = evColorList[i].GetAt(evColorList[i].FindIndex(j+k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_NO_A; } } } } if (evCardList[0].GetCount() >= 1 && evColorList[i].GetCount() >= 4) //带单王 { if (GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(3))) >=10) { bMaxCardData[0] = evCardList[0].GetHead(); bMaxCardData[1] = evColorList[i].GetHead(); for (int k = 1; k < 4; k++) bMaxCardData[k+1] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_BACK_A; } else if (GetCardValue(evColorList[i].GetHead()) == 1 && //检查A2345顺 GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-3))) <= 5) { bMaxCardData[0] = evCardList[0].GetHead(); bMaxCardData[1] = evColorList[i].GetHead(); for (int k = 1; k < 4; k++) bMaxCardData[k+1] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_FIRST_A; } else if (GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-4))) <= 5) //检查A2345顺 { bMaxCardData[0] = evCardList[0].GetHead(); for (int k = 1; k < 5; k++) bMaxCardData[k] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_FIRST_A; } else { for (int j = 0; j < evColorList[i].GetCount()-3; j++) { BYTE bFstCard = evColorList[i].GetAt(evColorList[i].FindIndex(j)); BYTE bLstCard = evColorList[i].GetAt(evColorList[i].FindIndex(j+3)); if ( (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 3) || (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 4) ) { bMaxCardData[0] = evCardList[0].GetHead(); for (int k = 0; k < 4; k++) bMaxCardData[k+1] = evColorList[i].GetAt(evColorList[i].FindIndex(j+k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_NO_A; } } } } if (evCardList[0].GetCount() == 2 && evColorList[i].GetCount() >= 3) //带双王 { if (GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(2))) >=10) { bMaxCardData[0] = evCardList[0].GetHead(); bMaxCardData[1] = evCardList[0].GetTail(); for (int k = 1; k < 4; k++) bMaxCardData[k+1] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_BACK_A; } else if (GetCardValue(evColorList[i].GetHead()) == 1 && //检查A2345顺 GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-2))) <= 5) { bMaxCardData[0] = evCardList[0].GetHead(); bMaxCardData[1] = evCardList[0].GetTail(); bMaxCardData[2] = evColorList[i].GetHead(); for (int k = 1; k < 3; k++) bMaxCardData[k+2] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_FIRST_A; } else if (GetCardLogicValue(evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-3))) <= 5) //检查A2345顺 { bMaxCardData[0] = evCardList[0].GetHead(); bMaxCardData[1] = evCardList[0].GetTail(); for (int k = 1; k < 4; k++) bMaxCardData[k+2] = evColorList[i].GetAt(evColorList[i].FindIndex(evColorList[i].GetCount()-k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_FIRST_A; } else { for (int j = 0; j < evColorList[i].GetCount()-2; j++) { BYTE bFstCard = evColorList[i].GetAt(evColorList[i].FindIndex(j)); BYTE bLstCard = evColorList[i].GetAt(evColorList[i].FindIndex(j+2)); if ( (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 2) || (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 3) || (GetCardLogicValue(bFstCard) - GetCardLogicValue(bLstCard) == 4)) { bMaxCardData[0] = evCardList[0].GetHead(); bMaxCardData[1] = evCardList[0].GetTail(); for (int k = 0; k < 3; k++) bMaxCardData[k+2] = evColorList[i].GetAt(evColorList[i].FindIndex(j+k)); bMaxCardCount = 5; return CT_FIVE_STRAIGHT_FLUSH_NO_A; } } } } } } } //寻找五相 if (bNeedCCount == 5) { for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount()== 4 && evCardList[0].GetCount() > 0) { bMaxCardData[0] = evCardList[0].GetAt(evCardList[0].FindIndex(0)); for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[1+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardCount = 5; return CT_FIVE_BOMB; } } for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount()== 3 && evCardList[0].GetCount() == 2) { bMaxCardData[0] = 0x42; bMaxCardData[1] = 0x41; for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[2+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardCount = 5; return CT_FIVE_BOMB; } } } //寻找炸弹 if (bNeedCCount == 5) { for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount() + evCardList[0].GetCount() >= 4) { ASSERT(evCardList[i].GetCount()<=4&&evCardList[i].GetCount()>=2); int j = 0; for (; j < 4 - evCardList[i].GetCount(); j++) { bMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[j+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardCount = 4; return CT_FIVE_FOUR_ONE; } } } //寻找葫芦 if (bNeedCCount == 5) { for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount() + evCardList[0].GetCount() == 3) { ASSERT(evCardList[i].GetCount()<=3&&evCardList[i].GetCount()>=1); //寻找一对 BYTE bDoubleLogicCard = 0; for (int k = 2; k < 15; k++) { if (k == i) continue; if (evCardList[k].GetCount() >= 2) { bDoubleLogicCard = k; break; } } if (bDoubleLogicCard == 0) break; int j = 0; for (; j < 3 - evCardList[i].GetCount(); j++) { bMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[j+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardData[3] = evCardList[bDoubleLogicCard].GetAt(evCardList[bDoubleLogicCard].FindIndex(0)); bMaxCardData[4] = evCardList[bDoubleLogicCard].GetAt(evCardList[bDoubleLogicCard].FindIndex(1)); bMaxCardCount = 5; return CT_FIVE_THREE_DEOUBLE; } } } //寻找同花 if (bNeedCCount == 5) { BYTE bPossibleCard[4][5] = {0}; //各个能组成同花的牌组 CList maxCardColorList; for (int i = 0; i < 4; i++) { if (evColorList[i].GetCount() + evCardList[0].GetCount() >= 5) { if (evColorList[i].GetCount() >= 5) { for (int k = 0; k < 5; k++) { bPossibleCard[i][k] = evColorList[i].GetAt(evColorList[i].FindIndex(k)); } } else { int j = 0; for (; j < 5 - evColorList[i].GetCount(); j++) { bPossibleCard[i][j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evColorList[i].GetCount(); k++) { bPossibleCard[i][j + k] = evColorList[i].GetAt(evColorList[i].FindIndex(k)); } } maxCardColorList.AddTail(i); } } if (maxCardColorList.GetCount() != 0) { BYTE bMax = maxCardColorList.GetAt(maxCardColorList.FindIndex(0)); for (int i = 1; i < maxCardColorList.GetCount(); i++) { BYTE bColor = maxCardColorList.GetAt(maxCardColorList.FindIndex(i)); if (CompareCard(bPossibleCard[bMax], bPossibleCard[bColor], 5, 5, true)) { bMax = bColor; } } memcpy(bMaxCardData, bPossibleCard[bMax], sizeof(BYTE)*5); bMaxCardCount = 5; return CT_FIVE_FLUSH; } } //寻找顺子 if (bNeedCCount == 5) { for (int i = 14; i > 4; i--) { BYTE bHaveCard[5] = {0}; for (int k = 0; k < 4; k++) { bHaveCard[k] = (evCardList[i - k].GetCount()>0); } bHaveCard[4] = ( ((i == 5)?evCardList[14].GetCount():evCardList[i-4].GetCount()) > 0 ); BYTE bCount = (bHaveCard[0]?1:0) + (bHaveCard[1]?1:0) + (bHaveCard[2]?1:0) + (bHaveCard[3]?1:0) + (bHaveCard[4]?1:0); if (bCount + evCardList[0].GetCount() >= 5) { ASSERT(bCount>=3&&bCount<=5); int j = 0; for (; j < 5 - bCount; j++) { bMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < 4; k++) { if (bHaveCard[k]) { bMaxCardData[j++] = evCardList[i-k].GetHead(); } } BYTE bFirstCardNum = ( (i == 5)?14:i-4 ); if (bHaveCard[4]) { bMaxCardData[4] = evCardList[bFirstCardNum].GetHead(); } bMaxCardCount = 5; return ((i==14)?CT_FIVE_MIXED_FLUSH_BACK_A:( (i == 5)?CT_FIVE_MIXED_FLUSH_FIRST_A:CT_FIVE_MIXED_FLUSH_NO_A )); } } } //寻找三条 for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount() + evCardList[0].GetCount() == 3) { ASSERT(evCardList[i].GetCount()<=3&&evCardList[i].GetCount()>=1); int j = 0; for (; j < 3 - evCardList[i].GetCount(); j++) { bMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[j+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardCount = 3; return CT_THREE; } } //寻找两对 if (bNeedCCount == 5) { for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount() + evCardList[0].GetCount() == 2) { ASSERT(evCardList[i].GetCount()<=2&&evCardList[i].GetCount()>=0); //寻找一对 BYTE bDoubleLogicCard = 0; for (int k = 2; k < 15; k++) { if (k == i) continue; if (evCardList[k].GetCount() >= 2) { bDoubleLogicCard = k; break; } } if (bDoubleLogicCard == 0) break; int j = 0; for (; j < 2 - evCardList[i].GetCount(); j++) { bMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[j+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardData[2] = evCardList[bDoubleLogicCard].GetAt(evCardList[bDoubleLogicCard].FindIndex(0)); bMaxCardData[3] = evCardList[bDoubleLogicCard].GetAt(evCardList[bDoubleLogicCard].FindIndex(1)); bMaxCardCount = 4; return CT_FIVE_TWO_DOUBLE; } } } //寻找对子 for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount() + evCardList[0].GetCount() == 2) { ASSERT(evCardList[i].GetCount()<=2&&evCardList[i].GetCount()>=0); int j = 0; for (; j < 2 - evCardList[i].GetCount(); j++) { bMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evCardList[i].GetCount(); k++) bMaxCardData[j+k] = evCardList[i].GetAt(evCardList[i].FindIndex(k)); bMaxCardCount = 2; return CT_ONE_DOUBLE; } } //寻找散牌 for (int i = 14; i > 1; i--) { if (evCardList[i].GetCount() == 1) { bMaxCardCount = 1; bMaxCardData[0] = evCardList[i].GetHead(); return CT_SINGLE; } } //MyMsgBox(_T("CGameLogic::GetMaxCardData Error!")); return CT_INVALID; } bool CGameLogic::IsFlush(const BYTE cbCardData[], const BYTE cbCardCount, BYTE bMaxCardData[], BYTE & bMaxCardCount, BYTE bNeedCCount) { //校验数据 ASSERT(cbCardCount <= 13 || cbCardCount > 3); //定义变量 BYTE bKCount = 0; CList evCardList[15]; //0位存王牌,1位保留,其他位按逻辑值存放 CList evColorList[4]; //方梅红黑 BYTE bCardArray[13] = {0}; memcpy(bCardArray, cbCardData, sizeof(BYTE)*cbCardCount); SortCardList(bCardArray, cbCardCount, enDescend); //分析扑克 for (int i = 0; i < cbCardCount; i++) { //保存王牌 if (bCardArray[i] == 0x41 || bCardArray[i] == 0x42) { evCardList[0].AddTail(bCardArray[i]); continue; } //保存其他 BYTE bLogicNum = GetCardLogicValue(bCardArray[i]); BYTE bColor = GetCardColor(bCardArray[i]); ASSERT(bLogicNum>1 && bLogicNum<15 && bColor>=0 && bColor<=3); ASSERT(evCardList[bLogicNum].Find(bCardArray[i]) == NULL); evCardList[bLogicNum].AddTail(bCardArray[i]); evColorList[bColor].AddTail(bCardArray[i]); } ASSERT(evCardList[0].GetCount() <= 2); //寻找同花 BYTE bPossibleCard[4][5] = {0}; //各个能组成同花的牌组 CList maxCardColorList; for (int i = 0; i < 4; i++) { if (evColorList[i].GetCount() + evCardList[0].GetCount() >= bNeedCCount) { if (evColorList[i].GetCount() >= bNeedCCount) { for (int k = 0; k < bNeedCCount; k++) bPossibleCard[i][k] = evColorList[i].GetAt(evColorList[i].FindIndex(k)); } else { int j = 0; for (; j < bNeedCCount - evColorList[i].GetCount(); j++) { bPossibleCard[i][j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < evColorList[i].GetCount(); k++) bPossibleCard[i][j+k] = evColorList[i].GetAt(evColorList[i].FindIndex(k)); } maxCardColorList.AddTail(i); } } if (maxCardColorList.GetCount() != 0) { BYTE bMax = maxCardColorList.GetAt(maxCardColorList.FindIndex(0)); for (int i = 1; i < maxCardColorList.GetCount(); i++) { BYTE bColor = maxCardColorList.GetAt(maxCardColorList.FindIndex(i)); if (CompareCard(bPossibleCard[bMax], bPossibleCard[bColor], bNeedCCount, bNeedCCount, true)) bMax = bColor; } memcpy(bMaxCardData, bPossibleCard[bMax], sizeof(BYTE)*bNeedCCount); bMaxCardCount = bNeedCCount; return true; } return false; } //是否顺子 bool CGameLogic::IsStraight(const BYTE cbCardData[], const BYTE cbCardCount, BYTE cbMaxCardData[], BYTE & bMaxCardCount, BYTE bNeedCCount) { //校验数据 ASSERT(cbCardCount <= 13 || cbCardCount > 3); //定义变量 BYTE bKCount = 0; CList evCardList[15]; //0位存王牌,1位保留,其他位按逻辑值存放 CList evColorList[4]; //方梅红黑 BYTE bCardArray[13] = {0}; memcpy(bCardArray, cbCardData, sizeof(BYTE)*cbCardCount); SortCardList(bCardArray, cbCardCount, enDescend); //分析扑克 for (int i = 0; i < cbCardCount; i++) { //保存王牌 if (bCardArray[i] == 0x41 || bCardArray[i] == 0x42) { evCardList[0].AddTail(bCardArray[i]); continue; } //保存其他 BYTE bLogicNum = GetCardLogicValue(bCardArray[i]); BYTE bColor = GetCardColor(bCardArray[i]); ASSERT(bLogicNum>1 && bLogicNum<15 && bColor>=0 && bColor<=3); ASSERT(evCardList[bLogicNum].Find(bCardArray[i]) == NULL); evCardList[bLogicNum].AddTail(bCardArray[i]); evColorList[bColor].AddTail(bCardArray[i]); } ASSERT(evCardList[0].GetCount() <= 2); //寻找顺子 for (int i = 14; i > bNeedCCount-1; i--) { BYTE bHaveCard[5] = {0}; for (int k = 0; k < bNeedCCount-1; k++) bHaveCard[k] = (evCardList[i-k].GetCount()>0); bHaveCard[bNeedCCount-1] = ( ((i == bNeedCCount)?evCardList[14].GetCount():evCardList[i-bNeedCCount+1].GetCount()) > 0 ); BYTE bCount = 0; for (int m=0;m= bNeedCCount) { ASSERT(bCount>=bNeedCCount-2&&bCount<=bNeedCCount); int j = 0; for (; j < bNeedCCount - bCount; j++) { cbMaxCardData[j] = evCardList[0].GetAt(evCardList[0].FindIndex(j)); } for (int k = 0; k < bNeedCCount-1; k++) { if (bHaveCard[k]) cbMaxCardData[j++] = evCardList[i-k].GetHead(); } BYTE bFirstCardNum = ( (i == bNeedCCount)?14:i-bNeedCCount+1 ); if (bHaveCard[bNeedCCount-1]) cbMaxCardData[bNeedCCount-1] = evCardList[bFirstCardNum].GetHead(); bMaxCardCount = bNeedCCount; return true; } } return false; } //是否是三同花顺 bool CGameLogic::IsThreeFlushStraight(const BYTE cbCardData[], const BYTE cbCardCount) { //校验数据 ASSERT(cbCardCount <= 13 || cbCardCount>3); BYTE bCardList[13] = {0}; memcpy(bCardList,cbCardData,sizeof(BYTE)*cbCardCount); SortCardList(bCardList,cbCardCount); BYTE bLeftCount = cbCardCount; BYTE cbStraightFlush[5] = {0}; BYTE bTempCount = 5; tagAnalyseType tagCardType = GetType(bCardList,bLeftCount); if (tagCardType.bStraightFlush) { for (BYTE i = 0;i=CARD_XW && GetCardLogicValue(bCardList[1])