Files
wnmj/Classes/Games/13S/13S_GameLogic.cpp
2026-02-13 14:34:15 +08:00

4861 lines
133 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "13S_GameLogic.h"
//////////////////////////////////////////////////////////////////////////
//静态变量
const uint8 C13SGameLogic::m_bCardListData[SSS_CARD_COUNT] =
{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //方块 A - K
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //梅花 A - K
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //红桃 A - K
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //黑桃 A - K
0x41, 0x42,
};
//////////////////////////////////////////////////////////////////////////
//构造函数
C13SGameLogic::C13SGameLogic()
{
zeromemory(btCardSpecialData, sizeof(btCardSpecialData));
m_bClassicRule = true;
}
//析构函数
C13SGameLogic::~C13SGameLogic()
{
}
//获取类型
uint8 C13SGameLogic::GetCardType(uint8 bCardData[], uint8 bCardCount, uint8 btSpecialCard[])
{
//数据校验
ASSERT(bCardCount == 3 || bCardCount == 5 || 13 == bCardCount);
if (bCardCount != 3 && bCardCount != 5 && bCardCount != 13) return SSS_CT_INVALID;
tag13SAnalyseData AnalyseData;
memset(&AnalyseData, 0, sizeof(tag13SAnalyseData));
AnalyseCard(bCardData, bCardCount, AnalyseData);
//开始分析
switch (bCardCount)
{
case 3: //三条类型
{
//单牌类型
if (3 == AnalyseData.bOneCount) return SSS_CT_SINGLE;
//对带一张
if (1 == AnalyseData.bTwoCount && 1 == AnalyseData.bOneCount) return SSS_CT_ONE_DOUBLE;
//三张牌型
if (1 == AnalyseData.bThreeCount) return SSS_CT_THREE;
//错误类型
return SSS_CT_INVALID;
}
case 5: //五张牌型
{
bool bFlushNoA = false, bFlushFirstA = false, bFlushBackA = false;
if (GetCardLogicValue(bCardData[0]) >= SSS_CARD_XW && GetCardLogicValue(bCardData[1])<SSS_CARD_XW)
{
//A连在后
if ((GetCardLogicValue(bCardData[4]) == 10 || GetCardLogicValue(bCardData[4]) == 11) && GetCardLogicValue(bCardData[1]) == 14)
{
bFlushBackA = true;
for (uint8 i = 1; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if (1 != nValue && nValue != 2)
{
bFlushBackA = false;
break;
}
}
}
else if (14 == GetCardLogicValue(bCardData[1]) && 5 >= GetCardLogicValue(bCardData[2]))//A连在前
{
bFlushFirstA = true;
for (uint8 i = 2; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if (1 != nValue && nValue != 2)
{
bFlushFirstA = false;
break;
}
}
}
else if (5 >= GetCardLogicValue(bCardData[1])
&& (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW || GetCardLogicValue(bCardData[0]) == SSS_CARD_XW))//A连在前
{
bFlushFirstA = true;
for (uint8 i = 1; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if (1 != nValue && nValue != 2)
{
bFlushFirstA = false;
break;
}
}
}
else
{
bFlushNoA = true;
bool bRes = false;
for (uint8 i = 1; i<4; ++i)
{
uint8 A = GetCardLogicValue(bCardData[i]);
uint8 B = GetCardLogicValue(bCardData[i + 1]);
uint8 nValue = A - B;
if (nValue == 2)
{
if (!bRes) //第一次进入
{
bRes = true;
continue;
}
//第二次进入
bFlushNoA = false;
break;
}
if (1 != nValue)
{
bFlushNoA = false;
break;
}
}
}
}
else if (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW && GetCardLogicValue(bCardData[1]) == SSS_CARD_XW)
{
if (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW&& GetCardLogicValue(bCardData[1]) == SSS_CARD_XW)
{
bFlushBackA = true;
uint8 bIndex = 0;
for (uint8 i = 2; i<5; ++i)
{
if (GetCardLogicValue(bCardData[i]) >= 10)
bIndex++;
}
if (GetCardLogicValue(bCardData[2]) != 14)
{
for (uint8 i = 2; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if ((1 != nValue && nValue != 2)/*|| bIndex!=3*/)
{
bFlushBackA = false;
break;
}
}
}
else //16 15 14 12 10 16 15 14 11 10 16 15 14 13 10
{ //16 15 14 12 11 16 15 14 13 11
//16 15 14 13 12
if (GetCardLogicValue(bCardData[4]) == 10 && bIndex == 3)
{
if (!(GetCardLogicValue(bCardData[3]) == 12 || GetCardLogicValue(bCardData[3]) == 11 ||
GetCardLogicValue(bCardData[3]) == 13))
{
bFlushBackA = false;
}
}
else if (GetCardLogicValue(bCardData[4]) == 11 && bIndex == 3)
{
if (!(GetCardLogicValue(bCardData[3]) == 12 || GetCardLogicValue(bCardData[3]) == 13))
{
bFlushBackA = false;
}
}
else if (GetCardLogicValue(bCardData[4]) == 12 && bIndex == 3)
{
if (!(GetCardLogicValue(bCardData[3]) == 13))
{
bFlushBackA = false;
}
}
else if (5 >= GetCardLogicValue(bCardData[3]) && (GetCardLogicValue(bCardData[3]) != GetCardLogicValue(bCardData[4])))
{
bFlushFirstA = true;
for (uint8 i = 3; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if (1 != nValue && nValue != 2 && nValue != 3)
{
bFlushFirstA = false;
break;
}
}
}
else //zyy 3/18 2鬼带两张认成A在后顺子 修复
{
for (uint8 i = 2; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if ((1 != nValue && nValue != 2)/*|| bIndex!=3*/)
{
bFlushBackA = false;
break;
}
}
}
}
//zyy 3/9
bFlushNoA = true;
bool bRes1 = false;
bool bRes2 = false;
for (uint8 i = 2; i<4; ++i)
{
uint8 A = GetCardLogicValue(bCardData[i]);
uint8 B = GetCardLogicValue(bCardData[i + 1]);
uint8 nValue = A - B;
if (nValue == 3)
{
if (!bRes1 && !bRes2)
{
bRes1 = true;
bRes2 = true;
continue;
}
bFlushNoA = false;
break;
}
if (nValue == 2)
{
if (!bRes1)
{
bRes1 = true;
continue;
}
else if (!bRes2)
{
bRes2 = true;
continue;
}
bFlushNoA = false;
break;
}
if (1 != nValue && nValue != 2 && nValue != 3)
{
bFlushNoA = false;
break;
}
}
}
else if ((GetCardLogicValue(bCardData[4]) == 10 || GetCardLogicValue(bCardData[4]) == 11 || GetCardLogicValue(bCardData[4]) == 12) && GetCardLogicValue(bCardData[2] == 14))
{
bFlushBackA = true;
for (uint8 i = 2; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if (1 != nValue && nValue != 2 && nValue != 3)
{
bFlushBackA = false;
break;
}
}
}
}
else
{
//A连在后
if (14 == GetCardLogicValue(bCardData[0]) && 10 == GetCardLogicValue(bCardData[4])) bFlushBackA = true;
else bFlushNoA = true;
for (uint8 i = 0; i<4; ++i)
{
uint8 nValue = GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1]);
if (1 != nValue)
{
bFlushBackA = false;
bFlushNoA = false;
break;
}
}
//A连在前
if (false == bFlushBackA && false == bFlushNoA && 14 == GetCardLogicValue(bCardData[0]))
{
bFlushFirstA = true;
for (uint8 i = 1; i<4; ++i) if (1 != GetCardLogicValue(bCardData[i]) - GetCardLogicValue(bCardData[i + 1])) bFlushFirstA = false;
if (2 != GetCardLogicValue(bCardData[4])) bFlushFirstA = false;
}
}
//同花五牌
if (false == bFlushBackA && false == bFlushNoA && false == bFlushFirstA)
{
if (true == AnalyseData.bStraight) return SSS_CT_FIVE_FLUSH;
}
else if (true == bFlushNoA)
{
//杂顺类型
if (false == AnalyseData.bStraight) return SSS_CT_FIVE_MIXED_FLUSH_NO_A;
//同花顺牌
else return SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A;
}
else if (true == bFlushFirstA)
{
//杂顺类型
if (false == AnalyseData.bStraight) return SSS_CT_FIVE_MIXED_FLUSH_FIRST_A;
//同花顺牌
else return SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A;
}
else if (true == bFlushBackA)
{
//杂顺类型
if (false == AnalyseData.bStraight) return SSS_CT_FIVE_MIXED_FLUSH_BACK_A;
//同花顺牌
else return SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A;
}
//五带0张
if (1 == AnalyseData.bFiveCount) return SSS_CT_FIVE_BOMB;
//四带单张
if (1 == AnalyseData.bFourCount && 1 == AnalyseData.bOneCount) return SSS_CT_FIVE_FOUR_ONE;
//三条一对
if (1 == AnalyseData.bThreeCount && 1 == AnalyseData.bTwoCount) return SSS_CT_FIVE_THREE_DEOUBLE;
//三条带单
if (1 == AnalyseData.bThreeCount && 2 == AnalyseData.bOneCount) return SSS_CT_THREE;
//两对牌型
if (2 == AnalyseData.bTwoCount && 1 == AnalyseData.bOneCount) return SSS_CT_FIVE_TWO_DOUBLE;
//只有一对
if (1 == AnalyseData.bTwoCount && 3 == AnalyseData.bOneCount) return SSS_CT_ONE_DOUBLE;
//单牌类型
if (5 == AnalyseData.bOneCount && false == AnalyseData.bStraight) return SSS_CT_SINGLE;
//错误类型
return SSS_CT_INVALID;
}
case 13://13张特殊牌型
{
bool TwelveKing = false;
//同花十三水
if (13 == AnalyseData.bOneCount && true == AnalyseData.bStraight)
return SSS_CT_THIRTEEN_FLUSH;
//十三水
if (13 == AnalyseData.bOneCount)
return SSS_CT_THIRTEEN;
//十二皇族
TwelveKing = true;
for (int i = 0; i<13; i++)
{
if (GetCardLogicValue(bCardData[i])<11)
{
TwelveKing = false;
break;
}
}
if (TwelveKing)
{
return SSS_CT_TWELVE_KING;
}
//三同花顺
/*bool bThreeStraightFlush = false;
bThreeStraightFlush = IsThreeFlushStraight(bCardData,bCardCount);
if (bThreeStraightFlush)
{
return SSS_CT_THREE_STRAIGHTFLUSH;
}*/
//三同花顺子
{
uint8 bCardList[13] = { 0 };
memcpy(bCardList, bCardData, sizeof(uint8) * 13);
SortCardList(bCardList, 13);
uint8 bLeftCount = 13;
uint8 cbStraightFlush[5] = { 0 };
uint8 bTempCount = 5;
tag13SAnalyseType tagCardType = GetType(bCardList, bLeftCount);
if (tagCardType.bStraightFlush)
{
for (uint8 i = 0; i<tagCardType.btStraightFlush; ++i)
{
CopyMemory(bCardList, bCardData, sizeof(bCardList));
bLeftCount = 13;
SortCardList(bCardList, 13);
zeromemory(cbStraightFlush, sizeof(cbStraightFlush));
cbStraightFlush[0] = bCardList[tagCardType.cbStraightFlush[i * 5]];
cbStraightFlush[1] = bCardList[tagCardType.cbStraightFlush[i * 5 + 1]];
cbStraightFlush[2] = bCardList[tagCardType.cbStraightFlush[i * 5 + 2]];
cbStraightFlush[3] = bCardList[tagCardType.cbStraightFlush[i * 5 + 3]];
cbStraightFlush[4] = bCardList[tagCardType.cbStraightFlush[i * 5 + 4]];
//移除第一个同花顺
RemoveCard(cbStraightFlush, bTempCount, bCardList, bLeftCount);
bLeftCount -= bTempCount;
//备份剩余牌
uint8 bLeftCardList[13] = { 0 };
CopyMemory(bLeftCardList, bCardList, bLeftCount);
uint8 bLeftCount1 = bLeftCount;
tag13SAnalyseType tagCardType1 = GetType(bCardList, bLeftCount);
if (tagCardType1.bStraightFlush)
{
for (uint8 j = 0; j<tagCardType1.btStraightFlush; ++j)
{
//重新赋值
CopyMemory(bCardList, bLeftCardList, bLeftCount1);
zeromemory(cbStraightFlush, sizeof(cbStraightFlush));
bLeftCount = bLeftCount1;
cbStraightFlush[0] = bCardList[tagCardType1.cbStraightFlush[j * 5]];
cbStraightFlush[1] = bCardList[tagCardType1.cbStraightFlush[j * 5 + 1]];
cbStraightFlush[2] = bCardList[tagCardType1.cbStraightFlush[j * 5 + 2]];
cbStraightFlush[3] = bCardList[tagCardType1.cbStraightFlush[j * 5 + 3]];
cbStraightFlush[4] = bCardList[tagCardType1.cbStraightFlush[j * 5 + 4]];
//移除第二个同花顺
RemoveCard(cbStraightFlush, bTempCount, bCardList, bLeftCount);
bLeftCount -= bTempCount;
//判断剩余3张是否也符合同花顺
bool bThreeStraightFlush = false;
SortCardList(bCardList, bLeftCount, enDescend);
if (GetCardLogicValue(bCardList[0]) >= SSS_CARD_XW && GetCardLogicValue(bCardList[1]) <SSS_CARD_XW)
{
if ((GetCardColor(bCardList[1]) == GetCardColor(bCardList[2])) &&
(GetCardLogicValue(bCardList[1]) - GetCardLogicValue(bCardList[2]) == 1
|| GetCardLogicValue(bCardList[1]) - GetCardLogicValue(bCardList[2]) == 2
|| (GetCardLogicValue(bCardList[1]) == 14 && GetCardLogicValue(bCardList[2]) <= 3))
)
{
bThreeStraightFlush = true;
}
}
else if (GetCardLogicValue(bCardList[0]) == SSS_CARD_DW && GetCardLogicValue(bCardList[1]) == SSS_CARD_XW)
{
bThreeStraightFlush = true;
}
else
{
if ((GetCardColor(bCardList[0]) == GetCardColor(bCardList[1]) && GetCardColor(bCardList[0]) == GetCardColor(bCardList[2])) &&
((GetCardLogicValue(bCardList[0]) == GetCardLogicValue(bCardList[1]) + 1 && GetCardLogicValue(bCardList[1]) == GetCardLogicValue(bCardList[2]) + 1)
|| (GetCardLogicValue(bCardList[0]) == 14 && GetCardLogicValue(bCardList[1]) == 3 && GetCardLogicValue(bCardList[2]) == 2)))
{
bThreeStraightFlush = true;
}
}
if (bThreeStraightFlush)
{
return SSS_CT_THREE_STRAIGHTFLUSH;
}
}
}
}
}
}
//三炸弹
if (3 == AnalyseData.bFourCount)
{
return SSS_CT_THREE_BOMB;
}
//全大
bool AllBig = true;
for (int i = 0; i<13; i++)
{
if (GetCardLogicValue(bCardData[i])<8 && GetCardLogicValue(bCardData[i]) != SSS_CARD_XW&&GetCardLogicValue(bCardData[i]) != SSS_CARD_DW)
{
AllBig = false;
break;
}
}
if (AllBig)
{
return SSS_CT_ALL_BIG;
}
//全小
bool AllSmall = true;
for (int i = 0; i<13; i++)
{
if (GetCardLogicValue(bCardData[i])>8 && GetCardLogicValue(bCardData[i]) != SSS_CARD_XW&&GetCardLogicValue(bCardData[i]) != SSS_CARD_DW)
{
AllSmall = false;
break;
}
}
if (AllSmall)
{
return SSS_CT_ALL_SMALL;
}
//凑一色
{
uint8 Flush = 1;
uint8 bStartIndex = 0;
uint8 SColor = 0;
uint8 bSameColorList[13] = { 0 };
memcpy(bSameColorList, bCardData, sizeof(uint8) * 13);
SortCardList(bSameColorList, 13);
if (GetCardLogicValue(bSameColorList[0]) >= SSS_CARD_XW && GetCardLogicValue(bSameColorList[1])<SSS_CARD_XW)
{
bStartIndex = 1;
}
else if (GetCardLogicValue(bSameColorList[0]) >= SSS_CARD_XW && GetCardLogicValue(bSameColorList[1]) >= SSS_CARD_XW)
{
bStartIndex = 2;
}
{
SColor = GetCardColor(bSameColorList[bStartIndex]);
for (int i = bStartIndex + 1; i<13; i++)
{
if (SColor == (GetCardColor(bSameColorList[i])) || SColor == ((GetCardColor(bSameColorList[i]) + 2) % 4))
{
Flush++;
}
else
{
break;
}
}
}
if (13 - bStartIndex == Flush)
{
return SSS_CT_SAME_COLOR;
}
}
//四套冲三
if (4 == AnalyseData.bThreeCount || (3 == AnalyseData.bThreeCount && 1 == AnalyseData.bFourCount)
|| (2 == AnalyseData.bThreeCount && 1 == AnalyseData.bFourCount && (AnalyseData.bTwoCount >= 1) && (GetCardLogicValue(bCardData[0]) == SSS_CARD_XW || GetCardLogicValue(bCardData[0]) == SSS_CARD_DW)))
{
return SSS_CT_FOUR_THREESAME;
}
//五对冲三
if ((5 == AnalyseData.bTwoCount && 1 == AnalyseData.bThreeCount) || (3 == AnalyseData.bTwoCount && 1 == AnalyseData.bFourCount && 1 == AnalyseData.bThreeCount)
|| (1 == AnalyseData.bTwoCount && 2 == AnalyseData.bFourCount && 1 == AnalyseData.bThreeCount))
{
return SSS_CT_FIVEPAIR_THREE;
}
//六对半
if (6 == AnalyseData.bTwoCount || (4 == AnalyseData.bTwoCount && 1 == AnalyseData.bFourCount) || (2 == AnalyseData.bTwoCount && 2 == AnalyseData.bFourCount)
|| (3 == AnalyseData.bFourCount))
{
return SSS_CT_SIXPAIR;
}
//三同花
{
//定义变量
uint8 bCardList[13] = { 0 };
memcpy(bCardList, bCardData, sizeof(uint8) * 13);
uint8 bLeftCCount = 13;
uint8 bTempCard[3][5] = { 0 };
uint8 bTempCCount[3] = { 0 };
bool Flush = true;
//摆牌开始
for (int i = 0; i < 3; i++)
{
if (!IsFlush(bCardList, bLeftCCount, bTempCard[i], bTempCCount[i], (i == 2 ? 3 : 5)))
{
Flush = false;
break;
}
RemoveCard(bTempCard[i], bTempCCount[i], bCardList, bLeftCCount);
bLeftCCount -= bTempCCount[i];
if (i<2) CopyMemory(&btSpecialCard[i * 5], bTempCard[i], bTempCCount[i]);
else CopyMemory(&btSpecialCard[10], bTempCard[i], bTempCCount[i]);
}
if (Flush)
{
return SSS_CT_THREE_FLUSH;
}
}
//三顺子
{
uint8 bCardList[13] = { 0 };
memcpy(bCardList, bCardData, sizeof(uint8) * 13);
SortCardList(bCardList, 13);
uint8 bLeftCount = 13;
uint8 cbStraight[5] = { 0 };
uint8 bTempCount = 5;
bool Straight = true;
tag13SAnalyseType tagCardType = GetType(bCardList, bLeftCount);
if (tagCardType.bStraight)
{
int xxx = 0;
for (uint8 i = 0; i<20; i++)
{
if (tagCardType.cbStraight[i * 5] == 0 && tagCardType.cbStraight[i * 5 + 1] == 0)
{
xxx = i;
break;
}
}
if (xxx>tagCardType.btStraight)
{
tagCardType.btStraight = xxx;
}
zeromemory(btSpecialCard, sizeof(uint8) * 13);
for (uint8 i = 0; i<tagCardType.btStraight; ++i) //zyy 特殊牌少了1次
{
CopyMemory(bCardList, bCardData, sizeof(bCardList));
bLeftCount = 13;
SortCardList(bCardList, 13);
zeromemory(cbStraight, sizeof(cbStraight));
cbStraight[0] = bCardList[tagCardType.cbStraight[i * 5]];
cbStraight[1] = bCardList[tagCardType.cbStraight[i * 5 + 1]];
cbStraight[2] = bCardList[tagCardType.cbStraight[i * 5 + 2]];
cbStraight[3] = bCardList[tagCardType.cbStraight[i * 5 + 3]];
cbStraight[4] = bCardList[tagCardType.cbStraight[i * 5 + 4]];
//移除第一个顺子
RemoveCard(cbStraight, bTempCount, bCardList, bLeftCount);
bLeftCount -= bTempCount;
CopyMemory(btSpecialCard, cbStraight, bTempCount);
//备份剩余牌
uint8 bLeftCardList[13] = { 0 };
CopyMemory(bLeftCardList, bCardList, bLeftCount);
uint8 bLeftCount1 = bLeftCount;
tag13SAnalyseType tagCardType1 = GetType(bCardList, bLeftCount);
if (tagCardType1.bStraight)
{
for (uint8 j = 0; j<tagCardType1.btStraight; ++j)
{
//重新赋值
CopyMemory(bCardList, bLeftCardList, bLeftCount1);
zeromemory(cbStraight, sizeof(cbStraight));
bLeftCount = bLeftCount1;
cbStraight[0] = bCardList[tagCardType1.cbStraight[j * 5]];
cbStraight[1] = bCardList[tagCardType1.cbStraight[j * 5 + 1]];
cbStraight[2] = bCardList[tagCardType1.cbStraight[j * 5 + 2]];
cbStraight[3] = bCardList[tagCardType1.cbStraight[j * 5 + 3]];
cbStraight[4] = bCardList[tagCardType1.cbStraight[j * 5 + 4]];
//移除第二个顺子
RemoveCard(cbStraight, bTempCount, bCardList, bLeftCount);
bLeftCount -= bTempCount;
CopyMemory(btSpecialCard + 5, cbStraight, bTempCount);
//判断剩余3张是否也符合顺子
bool bThreeStraight = false;
SortCardList(bCardList, bLeftCount, enDescend);
if (GetCardLogicValue(bCardList[0]) >= SSS_CARD_XW && GetCardLogicValue(bCardList[1]) <SSS_CARD_XW)
{
if (GetCardLogicValue(bCardList[1]) - GetCardLogicValue(bCardList[2]) == 1
|| GetCardLogicValue(bCardList[1]) - GetCardLogicValue(bCardList[2]) == 2
|| (GetCardLogicValue(bCardList[1]) == 14 && GetCardLogicValue(bCardList[2]) <= 3)
)
{
bThreeStraight = true;
}
}
else if (GetCardLogicValue(bCardList[0]) == SSS_CARD_DW && GetCardLogicValue(bCardList[1]) == SSS_CARD_XW)
{
bThreeStraight = true;
}
else
{
if ((GetCardLogicValue(bCardList[0]) == GetCardLogicValue(bCardList[1]) + 1 && GetCardLogicValue(bCardList[1]) == GetCardLogicValue(bCardList[2]) + 1)
|| (GetCardLogicValue(bCardList[0]) == 14 && GetCardLogicValue(bCardList[1]) == 3 && GetCardLogicValue(bCardList[2]) == 2))
{
bThreeStraight = true;
}
}
if (bThreeStraight)
{
CopyMemory(btSpecialCard + 10, bCardList, bLeftCount);
return SSS_CT_THREE_STRAIGHT;
}
}
}
}
}
}
}
}
return SSS_CT_INVALID;
}
//排列扑克;
void C13SGameLogic::SortCardList(uint8 bCardData[], uint8 bCardCount, en13SSortCardType SortCardType)
{
ASSERT(bCardCount >= 1 && bCardCount <= 13);
if (bCardCount<1 || bCardCount>13) return;
//转换数值;
uint8 bLogicVolue[13] = {0};
for (uint8 i = 0; i < bCardCount; i++)
{
bLogicVolue[i] = GetCardLogicValue(bCardData[i]);
}
if (enDescend == SortCardType)
{
//排序操作;
bool bSorted = true;
uint8 bTempData;
uint8 bLast = bCardCount - 1;
uint8 m_bCardCount = 1;
do
{
bSorted = true;
for (uint8 i = 0; i<bLast; i++)
{
if ((bLogicVolue[i]<bLogicVolue[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 (enAscend == SortCardType)
{
//排序操作;
bool bSorted = true;
uint8 bTempData;
uint8 bLast = bCardCount - 1;
uint8 m_bCardCount = 1;
do
{
bSorted = true;
for (uint8 i = 0; i<bLast; i++)
{
if ((bLogicVolue[i]>bLogicVolue[i + 1]) ||
((bLogicVolue[i] == bLogicVolue[i + 1]) && (bCardData[i]>bCardData[i + 1])))
{
//交换位置;
bTempData = bCardData[i];
bCardData[i] = bCardData[i + 1];
bCardData[i + 1] = bTempData;
bTempData = bLogicVolue[i];
bLogicVolue[i] = bLogicVolue[i + 1];
bLogicVolue[i + 1] = bTempData;
bSorted = false;
}
}
bLast--;
} while (bSorted == false);
}
else if (enColor == SortCardType)
{
//排序操作;
bool bSorted = true;
uint8 bTempData, bLast = bCardCount - 1;
uint8 m_bCardCount = 1;
uint8 bColor[13] = {0};
for (uint8 i = 0; i < bCardCount; i++)
{
bColor[i] = GetCardColor(bCardData[i]);
}
do
{
bSorted = true;
for (uint8 i = 0; i<bLast; i++)
{
if ((bColor[i]<bColor[i + 1]) ||
((bColor[i] == bColor[i + 1]) && (GetCardLogicValue(bCardData[i])<GetCardLogicValue(bCardData[i + 1]))))
{
//交换位置;
bTempData = bCardData[i];
bCardData[i] = bCardData[i + 1];
bCardData[i + 1] = bTempData;
bTempData = bColor[i];
bColor[i] = bColor[i + 1];
bColor[i + 1] = bTempData;
bSorted = false;
}
}
bLast--;
} while (bSorted == false);
}
return;
}
//混乱扑克
void C13SGameLogic::RandCardList(uint8 bCardBuffer[], uint8 bBufferCount)
{
//混乱准备
uint8 bCardData[sizeof(m_bCardListData)];
CopyMemory(bCardData, m_bCardListData, sizeof(m_bCardListData));
//CopyMemory(bCardBuffer,m_bCardListData,sizeof(m_bCardListData));
//混乱扑克
uint8 bRandCount = 0, bPosition = 0;
do
{
bPosition = rand() % (bBufferCount - bRandCount);
bCardBuffer[bRandCount++] = bCardData[bPosition];
bCardData[bPosition] = bCardData[bBufferCount - bRandCount];
} while (bRandCount<bBufferCount);
return;
}
//删除扑克;
bool C13SGameLogic::RemoveCard(const uint8 bRemoveCard[], uint8 bRemoveCount, uint8 bCardData[], uint8 bCardCount)
{
//检验数据;
ASSERT(bRemoveCount <= bCardCount);
//定义变量;
uint8 bDeleteCount = 0;
uint8 bTempCardData[13] = { 0 };
if (bCardCount > (sizeof(bTempCardData) / sizeof(bTempCardData[0])))
{
return false;
}
CopyMemory(bTempCardData, bCardData, bCardCount*sizeof(bCardData[0]));
//置零扑克;
for (uint8 i = 0; i<bRemoveCount; i++)
{
for (uint8 j = 0; j<bCardCount; j++)
{
if (bRemoveCard[i] == bTempCardData[j])
{
bDeleteCount++;
bTempCardData[j] = 0;
break;
}
}
}
if (bDeleteCount != bRemoveCount)
{
return false;
}
//清理扑克;
uint8 bCardPos = 0;
for (uint8 i = 0; i<bCardCount; i++)
{
if (bTempCardData[i] != 0)
{
bCardData[bCardPos++] = bTempCardData[i];
}
}
return true;
}
//逻辑数值;
uint8 C13SGameLogic::GetCardLogicValue(uint8 bCardData)
{
//扑克属性;
uint8 bCardValue = GetCardValue(bCardData);
uint8 bCardColor = GetCardColor(bCardData);
if (bCardColor == 0x04)
{
return bCardValue + 14;
}
//转换数值;
return (bCardValue == 1) ? (bCardValue + 13) : bCardValue;
}
/*
返回值:;
* bNextList>bFirstList:true
bNextList<bFirstList:false
*/
//对比扑克;
uint8 C13SGameLogic::CompareCard(uint8 bInFirstList[], uint8 bInNextList[], uint8 bFirstCount, uint8 bNextCount, bool bComperWithOther)
{
tag13SAnalyseData FirstAnalyseData, NextAnalyseData;
memset(&FirstAnalyseData, 0, sizeof(tag13SAnalyseData));
memset(&NextAnalyseData, 0, sizeof(tag13SAnalyseData));
//排列扑克;
uint8 bFirstList[13] = { 0 };
uint8 bNextList[13] = { 0 };
CopyMemory(bFirstList, bInFirstList, bFirstCount);
CopyMemory(bNextList, bInNextList, bNextCount);
SortCardList(bFirstList, bFirstCount, enDescend);
SortCardList(bNextList, bNextCount, enDescend);
//ASSERT(3 == bFirstCount || 5 == bFirstCount || 3 == bNextCount || 5 == bNextCount || 13 == bFirstCount || 13 == bNextCount);
AnalyseCard(bFirstList, bFirstCount, FirstAnalyseData);
AnalyseCard(bNextList, bNextCount, NextAnalyseData);
uint8 cbTempFirstCount = (FirstAnalyseData.bOneCount + FirstAnalyseData.bTwoCount * 2 + FirstAnalyseData.bThreeCount * 3 + FirstAnalyseData.bFourCount * 4 + FirstAnalyseData.bFiveCount * 5);
//ASSERT(bFirstCount == cbTempFirstCount);
if (bFirstCount != cbTempFirstCount)
{
return 0;
}
uint8 cbTempNextCount = (NextAnalyseData.bOneCount + NextAnalyseData.bTwoCount * 2 + NextAnalyseData.bThreeCount * 3 + NextAnalyseData.bFourCount * 4 + NextAnalyseData.bFiveCount * 5);
//ASSERT(bNextCount = cbTempNextCount);
if (bNextCount != cbTempNextCount)
{
return 0;
}
//数据验证;
//ASSERT((bFirstCount == bNextCount) || (bFirstCount != bNextCount && (3 == bFirstCount && 5 == bNextCount || 5 == bFirstCount && 3 == bNextCount)));
if (!((bFirstCount == bNextCount) || (bFirstCount != bNextCount && (3 == bFirstCount && 5 == bNextCount || 5 == bFirstCount && 3 == bNextCount)))) return 0;
//获取类型;
////ASSERT(3==bNextCount || 5==bNextCount) ;
////ASSERT(3==bFirstCount || 5==bFirstCount) ;
uint8 bNextType = GetCardType(bNextList, bNextCount, btCardSpecialData);
uint8 bFirstType = GetCardType(bFirstList, bFirstCount, btCardSpecialData);
//ASSERT(SSS_CT_INVALID != bNextType && SSS_CT_INVALID != bFirstType);
if (SSS_CT_INVALID == bFirstType || SSS_CT_INVALID == bNextType) return 0;
//头段比较;
if (true == bComperWithOther)
{
if (3 == bFirstCount)
{
//开始对比;
if (bNextType == bFirstType)
{
switch (bFirstType)
{
case SSS_CT_SINGLE: //单牌类型;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
for (uint8 i = 0; i < 3; ++i)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//表示不比水;
return 2;
}
case SSS_CT_ONE_DOUBLE: //对带一张;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
cbNextLogicValue = GetCardLogicValue(bNextList[NextAnalyseData.bOneFirst[0]]);
cbFirstLogicValue = GetCardLogicValue(bFirstList[FirstAnalyseData.bOneFirst[0]]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
else
{
return 2;
}
}
else
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
case SSS_CT_THREE: //三张牌型;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
return 2;
}
else
{
return cbNextLogicValue > cbFirstLogicValue; //比较数值;
}
}
}
}
else
{
return bNextType>bFirstType;
}
}
else if (5 == bFirstCount)
{
//开始对比;
if (bNextType == bFirstType)
{
switch (bFirstType)
{
case SSS_CT_SINGLE: //单牌类型;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
for (uint8 i = 0; i < 5; ++i)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_ONE_DOUBLE: //对带一张;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
//对比单张;
for (uint8 i = 0; i<3; ++i)
{
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[i]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[i]];
if (GetCardLogicValue(cbNextCardValue) != GetCardLogicValue(cbFirstCardValue))
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
return 2;
}
else
{
return cbNextLogicValue > cbFirstLogicValue; //比较数值;
}
}
case SSS_CT_FIVE_TWO_DOUBLE: //两对牌型;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[1]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[1]];
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]];
if (GetCardLogicValue(cbNextCardValue) != GetCardLogicValue(cbFirstCardValue))
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
return 2;
}
else
{
//比较数值;
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
else
{
return cbNextLogicValue > cbFirstLogicValue; //比较数值;
}
}
case SSS_CT_THREE: //三张牌型;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); //比较数值
}
}
case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A: //A在前顺子;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
return 2; // 12345 怎么比 都是一样大;
//如果顺子有王 就比第二张;
if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW
|| GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW)
{
if (GetCardLogicValue(bNextList[2]) == GetCardLogicValue(bFirstList[2]))
return 2;
else
return GetCardLogicValue(bNextList[2]) > GetCardLogicValue(bFirstList[2]); //比较数值
}
if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
return 2;
else
return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); //比较数值
}
case SSS_CT_FIVE_MIXED_FLUSH_NO_A: //没A杂顺
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
//如果顺子有王 就比第二张;
if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW
|| GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW)
{
if (GetCardLogicValue(bNextList[4]) == GetCardLogicValue(bFirstList[4]))
return 2;
else
return GetCardLogicValue(bNextList[4]) > GetCardLogicValue(bFirstList[4]); //比较数值;
}
if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
return 2;
else
return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); //比较数值;
}
case SSS_CT_FIVE_MIXED_FLUSH_BACK_A: //A在后顺子;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
return 2; // 10 J Q K 1 怎么比 都是一样大;
//如果顺子有王 就比第二张;
if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW
|| GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW)
{
if (GetCardLogicValue(bNextList[2]) == GetCardLogicValue(bFirstList[2]))
return 2;
else
return GetCardLogicValue(bNextList[2]) > GetCardLogicValue(bFirstList[2]); //比较数值;
}
if (GetCardLogicValue(bNextList[0]) == GetCardLogicValue(bFirstList[0]))
return 2;
else
return GetCardLogicValue(bNextList[0]) > GetCardLogicValue(bFirstList[0]); //比较数值;
}
case SSS_CT_FIVE_FLUSH: //同花五牌;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
//比较数值;
for (uint8 i = 0; i<5; ++i)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//比较花色;
return 2;
}
case SSS_CT_FIVE_THREE_DEOUBLE: //三条一对;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
//比较数值;
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
case SSS_CT_FIVE_FOUR_ONE: //四带一张;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
//如果顺子有王 就比第三张;
if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW
|| GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW)
{
if (GetCardLogicValue(bNextList[3]) == GetCardLogicValue(bFirstList[3]))
{
return 2;
}
else
{
return GetCardLogicValue(bNextList[3]) > GetCardLogicValue(bFirstList[3]); //比较数值;
}
}
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue); //比较数值;
}
}
case SSS_CT_FIVE_BOMB: //五相 //zyy五同需要比较第二张;
{
uint8 cbNextCardValue = bNextList[NextAnalyseData.bFiveFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFiveFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
if (GetCardLogicValue(bNextList[1]) == GetCardLogicValue(bFirstList[1]))
{
return 2;
}
else
{
//比较数值;
return GetCardLogicValue(bNextList[1]) > GetCardLogicValue(bFirstList[1]);
}
}
case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A: //没A同花顺
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
//zyy 如果顺子有王 就比第二张;
if (GetCardLogicValue(bNextList[0]) == SSS_CARD_DW || GetCardLogicValue(bNextList[0]) == SSS_CARD_XW
|| GetCardLogicValue(bFirstList[0]) == SSS_CARD_DW || GetCardLogicValue(bFirstList[0]) == SSS_CARD_XW)
{
//比较数值;
//for(uint8 i=2; i<5; ++i)
//if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
/// zyy 3/6 2017;
if (GetCardLogicValue(bNextList[4]) != GetCardLogicValue(bFirstList[4]))
{
return GetCardLogicValue(bNextList[4]) > GetCardLogicValue(bFirstList[4]);
}
else
{
return 2;
}
}
//比较数值;
for (uint8 i = 0; i<5; ++i)
{
if (GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
{
return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]);
}
}
//比较花色;
return 2;
}
case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A://A在前同花顺;
case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A: //A在后同花顺;
{
//数据验证;
//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
return 2; // 10 J Q K 1 怎么比 都是一样大;
}
default:
return false;
}
}
else
{
//同花顺牌;
//if( bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A || bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH)
//{
// if(SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType || SSS_CT_FIVE_STRAIGHT_FLUSH==bFirstType)
// {
// if(bNextType!=bFirstType)
// return bNextType > bFirstType ;
//
// //比较数值;
// for(uint8 i=0; i<5; ++i)
// if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
// return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]) ;
//
// //比较花色;
// return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]) ;
// }
//}
return bNextType>bFirstType;
}
}
else
{
if (bNextType == bFirstType)
{
switch (bFirstType)
{
case SSS_CT_THIRTEEN_FLUSH:
{
return 2;
}
case SSS_CT_TWELVE_KING:
{
for (int i = 0; i < 13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_THREE_STRAIGHTFLUSH:
{
for (int i = 0; i < 13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_THREE_BOMB:
{
uint8 cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
for (int i = 0; i < 3; i++)
{
cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[i]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[i]];
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]];
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
case SSS_CT_ALL_BIG:
{
for (int i = 0; i < 13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_ALL_SMALL:
{
for (int i = 0; i<13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_SAME_COLOR:
{
for (int i = 0; i<13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_FOUR_THREESAME:
{
uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
for (int i = 0; i < 4; i++)
{
cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[i]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[i]];
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]];
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
case SSS_CT_FIVEPAIR_THREE:
{
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
for (int i = 0; i < 5; i++)
{
cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[i]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[i]];
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
case SSS_CT_SIXPAIR:
{
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
for (int i = 0; i < 6; i++)
{
cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[i]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[i]];
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]];
if (GetCardLogicValue(cbNextCardValue) == GetCardLogicValue(cbFirstCardValue))
{
return 2;
}
else
{
return GetCardLogicValue(cbNextCardValue) > GetCardLogicValue(cbFirstCardValue);
}
}
case SSS_CT_THREE_FLUSH:
{
for (int i = 0; i<13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
case SSS_CT_THREE_STRAIGHT:
{
for (int i = 0; i<13; i++)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
return 2;
}
}
}
else
{
return bNextType>bFirstType;
}
}
}
else
{
//开始对比;
if (bNextType == bFirstType)
{
switch (bFirstType)
{
case SSS_CT_SINGLE: //单牌类型;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
for (uint8 i = 0; i<bFirstCount; ++i)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//比较花色;
return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
}
case SSS_CT_ONE_DOUBLE: //对带一张;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]];
cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
//比较花色;
return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
return bNextCount < bFirstCount;
}
case SSS_CT_FIVE_TWO_DOUBLE: //两对牌型;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
cbNextCardValue = bNextList[NextAnalyseData.bTwoFirst[1]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bTwoFirst[1]];
cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
//对比单牌;
cbNextCardValue = bNextList[NextAnalyseData.bOneFirst[0]];
cbFirstCardValue = bFirstList[FirstAnalyseData.bOneFirst[0]];
cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
//比较花色;
return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
//return bNextCount < bFirstCount ;
}
case SSS_CT_THREE: //三张牌型;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A: //A在前顺子;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]);
//zyy 如果顺子有王 就比第二张;
if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW)
{
cbNextLogicValue = GetCardLogicValue(bNextList[2]);
cbFirstLogicValue = GetCardLogicValue(bFirstList[2]);
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(bNextList[2]) > GetCardColor(bFirstList[2]);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色 A5432 比较 5的花色;
return GetCardColor(bNextList[1]) > GetCardColor(bFirstList[1]);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
case SSS_CT_FIVE_MIXED_FLUSH_NO_A: //没A杂顺
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]);
//zyy 如果顺子有王 就比第二张;
if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW)
{
cbNextLogicValue = GetCardLogicValue(bNextList[2]);
cbFirstLogicValue = GetCardLogicValue(bFirstList[2]);
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(bNextList[2]) > GetCardColor(bFirstList[2]);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
if (cbNextLogicValue == cbFirstLogicValue)
{
return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]); //比较花色
}
else
{
return cbNextLogicValue > cbFirstLogicValue; //比较数值
}
}
case SSS_CT_FIVE_MIXED_FLUSH_BACK_A: //A在后顺子;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]);
//zyy 如果顺子有王 就比第二张;
if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW)
{
cbNextLogicValue = GetCardLogicValue(bNextList[2]);
cbFirstLogicValue = GetCardLogicValue(bFirstList[2]);
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(bNextList[2]) > GetCardColor(bFirstList[2]);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
case SSS_CT_FIVE_FLUSH: //同花五牌;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
uint8 cbNextCardColor = GetCardColor(bNextList[0]);
uint8 cbFirstCardColor = GetCardColor(bFirstList[0]);
//先比花色;
if (cbNextCardColor != cbFirstCardColor)
{
//比较花色;
return cbNextCardColor > cbFirstCardColor;
}
//比较数值;
for (uint8 i = 0; i<5; ++i)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//比较花色;
return cbNextCardColor > cbFirstCardColor;
}
case SSS_CT_FIVE_THREE_DEOUBLE: //三条一对;
{
uint8 cbNextCardValue = bNextList[NextAnalyseData.bThreeFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bThreeFirst[0]];
//数据验证;
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
case SSS_CT_FIVE_BOMB: //zyy
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
//比较数值;
for (uint8 i = 0; i<5; ++i)
{
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[i]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue && (cbNextLogicValue != 16 || cbNextLogicValue != 15))
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//比较花色;
return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]);
}
case SSS_CT_FIVE_FOUR_ONE: //四带一张;
{
//数据验证;
uint8 cbNextCardValue = bNextList[NextAnalyseData.bFourFirst[0]];
uint8 cbFirstCardValue = bFirstList[FirstAnalyseData.bFourFirst[0]];
//CC_//ASSERT(cbNextCardValue != cbFirstCardValue);
if (cbNextCardValue == cbFirstCardValue) return false;
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCardValue);
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCardValue);
if (cbNextLogicValue == cbFirstLogicValue)
{
//比较花色;
return GetCardColor(cbNextCardValue) > GetCardColor(cbFirstCardValue);
}
else
{
//比较数值;
return cbNextLogicValue > cbFirstLogicValue;
}
}
case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A: //没A同花顺;
case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A://A在前同花顺;
case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A: //A在后同花顺;
{
//数据验证;
//CC_//ASSERT(bNextList[0] != bFirstList[0]);
if (bNextList[0] == bFirstList[0]) return false;
uint8 cbNextLogicValue = GetCardLogicValue(bNextList[0]);
uint8 cbFirstLogicValue = GetCardLogicValue(bFirstList[0]);
//zyy 如果顺子有王 就比第二张;
if (cbNextLogicValue == SSS_CARD_DW || cbNextLogicValue == SSS_CARD_XW || cbFirstLogicValue == SSS_CARD_DW || cbFirstLogicValue == SSS_CARD_XW)
{
BYTE cbNextCard1Color = GetCardColor(bNextList[1]);
BYTE cbFirstCard1Color = GetCardColor(bFirstList[1]);
//先比花色;
if (cbNextCard1Color != cbFirstCard1Color)
{
//比较花色;
return cbNextCard1Color > cbFirstCard1Color;
}
//比较数值;
for (uint8 i = 2; i<5; ++i)
{
cbNextLogicValue = GetCardLogicValue(bNextList[i]);
cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//比较花色;
return cbNextCard1Color > cbFirstCard1Color;
}
BYTE cbNextCardColor = GetCardColor(bNextList[0]);
BYTE cbFirstCardColor = GetCardColor(bFirstList[0]);
//先比花色;
if (cbNextCardColor != cbFirstCardColor)
{
//比较花色;
return cbNextCardColor > cbFirstCardColor;
}
//比较数值;
for (uint8 i = 0; i<5; ++i)
{
cbNextLogicValue = GetCardLogicValue(bNextList[i]);
cbFirstLogicValue = GetCardLogicValue(bFirstList[i]);
if (cbNextLogicValue != cbFirstLogicValue)
{
return cbNextLogicValue > cbFirstLogicValue;
}
}
//比较花色;
return cbNextCardColor > cbFirstCardColor;
}
default:
// #ifdef _DEBUG
// AfxMessageBox("错误扑克类型!") ;
// #endif
return false;
}
}
else
{
//同花顺牌
//if( bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A || bNextType==SSS_CT_FIVE_STRAIGHT_FLUSH)
//{
// if(SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A==bFirstType || SSS_CT_FIVE_STRAIGHT_FLUSH==bFirstType)
// {
// if(bNextType!=bFirstType)
// return bNextType > bFirstType ;
//
// //比较数值
// for(uint8 i=0; i<5; ++i)
// if(GetCardLogicValue(bNextList[i]) != GetCardLogicValue(bFirstList[i]))
// return GetCardLogicValue(bNextList[i]) > GetCardLogicValue(bFirstList[i]) ;
//
// //比较花色
// return GetCardColor(bNextList[0]) > GetCardColor(bFirstList[0]) ;
//
// }
//}
if (m_bClassicRule)
{
return bNextType>bFirstType;
}
else
{
if ((bFirstType == SSS_CT_FIVE_MIXED_FLUSH_NO_A&&bNextType == SSS_CT_FIVE_MIXED_FLUSH_FIRST_A) ||
(bFirstType == SSS_CT_FIVE_MIXED_FLUSH_FIRST_A&&bNextType == SSS_CT_FIVE_MIXED_FLUSH_NO_A))
{
return bNextType<bFirstType;
}
else
{
return bNextType>bFirstType;
}
}
}
}
return false;
}
/*
* 分析扑克的单张,一对。。。的数目,并记录下每种类型扑克的第一张牌(也就是最大的牌)位置以便比较大小,同时判断同一花色是否有五张
*/
//分析扑克
//分析扑克
void C13SGameLogic::AnalyseCard(const uint8 bCardDataList[], const uint8 bCardCount, tag13SAnalyseData& AnalyseData)
{
//排列扑克
uint8 bCardData[13];
CopyMemory(bCardData, bCardDataList, bCardCount);
SortCardList(bCardData, bCardCount, enDescend);
//变量定义
uint8 bSameCount = 1, bCardValueTemp = 0, bSameColorCount = 1, bFirstCardIndex = 0; //记录下标
//ASSERT(3 == bCardCount || 5 == bCardCount || 13 == bCardCount);
//设置结果
memset(&AnalyseData, 0, sizeof(AnalyseData));
if (((GetCardLogicValue(bCardData[0]) == SSS_CARD_DW || GetCardLogicValue(bCardData[0]) == SSS_CARD_XW)) && GetCardLogicValue(bCardData[1])<SSS_CARD_XW)
{
uint8 bLogicValue = GetCardLogicValue(bCardData[1]);
uint8 bCardColor = GetCardColor(bCardData[1]);
bFirstCardIndex = 1;
//扑克分析
for (uint8 i = 2; i<bCardCount; i++)
{
//获取扑克
bCardValueTemp = GetCardLogicValue(bCardData[i]);
if (bCardValueTemp == bLogicValue) bSameCount++;
//保存结果
if ((bCardValueTemp != bLogicValue) || (i == (bCardCount - 1)))
{
switch (bSameCount)
{
case 1: //一张
break;
case 2: //两张
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount] = bFirstCardIndex;
AnalyseData.bTwoCount++;
break;
}
case 3: //三张
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount] = bFirstCardIndex;
AnalyseData.bThreeCount++;
break;
}
case 4: //四张
{
AnalyseData.bFourFirst[AnalyseData.bFourCount] = bFirstCardIndex;
AnalyseData.bFourCount++;
break;
}
}
}
//设置变量
if (bCardValueTemp != bLogicValue)
{
if (bSameCount == 1)
{
if (i != bCardCount - 1)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
}
else
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
AnalyseData.bOneCount++;
}
}
else
{
if (i == bCardCount - 1)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
AnalyseData.bOneCount++;
}
}
bSameCount = 1;
bLogicValue = bCardValueTemp;
bFirstCardIndex = i;
}
if (GetCardColor(bCardData[i]) != bCardColor) bSameColorCount = 1;
else ++bSameColorCount;
}
//是否同花
AnalyseData.bStraight = ((bCardCount - 1) == bSameColorCount) ? true : false;
//开始分析
switch (bCardCount)
{
case 3: //三条类型
{
//如果有一个对子的话 剩下一个王正好组成三条
if (AnalyseData.bTwoCount == 1){ AnalyseData.bTwoCount = 0; AnalyseData.bThreeCount = 1; AnalyseData.bThreeFirst[0] = AnalyseData.bTwoFirst[0]; }
//如果两张都是单牌的话就组成一个对子
if (AnalyseData.bOneCount == 2)
{
AnalyseData.bOneCount = 1;
AnalyseData.bTwoCount = 1;
AnalyseData.bTwoFirst[0] = AnalyseData.bOneFirst[0];
AnalyseData.bOneFirst[0] = AnalyseData.bOneFirst[1];
}
return;
}
case 5: //五张牌型
{
//把四带一变成五相
if (AnalyseData.bFourCount == 1)
{
AnalyseData.bFourCount = 0;
AnalyseData.bFiveCount = 1;
AnalyseData.bFiveFirst[0] = AnalyseData.bFourFirst[0];
}
//把三带一变成4带1
if (AnalyseData.bThreeCount == 1 && AnalyseData.bOneCount == 1)
{
AnalyseData.bThreeCount = 0;
AnalyseData.bFourCount = 1;
AnalyseData.bFourFirst[0] = AnalyseData.bThreeFirst[0];
}//把两队改三条一对
else if (AnalyseData.bTwoCount == 2)
{
AnalyseData.bTwoCount = 1;
AnalyseData.bThreeCount = 1;
AnalyseData.bThreeFirst[0] = AnalyseData.bTwoFirst[0];
AnalyseData.bTwoFirst[0] = AnalyseData.bTwoFirst[1];
}//一对两单改成三条带单
else if (AnalyseData.bTwoCount == 1 && AnalyseData.bOneCount == 2)
{
AnalyseData.bTwoCount = 0;
AnalyseData.bThreeCount = 1;
AnalyseData.bThreeFirst[0] = AnalyseData.bTwoFirst[0];
}
else if (AnalyseData.bOneCount == 4)
{
AnalyseData.bOneCount = 3;
AnalyseData.bTwoFirst[0] = AnalyseData.bOneFirst[0];
AnalyseData.bOneFirst[0] = AnalyseData.bOneFirst[1];
AnalyseData.bOneFirst[1] = AnalyseData.bOneFirst[2];
AnalyseData.bOneFirst[2] = AnalyseData.bOneFirst[3];
AnalyseData.bTwoCount = 1;
}
return;
}
case 13://13张特殊牌型
{
//除了一张大小王 还有12张牌
//12张 改成 13水
if (AnalyseData.bOneCount == 12)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount++] = 0;
}
///////////////////////////////三个炸弹///////////////////////////////
if (AnalyseData.bFourCount == 2 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bThreeFirst[--AnalyseData.bThreeCount];
}
///////////////////////////////四套冲三/////////////////////////////////
if (AnalyseData.bThreeCount == 3 && AnalyseData.bTwoCount == 1 && AnalyseData.bOneCount == 1)
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
}
///////////////////////////////五对冲三/////////////////////////////////
if (AnalyseData.bTwoCount == 6)
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
}
if (AnalyseData.bTwoCount == 4 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
if (AnalyseData.bTwoCount == 3 && AnalyseData.bThreeCount == 2)
{
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bThreeFirst[--AnalyseData.bThreeCount];
}
if (AnalyseData.bTwoCount == 2 && AnalyseData.bFourCount == 1 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
if (AnalyseData.bTwoCount == 2 && AnalyseData.bFourCount == 2)
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
}
if (AnalyseData.bFourCount == 2 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
///////////////////////////////六对半 /////////////////////////////////
if (AnalyseData.bTwoCount == 5 && AnalyseData.bOneCount == 2)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
if (AnalyseData.bTwoCount == 1 && AnalyseData.bFourCount == 2)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
}
}
}
else if (GetCardLogicValue(bCardData[0]) == SSS_CARD_DW && GetCardLogicValue(bCardData[1]) == SSS_CARD_XW)
{
uint8 bLogicValue = GetCardLogicValue(bCardData[2]);
uint8 bCardColor = GetCardColor(bCardData[2]);
bFirstCardIndex = 2;
if (bCardCount != 3)
{
//扑克分析
for (uint8 i = 3; i<bCardCount; i++)
{
//获取扑克
bCardValueTemp = GetCardLogicValue(bCardData[i]);
if (bCardValueTemp == bLogicValue) bSameCount++;
//保存结果
if ((bCardValueTemp != bLogicValue) || (i == (bCardCount - 1)))
{
switch (bSameCount)
{
case 1: //一张
break;
case 2: //两张
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount] = bFirstCardIndex;
AnalyseData.bTwoCount++;
break;
}
case 3: //三张
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount] = bFirstCardIndex;
AnalyseData.bThreeCount++;
break;
}
case 4: //四张
{
AnalyseData.bFourFirst[AnalyseData.bFourCount] = bFirstCardIndex;
AnalyseData.bFourCount++;
break;
}
}
}
//设置变量
if (bCardValueTemp != bLogicValue)
{
if (bSameCount == 1)
{
if (i != bCardCount - 1)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
}
else
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
AnalyseData.bOneCount++;
}
}
else
{
if (i == bCardCount - 1)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
AnalyseData.bOneCount++;
}
}
bSameCount = 1;
bLogicValue = bCardValueTemp;
bFirstCardIndex = i;
}
if (GetCardColor(bCardData[i]) != bCardColor) bSameColorCount = 1;
else ++bSameColorCount;
}
}
else
{
//zyy
AnalyseData.bThreeFirst[AnalyseData.bThreeCount] = bFirstCardIndex;
AnalyseData.bThreeCount++;
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
}
//是否同花
AnalyseData.bStraight = ((bCardCount - 2) == bSameColorCount) ? true : false;
//开始分析
switch (bCardCount)
{
case 3: //三条类型
{
//一共就三张牌 大小王两张 就剩下一张了 组成个三条吧
if (AnalyseData.bOneCount == 1)
{
AnalyseData.bOneCount = 0;
AnalyseData.bThreeCount = 1;
AnalyseData.bThreeFirst[0] = AnalyseData.bOneFirst[0];
}
return;
}
case 5: //五张牌型
{
/////////////////一共就5张牌 大小王两张 剩下三张了/////////////////////////////
//这三张是三条的话 就只能组成 五相
if (AnalyseData.bThreeCount == 1)
{
AnalyseData.bThreeCount = 0;
AnalyseData.bFiveCount = 1;
AnalyseData.bFiveFirst[0] = AnalyseData.bThreeFirst[0];
}
else if (AnalyseData.bTwoCount == 1 && AnalyseData.bOneCount == 1)
{
AnalyseData.bTwoCount = 0;
AnalyseData.bFourCount = 1;
AnalyseData.bFourFirst[0] = AnalyseData.bTwoFirst[0];
}//这三张是单牌 就组成三带二
else if (AnalyseData.bOneCount == 3)
{
AnalyseData.bOneCount = 2;
AnalyseData.bThreeCount = 1;
AnalyseData.bThreeFirst[0] = AnalyseData.bOneFirst[0];
AnalyseData.bOneFirst[0] = AnalyseData.bOneFirst[1];
AnalyseData.bOneFirst[1] = AnalyseData.bOneFirst[2];
AnalyseData.bOneFirst[2] = AnalyseData.bOneFirst[3];
}
return;
}
case 13://13张特殊牌型
{
//11张改成13水
if (AnalyseData.bOneCount == 11)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount++] = 0;
AnalyseData.bOneFirst[AnalyseData.bOneCount++] = 1;
}
///////////////////////////////三个炸弹///////////////////////////////
if (AnalyseData.bFourCount == 2 && AnalyseData.bThreeCount == 1) //2个4张+1个3张
{
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bThreeFirst[--AnalyseData.bThreeCount];
}
if (AnalyseData.bFourCount == 2 && AnalyseData.bTwoCount == 1)//2个4张+1个2张+1个1张
{
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
}
if (AnalyseData.bFourCount == 1 && AnalyseData.bThreeCount == 2)//1个4张+2个3张
{
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bThreeFirst[--AnalyseData.bThreeCount];
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bThreeFirst[--AnalyseData.bThreeCount];
}
///////////////////////////////四套冲三///////////////////////////////// 4个3张
if (AnalyseData.bThreeCount == 3 && AnalyseData.bTwoCount == 1)//3个3张+1个2张
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
}
if (AnalyseData.bThreeCount == 3 && AnalyseData.bOneCount == 2)//3个3张+2个1张
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
if (AnalyseData.bThreeCount == 2 && AnalyseData.bTwoCount == 2)//2个3张+2个2张
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bTwoFirst[--AnalyseData.bTwoCount];
}
///////////////////////////////五对冲三/////////////////////////////////
if (AnalyseData.bTwoCount == 5 && AnalyseData.bOneCount == 1)
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
if (AnalyseData.bTwoCount == 4 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = 0;
}
if (AnalyseData.bTwoCount == 3 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
if (AnalyseData.bTwoCount == 2 && AnalyseData.bThreeCount == 2)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
AnalyseData.bFourFirst[AnalyseData.bFourCount++] = AnalyseData.bThreeFirst[--AnalyseData.bThreeCount];
}
if (AnalyseData.bTwoCount == 2 && AnalyseData.bFourCount == 1 && AnalyseData.bThreeCount == 1)
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = 0;
}
if ((AnalyseData.bTwoCount == 3 && AnalyseData.bFourCount == 1)
|| (AnalyseData.bTwoCount == 1 && AnalyseData.bFourCount == 2))
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
///////////////////////////////六对半 /////////////////////////////////
if ((AnalyseData.bTwoCount == 4 && AnalyseData.bOneCount == 3)
|| (AnalyseData.bFourCount == 2 && AnalyseData.bOneCount == 3))
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
AnalyseData.bTwoFirst[AnalyseData.bTwoCount++] = AnalyseData.bOneFirst[--AnalyseData.bOneCount];
}
}
}
}
else
{
uint8 bLogicValue = GetCardLogicValue(bCardData[0]);
uint8 bCardColor = GetCardColor(bCardData[0]);
//扑克分析
for (uint8 i = 1; i<bCardCount; i++)
{
//获取扑克
bCardValueTemp = GetCardLogicValue(bCardData[i]);
if (bCardValueTemp == bLogicValue) bSameCount++;
//保存结果
if ((bCardValueTemp != bLogicValue) || (i == (bCardCount - 1)))
{
switch (bSameCount)
{
case 1: //一张
break;
case 2: //两张
{
AnalyseData.bTwoFirst[AnalyseData.bTwoCount] = bFirstCardIndex;
AnalyseData.bTwoCount++;
break;
}
case 3: //三张
{
AnalyseData.bThreeFirst[AnalyseData.bThreeCount] = bFirstCardIndex;
AnalyseData.bThreeCount++;
break;
}
case 4: //四张
{
AnalyseData.bFourFirst[AnalyseData.bFourCount] = bFirstCardIndex;
AnalyseData.bFourCount++;
break;
}
}
}
//设置变量
if (bCardValueTemp != bLogicValue)
{
if (bSameCount == 1)
{
if (i != bCardCount - 1)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
}
else
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = bFirstCardIndex;
AnalyseData.bOneCount++;
AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
AnalyseData.bOneCount++;
}
}
else
{
if (i == bCardCount - 1)
{
AnalyseData.bOneFirst[AnalyseData.bOneCount] = i;
AnalyseData.bOneCount++;
}
}
bSameCount = 1;
bLogicValue = bCardValueTemp;
bFirstCardIndex = i;
}
if (GetCardColor(bCardData[i]) != bCardColor) bSameColorCount = 1;
else ++bSameColorCount;
}
//是否同花
AnalyseData.bStraight = (bCardCount == bSameColorCount) ? true : false;
}
return;
}
//分析扑克
void C13SGameLogic::AnalysebCardData(const uint8 cbCardData[], uint8 cbCardCount, tag13SAnalyseResult & AnalyseResult)
{
//设置结果
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
//扑克分析
for (uint8 i = 0; i<cbCardCount; i++)
{
//变量定义
uint8 cbSameCount = 1, cbCardValueTemp = 0;
uint8 cbLogicValue = GetCardLogicValue(cbCardData[i]);
//搜索同牌
for (uint8 j = i + 1; j<cbCardCount; j++)
{
//获取扑克
if (GetCardLogicValue(cbCardData[j]) != cbLogicValue) break;
//设置变量
cbSameCount++;
}
//设置结果
switch (cbSameCount)
{
case 1: //单张
{
uint8 cbIndex = AnalyseResult.cbSignedCount++;
AnalyseResult.cbSignedCardData[cbIndex*cbSameCount] = cbCardData[i];
break;
}
case 2: //两张
{
uint8 cbIndex = AnalyseResult.cbDoubleCount++;
AnalyseResult.cbDoubleCardData[cbIndex*cbSameCount] = cbCardData[i];
AnalyseResult.cbDoubleCardData[cbIndex*cbSameCount + 1] = cbCardData[i + 1];
break;
}
case 3: //三张
{
uint8 cbIndex = AnalyseResult.cbThreeCount++;
AnalyseResult.cbThreeCardData[cbIndex*cbSameCount] = cbCardData[i];
AnalyseResult.cbThreeCardData[cbIndex*cbSameCount + 1] = cbCardData[i + 1];
AnalyseResult.cbThreeCardData[cbIndex*cbSameCount + 2] = cbCardData[i + 2];
break;
}
case 4: //四张
{
uint8 cbIndex = AnalyseResult.cbFourCount++;
AnalyseResult.cbFourCardData[cbIndex*cbSameCount] = cbCardData[i];
AnalyseResult.cbFourCardData[cbIndex*cbSameCount + 1] = cbCardData[i + 1];
AnalyseResult.cbFourCardData[cbIndex*cbSameCount + 2] = cbCardData[i + 2];
AnalyseResult.cbFourCardData[cbIndex*cbSameCount + 3] = cbCardData[i + 3];
break;
}
}
//设置索引
i += cbSameCount - 1;
}
return;
}
tag13SAnalyseType C13SGameLogic::GetType(uint8 bCardData[], uint8 bCardCount)
{
tag13SAnalyseType Type;
zeromemory(&Type, sizeof(Type));
if (bCardCount == 0)
{
zeromemory(&Type, sizeof(Type));
return Type;
}
//排列扑克;
uint8 CardData[13];
CopyMemory(CardData, bCardData, bCardCount);
SortCardList(CardData, bCardCount, enDescend);
uint8 Index[13] = { 0 };
uint8 Number = 0;
uint8 SameValueCount = 1;
uint8 Num[9] = { 0 };
if (GetCardLogicValue(CardData[0]) >= SSS_CARD_XW && GetCardLogicValue(CardData[1]) <SSS_CARD_XW)
{
//判断数值相同的牌
uint8 bLogicValue = GetCardLogicValue(CardData[1]);
Index[Number++] = 1;
for (uint8 i = 2; i<bCardCount; i++)
{
if (bLogicValue == GetCardLogicValue(CardData[i]))
{
SameValueCount++;
Index[Number++] = i;
}
if (bLogicValue != GetCardLogicValue(CardData[i]) || i == bCardCount - 1)
{
if (SameValueCount == 1)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 1];
Type.cbOnePare[Num[0]++] = 0;
Type.btOnePare++;
}
else if (SameValueCount == 2)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 2];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 1];
Type.btOnePare++;
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 1];
Type.cbThreeSame[Num[2]++] = 0;
Type.btThreeSame++;
//printf("%d,%d ",Index[0],Index[1]);
}
else if (SameValueCount == 3)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 3];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 2];
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 3];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 1];
Type.btThreeSame++;
Type.bFourSame = true;
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 3];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 2];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 1];
Type.cbFourSame[Num[6]++] = 0;
Type.btFourSame++;
}
else if (SameValueCount == 4)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 4];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 3];
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 4];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 3];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.bFourSame = true;
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 4];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 3];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 2];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 1];
Type.btFourSame++;
Type.bFiveSame = true;
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 4];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 3];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 2];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 1];
Type.cbFiveSame[Num[8]++] = 0;
Type.btFiveSame++;
}
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
SameValueCount = 1;
bLogicValue = GetCardLogicValue(CardData[i]);
}
}
}
else if (GetCardLogicValue(CardData[0]) == SSS_CARD_DW && GetCardLogicValue(CardData[1]) == SSS_CARD_XW)
{
//判断数值相同的牌
uint8 bLogicValue = GetCardLogicValue(CardData[2]);
Index[Number++] = 2;
for (uint8 i = 3; i<bCardCount; i++)
{
if (bLogicValue == GetCardLogicValue(CardData[i]))
{
SameValueCount++;
Index[Number++] = i;
}
if (bLogicValue != GetCardLogicValue(CardData[i]) || i == bCardCount - 1)
{
if (SameValueCount == 1)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 1];
Type.cbOnePare[Num[0]++] = 0;
Type.btOnePare++;
/*Type.bThreeSame=true;
Type.cbThreeSame[Num[2]++]=Index[SameValueCount-1];
Type.cbThreeSame[Num[2]++]=0;
Type.cbThreeSame[Num[2]++]=1;
Type.btThreeSame++;*/
}
else if (SameValueCount == 2)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 2];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 1];
Type.btOnePare++;
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 1];
Type.cbThreeSame[Num[2]++] = 0;
Type.btThreeSame++;
Type.bFourSame = true;
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 2];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 1];
Type.cbFourSame[Num[6]++] = 0;
Type.cbFourSame[Num[6]++] = 1;
Type.btFourSame++;
}
else if (SameValueCount == 3)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 3];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 2];
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 3];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 1];
Type.btThreeSame++;
Type.bFourSame = true;
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 3];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 2];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 1];
Type.cbFourSame[Num[6]++] = 0;
Type.btFourSame++;
Type.bFiveSame = true;
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 3];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 2];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 1];
Type.cbFiveSame[Num[8]++] = 0;
Type.cbFiveSame[Num[8]++] = 1;
Type.btFiveSame++;
}
else if (SameValueCount == 4)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 4];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 3];
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 4];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 3];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.bFourSame = true;
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 4];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 3];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 2];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 1];
Type.btFourSame++;
Type.bFiveSame = true;
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 4];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 3];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 2];
Type.cbFiveSame[Num[8]++] = Index[SameValueCount - 1];
Type.cbFiveSame[Num[8]++] = 0;
Type.btFiveSame++;
}
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
SameValueCount = 1;
bLogicValue = GetCardLogicValue(CardData[i]);
}
}
}
else
{
//判断数值相同的牌
uint8 bLogicValue = GetCardLogicValue(CardData[0]);
Index[Number++] = 0;
for (uint8 i = 1; i<bCardCount; i++)
{
if (bLogicValue == GetCardLogicValue(CardData[i]))
{
SameValueCount++;
Index[Number++] = i;
}
if (bLogicValue != GetCardLogicValue(CardData[i]) || i == bCardCount - 1)
{
if (SameValueCount == 1)
{
}
else if (SameValueCount == 2)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 2];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 1];
Type.btOnePare++;
//printf("%d,%d ",Index[0],Index[1]);
}
else if (SameValueCount == 3)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 3];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 2];
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 3];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 1];
Type.btThreeSame++;
}
else if (SameValueCount == 4)
{
Type.bOnePare = true;
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 4];
Type.cbOnePare[Num[0]++] = Index[SameValueCount - 3];
//printf("%d,%d ",Index[0],Index[1]);
Type.bThreeSame = true;
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 4];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 3];
Type.cbThreeSame[Num[2]++] = Index[SameValueCount - 2];
Type.bFourSame = true;
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 4];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 3];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 2];
Type.cbFourSame[Num[6]++] = Index[SameValueCount - 1];
Type.btFourSame++;
}
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
SameValueCount = 1;
bLogicValue = GetCardLogicValue(CardData[i]);
}
}
}
//判断两对
uint8 OnePareCount = Num[0] / 2;
uint8 ThreeSameCount = Num[2] / 3;
if (OnePareCount >= 2)
{
Type.bTwoPare = false;
for (uint8 i = 0; i<OnePareCount; i++)
{
for (uint8 j = i + 1; j<OnePareCount; j++)
{
if (CardData[Type.cbOnePare[i * 2]] == CardData[Type.cbOnePare[i * 2 + 1]] || CardData[Type.cbOnePare[i * 2]] == CardData[Type.cbOnePare[j * 2]]
|| CardData[Type.cbOnePare[i * 2 + 1]] == CardData[Type.cbOnePare[j * 2]] || CardData[Type.cbOnePare[i * 2 + 1]] == CardData[Type.cbOnePare[j * 2 + 1]]
|| CardData[Type.cbOnePare[j * 2 + 1]] == CardData[Type.cbOnePare[i * 2]] || CardData[Type.cbOnePare[j * 2 + 1]] == CardData[Type.cbOnePare[j * 2]]) continue;
Type.cbTwoPare[Num[1]++] = Type.cbOnePare[i * 2];
Type.cbTwoPare[Num[1]++] = Type.cbOnePare[i * 2 + 1];
Type.cbTwoPare[Num[1]++] = Type.cbOnePare[j * 2];
Type.cbTwoPare[Num[1]++] = Type.cbOnePare[j * 2 + 1];
Type.btTwoPare++;
Type.bTwoPare = true;
}
}
}
//判断葫芦
if (OnePareCount>0 && ThreeSameCount>0)
{
for (uint8 i = 0; i<ThreeSameCount; i++)
{
for (uint8 j = 0; j<OnePareCount; j++)
{
if (bCardData[Type.cbThreeSame[i * 3]] == bCardData[Type.cbThreeSame[i * 3 + 1]]
|| bCardData[Type.cbThreeSame[i * 3]] == bCardData[Type.cbThreeSame[i * 3 + 2]]
|| bCardData[Type.cbThreeSame[i * 3]] == bCardData[Type.cbOnePare[j * 2]]
|| bCardData[Type.cbThreeSame[i * 3]] == bCardData[Type.cbOnePare[j * 2 + 1]]
|| bCardData[Type.cbThreeSame[i * 3 + 1]] == bCardData[Type.cbThreeSame[i * 3 + 2]]
|| bCardData[Type.cbThreeSame[i * 3 + 1]] == bCardData[Type.cbOnePare[j * 2]]
|| bCardData[Type.cbThreeSame[i * 3 + 1]] == bCardData[Type.cbOnePare[j * 2 + 1]]
|| bCardData[Type.cbThreeSame[i * 3 + 2]] == bCardData[Type.cbOnePare[j * 2]]
|| bCardData[Type.cbThreeSame[i * 3 + 2]] == bCardData[Type.cbOnePare[j * 2 + 1]]
|| bCardData[Type.cbOnePare[j * 2]] == bCardData[Type.cbThreeSame[i * 3 + 2]])
{
continue;
}
/*if (bCardData [Type.cbThreeSame[i*3]] != bCardData [Type.cbOnePare[j*2]]
&& bCardData [Type.cbThreeSame[i*3]] != bCardData [Type.cbOnePare[j*2+1]]
&& bCardData [Type.cbThreeSame[i*3+1]] != bCardData [Type.cbOnePare[j*2]]
&& bCardData [Type.cbThreeSame[i*3+1]] != bCardData [Type.cbOnePare[j*2+1]]
&& bCardData [Type.cbThreeSame[i*3+2]] != bCardData [Type.cbOnePare[j*2]]
&& bCardData [Type.cbThreeSame[i*3+2]] != bCardData [Type.cbOnePare[j*2+1]])*/
{
Type.bGourd = true;
Type.cbGourd[Num[5]++] = Type.cbThreeSame[i * 3];
Type.cbGourd[Num[5]++] = Type.cbThreeSame[i * 3 + 1];
Type.cbGourd[Num[5]++] = Type.cbThreeSame[i * 3 + 2];
Type.cbGourd[Num[5]++] = Type.cbOnePare[j * 2];
Type.cbGourd[Num[5]++] = Type.cbOnePare[j * 2 + 1];
Type.btGourd++;
}
}
}
}
//判断顺子及同花顺
Number = 0;
zeromemory(Index, sizeof(Index));
uint8 Straight = 1;
uint8 bStraight = GetCardLogicValue(CardData[0]);
if (GetCardLogicValue(CardData[0]) >= SSS_CARD_XW && GetCardLogicValue(CardData[1]) <SSS_CARD_XW)
{
bStraight = GetCardLogicValue(CardData[1]);
Index[Number++] = 1;
bool bUsedW = false;
for (uint8 i = 2; i<bCardCount; i++)
{
if (bStraight == GetCardLogicValue(CardData[i]) + 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
else if ((bStraight == GetCardLogicValue(CardData[i]) + 2) && (bUsedW == false))
{
bUsedW = true;
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
if (bStraight>GetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1)
{
if (Straight == 4 && bUsedW == false)
{
Straight++;
Index[Number++] = 0;
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<Straight; j++)
{
if (Straight - 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<j + 5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = j; n<j + 5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
else
{
break;
}
}
}
if (bCardCount - i<5)
{
break;
}
bStraight = GetCardLogicValue(CardData[i]);
Straight = 1;
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
bUsedW = false;
}
}
//存在2 检测A2345顺子
if (GetCardLogicValue(CardData[bCardCount - 1]) == 2)
{
Number = 0;
Straight = 2;
bStraight = GetCardLogicValue(CardData[1]);
zeromemory(Index, sizeof(Index));
bool bFind = false;
if (bStraight == 14)
{
Index[Number++] = 1;
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
bUsedW = false;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
continue;
}
if ((bStraight == GetCardLogicValue(CardData[i]) - 2)
&& (false == bUsedW))//保证鬼只使用一次
{
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
bUsedW = true;
}
}
if (Straight == 4 && bUsedW == false)
{
Straight++;
Index[Number++] = 0;
}
}
else
{
Index[Number++] = 0;
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<5; j++)
{
Type.cbStraight[Num[3]++] = Index[j];
}
Type.btStraight++;
//从手牌中找到和顺子5张中其中一张数值相同的牌组成另一种顺子
for (int k = 0; k<5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = 0; n<5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
}
//存在3并且存在A 检测A2345顺子
if ((GetCardLogicValue(CardData[bCardCount - 1]) == 3)
&& (GetCardLogicValue(CardData[1]) == 14))
{
Number = 0;
Straight = 3;
zeromemory(Index, sizeof(Index));
Index[Number++] = 0;
Index[Number++] = 1;
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<5; j++)
{
Type.cbStraight[Num[3]++] = Index[j];
}
Type.btStraight++;
//从手牌中找到和顺子5张中其中一张数值相同的牌组成另一种顺子
for (int k = 0; k<5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = 0; n<5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
}
}
else if (GetCardLogicValue(CardData[0]) == SSS_CARD_DW && GetCardLogicValue(CardData[1]) == SSS_CARD_XW)
{
bStraight = GetCardLogicValue(CardData[2]);
Index[Number++] = 2;
bool bUsedDW = false;
bool bUsedXW = false;
for (uint8 i = 3; i<bCardCount; i++)
{
if (bStraight == GetCardLogicValue(CardData[i]) + 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
else if ((bStraight == GetCardLogicValue(CardData[i]) + 2) && ((bUsedDW == false) || (bUsedXW == false)))
{
if (bUsedDW == false)
{
Straight++;
Index[Number++] = 0;
bUsedDW = true;
}
else if (bUsedXW == false)
{
Straight++;
Index[Number++] = 1;
bUsedXW = true;
}
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
else if ((bStraight == GetCardLogicValue(CardData[i] + 3)) && (bUsedDW == false) && (bUsedXW == false))
{
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = 1;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
bUsedDW = true;
bUsedXW = true;
}
if (bStraight>GetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1)
{
if (Straight == 4 && ((bUsedDW == false) || (bUsedXW == false)))
{
if (bUsedDW == false)
{
Straight++;
Index[Number++] = 0;
bUsedDW = true;
}
else if (bUsedXW == false)
{
Straight++;
Index[Number++] = 1;
bUsedXW = true;
}
}
if (Straight == 3 && ((bUsedDW == false) && (bUsedXW == false)))
{
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = 1;
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<Straight; j++)
{
if (Straight - 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<j + 5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = j; n<j + 5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
else
{
break;
}
}
}
if (bCardCount - i<5)
{
break;
}
bStraight = GetCardLogicValue(CardData[i]);
Straight = 1;
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
bUsedDW = false;
bUsedXW = false;
}
}
//存在2 检测A2345顺子
if (GetCardLogicValue(CardData[bCardCount - 1]) == 2)
{
Number = 0;
Straight = 2;
bStraight = GetCardLogicValue(CardData[2]);
zeromemory(Index, sizeof(Index));
bool bFind = false;
if (bStraight == 14)
{
//Index[Number++]=1;
Index[Number++] = 2; //下标0,1位置是鬼所以是从下标2位置的A开始
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
bool bDWused = false;
bool bXWused = false;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
continue;
}
else if ((bStraight == GetCardLogicValue(CardData[i]) - 2)
&& ((false == bDWused) || (false == bDWused)))//保证大小鬼只使用一次
{
if (bDWused == false)
{
bDWused = true;
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
else if (bXWused == false)
{
bXWused = true;
Straight++;
Index[Number++] = 1;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
else if ((bStraight == GetCardLogicValue(CardData[i] - 3))
&& (false == bDWused) && (false == bDWused))//保证大小鬼只使用一次
{
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = 1;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
}
else
{
Index[Number++] = rand() % 2;//大小鬼任取一张
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<5; j++)
{
Type.cbStraight[Num[3]++] = Index[j];
}
Type.btStraight++;
//从手牌中找到和顺子5张中其中一张数值相同的牌组成另一种顺子
for (int k = 0; k<5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = 0; n<5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
}
//存在3 检测A2345顺子
if (GetCardLogicValue(CardData[bCardCount - 1]) == 3)
{
Number = 0;
Straight = 3;
bStraight = GetCardLogicValue(CardData[2]);
zeromemory(Index, sizeof(Index));
bool bFind = false;
if (bStraight == 14)
{
Index[Number++] = 1;
Index[Number++] = 2;
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
bool bDWused = false;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
continue;
}
else if ((bStraight == GetCardLogicValue(CardData[i]) - 2)
&& (false == bDWused))//保证大鬼只使用一次
{
if (bDWused == false)
{
bDWused = true;
Straight++;
Index[Number++] = 0;
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
}
}
else
{
Index[Number++] = 0;
Index[Number++] = 1;
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<5; j++)
{
Type.cbStraight[Num[3]++] = Index[j];
}
Type.btStraight++;
//从手牌中找到和顺子5张中其中一张数值相同的牌组成另一种顺子
for (int k = 0; k<5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = 0; n<5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
}
//存在4和A 检测A2345顺子
if ((GetCardLogicValue(CardData[bCardCount - 1]) == 4)
&& (GetCardLogicValue(CardData[2]) == 14))
{
Number = 0;
Straight = 4;
bStraight = GetCardLogicValue(CardData[2]);
zeromemory(Index, sizeof(Index));
Index[Number++] = 0;
Index[Number++] = 1;
Index[Number++] = 2;
bStraight = GetCardLogicValue(CardData[bCardCount - 1]);
Index[Number++] = bCardCount - 1;
for (int i = bCardCount - 2; i >= 0; i--)
{
if (bStraight == GetCardLogicValue(CardData[i]) - 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<5; j++)
{
Type.cbStraight[Num[3]++] = Index[j];
}
Type.btStraight++;
//从手牌中找到和顺子5张中其中一张数值相同的牌组成另一种顺子
for (int k = 0; k<5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = 0; n<5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
}
}
else //没有王的
{
bStraight = GetCardLogicValue(CardData[0]);
Index[Number++] = 0;
if (bStraight != 14)
{
for (uint8 i = 1; i<bCardCount; i++)
{
if (bStraight == GetCardLogicValue(CardData[i]) + 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
if (bStraight>GetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1)
{
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<Straight; j++)
{
if (Straight - 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<j + 5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = j; n<j + 5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
else
{
break;
}
}
}
if (bCardCount - i<5)
{
break;
}
bStraight = GetCardLogicValue(CardData[i]);
Straight = 1;
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
}
}
}
if (bStraight == 14) ///zyy 要是出现A的 就会有问题
{
for (uint8 i = 1; i<bCardCount; i++)
{
if (bStraight == GetCardLogicValue(CardData[i]) + 1)
{
Straight++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
if (bStraight>GetCardLogicValue(CardData[i]) + 1 || i == bCardCount - 1)
{
if (Straight >= 5)
{
Type.bStraight = true;
for (uint8 j = 0; j<Straight; j++)
{
if (Straight - 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<j + 5; k++)
{
for (int m = 0; m<bCardCount; m++)
{
if (GetCardLogicValue(CardData[Index[k]]) == GetCardLogicValue(CardData[m]) && GetCardColor(CardData[Index[k]]) != GetCardColor(CardData[m]))
{
for (int n = j; n<j + 5; n++)
{
if (n == k)
{
Type.cbStraight[Num[3]++] = m;
}
else
{
Type.cbStraight[Num[3]++] = Index[n];
}
}
Type.btStraight++;
}
}
}
}
else
{
break;
}
}
}
if ((bCardCount - i)<5)
{
break;
}
bStraight = GetCardLogicValue(CardData[i]);
Straight = 1;
Number = 0;
zeromemory(Index, sizeof(Index));
Index[Number++] = i;
}
}
if (GetCardLogicValue(CardData[bCardCount - 1]) == 2)
{
Number = 0;
uint8 BackA = 1;
uint8 FrontA = 1;
bStraight = GetCardLogicValue(CardData[0]);
zeromemory(Index, sizeof(Index));
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)
{
FrontA++;
Index[Number++] = i;
bStraight = GetCardLogicValue(CardData[i]);
}
}
if (FrontA + BackA >= 5)
{
Type.bStraight = true;
for (uint8 i = BackA; i>0; i--)
{
for (uint8 j = 1; j <= FrontA; j++)
{
if (i + j == 5)
{
for (uint8 k = 0; k<i; k++)
{
Type.cbStraight[Num[3]++] = Index[k];
}
for (uint8 k = 0; k<j; k++)
{
Type.cbStraight[Num[3]++] = Index[k + BackA];
}
Type.btStraight++;
break;
}
}
}
}
}
}
}
//判断同花
Number = 0;
zeromemory(Index, sizeof(Index));
SortCardList(CardData, bCardCount, enColor);
uint8 cbCardData[13];
CopyMemory(cbCardData, bCardData, bCardCount);
SortCardList(cbCardData, bCardCount, enDescend);
if (GetCardLogicValue(CardData[0]) >= SSS_CARD_XW && GetCardLogicValue(CardData[1]) <SSS_CARD_XW)
{
uint8 SameColorCount = 1;
uint8 bCardColor = GetCardColor(CardData[1]);
Index[Number++] = 1;
for (uint8 i = 2; i<bCardCount; i++)
{
if (bCardColor == GetCardColor(CardData[i]))
{
SameColorCount++;
Index[Number++] = i;
}
if (bCardColor != GetCardColor(CardData[i]) || i == bCardCount - 1)
{
if (SameColorCount == 4)
{
SameColorCount++;
Index[Number++] = 0;
}
if (SameColorCount >= 5)
{
Type.bFlush = true;
//切换位置
for (uint8 j = 0; j<SameColorCount; j++)
{
for (uint8 k = 0; k<bCardCount; k++)
{
if (GetCardLogicValue(CardData[Index[j]]) == GetCardLogicValue(cbCardData[k])
&& GetCardColor(CardData[Index[j]]) == GetCardColor(cbCardData[k]))
{
Index[j] = k;
break;
}
}
}
//排序位置
uint8 SaveIndex = 0;
for (uint8 j = 0; j<SameColorCount; j++)
{
for (uint8 k = j + 1; k<SameColorCount; k++)
{
if (Index[j]>Index[k])
{
SaveIndex = Index[j];
Index[j] = Index[k];
Index[k] = SaveIndex;
}
}
}
//同花顺
if (GetCardLogicValue(cbCardData[Index[0]]) >= SSS_CARD_XW)
{
if (((GetCardLogicValue(cbCardData[Index[1]]) == 14) && ((GetCardLogicValue(cbCardData[Index[2]]) == 5) || (GetCardLogicValue(cbCardData[Index[2]]) == 4)))
|| (4 >= (GetCardLogicValue(cbCardData[Index[1]]) - GetCardLogicValue(cbCardData[Index[4]]))))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[0];
Type.cbStraightFlush[Num[7]++] = Index[1];
Type.cbStraightFlush[Num[7]++] = Index[2];
Type.cbStraightFlush[Num[7]++] = Index[3];
Type.cbStraightFlush[Num[7]++] = Index[4];
Type.btStraightFlush++;
}
}
else
{
//同花A2345特殊处理
if (GetCardLogicValue(cbCardData[Index[0]]) == 14)
{
for (uint8 i = 1; i<SameColorCount; i++)
{
if (GetCardLogicValue(cbCardData[Index[i]]) == 5)
{
if (SameColorCount - i == 4)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[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 == 3)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = Index[0];//A
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.btStraightFlush++;
}
}
if (GetCardLogicValue(cbCardData[Index[i]]) == 4)
{
if (SameColorCount - i == 3)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = Index[0];//A
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.btStraightFlush++;
}
}
}
}
for (uint8 i = 0; i<SameColorCount; i++)
{
if (SameColorCount - i >= 5)
{
if (4 == (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 4]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.cbStraightFlush[Num[7]++] = Index[i + 3];
Type.cbStraightFlush[Num[7]++] = Index[i + 4];
Type.btStraightFlush++;
}
else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.cbStraightFlush[Num[7]++] = Index[i + 3];
Type.btStraightFlush++;
}
}
else if (SameColorCount - i == 4)
{
if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.cbStraightFlush[Num[7]++] = Index[i + 3];
Type.btStraightFlush++;
}
}
}
}
for (uint8 j = 0; j<SameColorCount; j++)
{
if (SameColorCount - j >= 5)
{
Type.cbFlush[Num[4]++] = Index[j];
Type.cbFlush[Num[4]++] = Index[j + 1];
Type.cbFlush[Num[4]++] = Index[j + 2];
Type.cbFlush[Num[4]++] = Index[j + 3];
Type.cbFlush[Num[4]++] = Index[j + 4];
Type.btFlush++;
}
else
{
break;
}
}
}
if (bCardCount - i<4)
{
break;
}
Number = 0;
zeromemory(Index, sizeof(Index));
SameColorCount = 1;
Index[Number++] = i;
bCardColor = GetCardColor(CardData[i]);
}
}
}
else if (GetCardLogicValue(CardData[0]) == SSS_CARD_DW && GetCardLogicValue(CardData[1]) == SSS_CARD_XW)
{
uint8 SameColorCount = 1;
uint8 bCardColor = GetCardColor(CardData[2]);
Index[Number++] = 2;
for (uint8 i = 3; i<bCardCount; i++)
{
if (bCardColor == GetCardColor(CardData[i]))
{
SameColorCount++;
Index[Number++] = i;
}
if (bCardColor != GetCardColor(CardData[i]) || i == bCardCount - 1)
{
if (SameColorCount == 4)
{
SameColorCount++;
Index[Number++] = 0;
}
if (SameColorCount == 3)
{
SameColorCount++;
Index[Number++] = 0;
SameColorCount++;
Index[Number++] = 1;
}
if (SameColorCount >= 5)
{
Type.bFlush = true;
for (uint8 j = 0; j<SameColorCount; j++)
{
for (uint8 k = 0; k<bCardCount; k++)
{
if (GetCardLogicValue(CardData[Index[j]]) == GetCardLogicValue(cbCardData[k])
&& GetCardColor(CardData[Index[j]]) == GetCardColor(cbCardData[k]))
{
Index[j] = k;
break;
}
}
}
uint8 SaveIndex = 0;
for (uint8 j = 0; j<SameColorCount; j++)
{
for (uint8 k = j + 1; k<SameColorCount; k++)
{
if (Index[j]>Index[k])
{
SaveIndex = Index[j];
Index[j] = Index[k];
Index[k] = SaveIndex;
}
}
}
//同花顺
if (GetCardLogicValue(cbCardData[Index[0]]) == SSS_CARD_DW && GetCardLogicValue(cbCardData[Index[1]]) == SSS_CARD_XW)
{
if (((GetCardLogicValue(cbCardData[Index[2]]) == 14) && ((GetCardLogicValue(cbCardData[Index[3]]) == 5) || (GetCardLogicValue(cbCardData[Index[3]]) == 4) || (GetCardLogicValue(cbCardData[Index[3]]) == 3)))
|| (4 >= (GetCardLogicValue(cbCardData[Index[2]]) - GetCardLogicValue(cbCardData[Index[4]]))))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[0];
Type.cbStraightFlush[Num[7]++] = Index[1];
Type.cbStraightFlush[Num[7]++] = Index[2];
Type.cbStraightFlush[Num[7]++] = Index[3];
Type.cbStraightFlush[Num[7]++] = Index[4];
Type.btStraightFlush++;
}
}
else if (GetCardLogicValue(cbCardData[Index[0]]) >= SSS_CARD_XW && GetCardLogicValue(cbCardData[Index[1]]) <SSS_CARD_XW)
{
if (((GetCardLogicValue(cbCardData[Index[1]]) == 14) && ((GetCardLogicValue(cbCardData[Index[2]]) == 5) || (GetCardLogicValue(cbCardData[Index[2]]) == 4)))
|| (4 >= (GetCardLogicValue(cbCardData[Index[1]]) - GetCardLogicValue(cbCardData[Index[4]]))))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[0];
Type.cbStraightFlush[Num[7]++] = Index[1];
Type.cbStraightFlush[Num[7]++] = Index[2];
Type.cbStraightFlush[Num[7]++] = Index[3];
Type.cbStraightFlush[Num[7]++] = Index[4];
Type.btStraightFlush++;
}
}
else
{
//同花A2345特殊处理
if (GetCardLogicValue(cbCardData[Index[0]]) == 14)
{
for (uint8 i = 1; i<SameColorCount; i++)
{
if (GetCardLogicValue(cbCardData[Index[i]]) == 5)
{
if (SameColorCount - i == 4)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[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 == 3)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = Index[0];//A
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 == 2)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = 1;
Type.cbStraightFlush[Num[7]++] = Index[0];//A
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.btStraightFlush++;
}
}
else if (GetCardLogicValue(cbCardData[Index[i]]) == 4)
{
if (SameColorCount - i == 3)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = Index[0];//A
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 == 2)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = 1;
Type.cbStraightFlush[Num[7]++] = Index[0];//A
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.btStraightFlush++;
}
}
else if (GetCardLogicValue(cbCardData[Index[i]]) == 3)
{
if (SameColorCount - i == 2)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;//鬼
Type.cbStraightFlush[Num[7]++] = 1;
Type.cbStraightFlush[Num[7]++] = Index[0];//A
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.btStraightFlush++;
}
}
}
}
for (uint8 i = 0; i<SameColorCount; i++)
{
if (SameColorCount - i >= 5)
{
if (4 == (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 4]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.cbStraightFlush[Num[7]++] = Index[i + 3];
Type.cbStraightFlush[Num[7]++] = Index[i + 4];
Type.btStraightFlush++;
}
else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.cbStraightFlush[Num[7]++] = Index[i + 3];
Type.btStraightFlush++;
}
else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 2]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = 1;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.btStraightFlush++;
}
}
else if (SameColorCount - i == 4)
{
if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 3]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.cbStraightFlush[Num[7]++] = Index[i + 3];
Type.btStraightFlush++;
}
else if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 2]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = 1;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.btStraightFlush++;
}
}
else if (SameColorCount - i == 3)
{
if (4 >= (GetCardLogicValue(cbCardData[Index[i]]) - GetCardLogicValue(cbCardData[Index[i + 2]])))
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = 0;
Type.cbStraightFlush[Num[7]++] = 1;
Type.cbStraightFlush[Num[7]++] = Index[i];
Type.cbStraightFlush[Num[7]++] = Index[i + 1];
Type.cbStraightFlush[Num[7]++] = Index[i + 2];
Type.btStraightFlush++;
}
}
}
}
for (uint8 j = 0; j<SameColorCount; j++)
{
if (SameColorCount - j >= 5)
{
Type.cbFlush[Num[4]++] = Index[j];
Type.cbFlush[Num[4]++] = Index[j + 1];
Type.cbFlush[Num[4]++] = Index[j + 2];
Type.cbFlush[Num[4]++] = Index[j + 3];
Type.cbFlush[Num[4]++] = Index[j + 4];
Type.btFlush++;
}
else
{
break;
}
}
}
if (bCardCount - i<3)
{
break;
}
Number = 0;
zeromemory(Index, sizeof(Index));
SameColorCount = 1;
Index[Number++] = i;
bCardColor = GetCardColor(CardData[i]);
}
}
}
else
{
uint8 SameColorCount = 1;
uint8 bCardColor = GetCardColor(CardData[0]);
Index[Number++] = 0;
for (uint8 i = 1; i<bCardCount; i++)
{
if (bCardColor == GetCardColor(CardData[i]))
{
SameColorCount++;
Index[Number++] = i;
}
if (bCardColor != GetCardColor(CardData[i]) || i == bCardCount - 1)
{
if (SameColorCount >= 5)
{
Type.bFlush = true;
for (uint8 j = 0; j<SameColorCount; j++)
{
for (uint8 k = 0; k<bCardCount; k++)
{
if (GetCardLogicValue(CardData[Index[j]]) == GetCardLogicValue(cbCardData[k])
&& GetCardColor(CardData[Index[j]]) == GetCardColor(cbCardData[k]))
{
Index[j] = k;
break;
}
}
}
uint8 SaveIndex = 0;
for (uint8 j = 0; j<SameColorCount; j++)
{
for (uint8 k = j + 1; k<SameColorCount; k++)
{
if (Index[j]>Index[k])
{
SaveIndex = Index[j];
Index[j] = Index[k];
Index[k] = SaveIndex;
}
}
}
for (uint8 j = 0; j<SameColorCount; j++)
{
if (SameColorCount - j >= 5)
{
Type.cbFlush[Num[4]++] = Index[j];
Type.cbFlush[Num[4]++] = Index[j + 1];
Type.cbFlush[Num[4]++] = Index[j + 2];
Type.cbFlush[Num[4]++] = Index[j + 3];
Type.cbFlush[Num[4]++] = Index[j + 4];
Type.btFlush++;
//同花A2345特殊处理
if (GetCardLogicValue(cbCardData[Index[j]]) == 14)
{
for (uint8 i = j + 1; i<SameColorCount; i++)
{
if (GetCardLogicValue(cbCardData[Index[i]]) == 5)
{
if (SameColorCount - i >= 4)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[j];//A
Type.cbStraightFlush[Num[7]++] = Index[i];//5
Type.cbStraightFlush[Num[7]++] = Index[i + 1];//4
Type.cbStraightFlush[Num[7]++] = Index[i + 2];//3
Type.cbStraightFlush[Num[7]++] = Index[i + 3];//2
Type.btStraightFlush++;
}
}
}
}
if (GetCardLogicValue(cbCardData[Index[j]]) - GetCardLogicValue(cbCardData[Index[j + 4]]) == 4)
{
Type.bStraightFlush = true;
Type.cbStraightFlush[Num[7]++] = Index[j];
Type.cbStraightFlush[Num[7]++] = Index[j + 1];
Type.cbStraightFlush[Num[7]++] = Index[j + 2];
Type.cbStraightFlush[Num[7]++] = Index[j + 3];
Type.cbStraightFlush[Num[7]++] = Index[j + 4];
Type.btStraightFlush++;
}
}
else
{
break;
}
}
}
if (bCardCount - i<5)
{
break;
}
Number = 0;
zeromemory(Index, sizeof(Index));
SameColorCount = 1;
Index[Number++] = i;
bCardColor = GetCardColor(CardData[i]);
}
}
}
return Type;
}
bool C13SGameLogic::AppendCard(const uint8 bAppendCard[], uint8 bAppendCount, uint8 bCardData[], uint8 &bCardCount)
{
//ASSERT(bAppendCount + bCardCount <= 13);
for (int i = 0; i<bAppendCount; i++)
{
bCardData[bCardCount + i] = bAppendCard[i];
}
bCardCount += bAppendCount;
return true;
}
uint8 C13SGameLogic::GetCardCount(uint8 bCardData[])
{
uint8 Number = 0;
if (0 == GetCardLogicValue(bCardData[1]) && 0 == GetCardLogicValue(bCardData[2]))
{
return 0;
}
else
{
for (uint8 i = 0; i<5; i++)
{
if (GetCardLogicValue(bCardData[i])>0)
{
Number++;
}
else
{
break;
}
}
}
return Number;
}
bool C13SGameLogic::IsSameCardData(uint8 btFirstCard[], uint8 btNextCard[], uint8 btFirstCount, uint8 btNextCount)
{
if (btNextCount != btFirstCount)
{
return false;
}
for (int i = 0; i<btFirstCount; i++)
{
if (btFirstCard[i] != btNextCard[i])
{
return false;
}
}
return true;
}
bool C13SGameLogic::IsFlush(const uint8 cbCardData[], const uint8 cbCardCount, uint8 bMaxCardData[], uint8 & bMaxCardCount, uint8 bNeedCCount)
{
//校验数据
//ASSERT(cbCardCount <= 13 || cbCardCount > 3);
//定义变量
uint8 bKCount = 0;
std::vector<uint8> evCardList[15]; //0位存王牌,1位保留,其他位按逻辑值存放
std::vector<uint8> evColorList[4]; //方梅红黑
uint8 bCardArray[13] = { 0 };
memcpy(bCardArray, cbCardData, sizeof(uint8)*cbCardCount);
SortCardList(bCardArray, cbCardCount, enDescend);
//分析扑克
for (int i = 0; i < cbCardCount; i++)
{
//保存王牌
if (bCardArray[i] == 0x41 || bCardArray[i] == 0x42)
{
evCardList[0].push_back(bCardArray[i]);
continue;
}
//保存其他
uint8 bLogicNum = GetCardLogicValue(bCardArray[i]);
uint8 bColor = GetCardColor(bCardArray[i]);
//ASSERT(bLogicNum>1 && bLogicNum<15 && bColor >= 0 && bColor <= 3);
//ASSERT(std::find(evCardList[bLogicNum].begin(), evCardList[bLogicNum].end(), bCardArray[i]) != evCardList[bLogicNum].end());
evCardList[bLogicNum].push_back(bCardArray[i]);
evColorList[bColor].push_back(bCardArray[i]);
}
//ASSERT(evCardList[0].size() <= 2);
//寻找同花
uint8 bPossibleCard[4][5] = { 0 }; //各个能组成同花的牌组
std::vector<uint8> maxCardColorList;
for (int i = 0; i < 4; i++)
{
if (evColorList[i].size() + evCardList[0].size() >= bNeedCCount)
{
if (evColorList[i].size() >= bNeedCCount)
{
for (int k = 0; k < bNeedCCount; k++)
{
bPossibleCard[i][k] = evColorList[i].at(k);
}
}
else
{
int j = 0;
for (; j < bNeedCCount - evColorList[i].size(); j++)
{
bPossibleCard[i][j] = evCardList[0].at(j);
}
for (int k = 0; k < evColorList[i].size(); k++)
{
bPossibleCard[i][j + k] = evColorList[i].at(k);
}
}
maxCardColorList.push_back(i);
}
}
if (maxCardColorList.size() != 0)
{
uint8 bMax = maxCardColorList.at(0);
for (int i = 1; i < maxCardColorList.size(); i++)
{
uint8 bColor = maxCardColorList.at(i);
if (CompareCard(bPossibleCard[bMax], bPossibleCard[bColor], bNeedCCount, bNeedCCount, m_bClassicRule))
{
bMax = bColor;
}
}
memcpy(bMaxCardData, bPossibleCard[bMax], sizeof(uint8)*bNeedCCount);
bMaxCardCount = bNeedCCount;
return true;
}
return false;
}
// 获取牌型图片路径;
std::string C13SGameLogic::getCardTypeImagePath(uint8 cbCardType)
{
switch (cbCardType)
{
case SSS_CT_SINGLE:
{
return "Games/13S/CardType/N_SanPai.png";
}
case SSS_CT_ONE_DOUBLE:
{
return "Games/13S/CardType/N_YiDui.png";
}
case SSS_CT_FIVE_TWO_DOUBLE:
{
return "Games/13S/CardType/N_LiangDui.png";
}
case SSS_CT_THREE:
{
return "Games/13S/CardType/N_SanTiao.png";
}
case SSS_CT_FIVE_MIXED_FLUSH_NO_A:
case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A:
case SSS_CT_FIVE_MIXED_FLUSH_BACK_A:
{
return "Games/13S/CardType/N_ShunZi.png";
}
case SSS_CT_FIVE_FLUSH:
{
return "Games/13S/CardType/N_TongHua.png";;
}
case SSS_CT_FIVE_THREE_DEOUBLE:
{
return "Games/13S/CardType/N_HuLu.png";
}
case SSS_CT_FIVE_FOUR_ONE:
{
return "Games/13S/CardType/N_TieZhi.png";
}
case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A:
case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A:
case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A:
{
return "Games/13S/CardType/N_TongHuaShun.png";
}
case SSS_CT_FIVE_BOMB:
{
break;
}
case SSS_CT_THREE_STRAIGHT:
{
return "Games/13S/CardType/S_SanShunZi.png";
}
case SSS_CT_THREE_FLUSH:
{
return "Games/13S/CardType/S_SanTongHua.png";
}
case SSS_CT_SIXPAIR:
{
return "Games/13S/CardType/S_LiuDuiBan.png";
}
case SSS_CT_FIVEPAIR_THREE:
{
return "Games/13S/CardType/S_WuDuiSanTiao.png";
}
case SSS_CT_FOUR_THREESAME:
{
return "Games/13S/CardType/S_SiTaoBanTiao.png";
}
case SSS_CT_SAME_COLOR:
{
return "Games/13S/CardType/S_CouYiSe.png";
}
case SSS_CT_ALL_SMALL:
{
return "Games/13S/CardType/S_QuanXiao.png";
}
case SSS_CT_ALL_BIG:
{
return "Games/13S/CardType/S_QuanDa.png";
}
case SSS_CT_THREE_BOMB:
{
return "Games/13S/CardType/S_SanFenTianXia.png";
}
case SSS_CT_THREE_STRAIGHTFLUSH:
{
return "Games/13S/CardType/S_SanTongHuaShun.png";
}
case SSS_CT_TWELVE_KING:
{
return "Games/13S/CardType/S_ShiErHuangZu.png";
}
case SSS_CT_THIRTEEN:
{
return "Games/13S/CardType/S_YiTiaoLong.png";
}
case SSS_CT_THIRTEEN_FLUSH:
{
return "Games/13S/CardType/S_ZhiZunQingLong.png";
}
default:
break;
}
return "";
}
// 获取牌型声音路径;
std::string C13SGameLogic::getCardTypeSoundPath(uint8 cbGender, uint8 cbCardType)
{
std::string strPath = "Games/13S/Sound/";
if (0 == cbGender)
{
strPath += "man/m_";
}
else
{
strPath += "woman/f_";
}
switch (cbCardType)
{
case SSS_CT_SINGLE:
{
strPath += "wulong.mp3";
break;
}
case SSS_CT_ONE_DOUBLE:
{
strPath += "duizi.mp3";
break;
}
case SSS_CT_FIVE_TWO_DOUBLE:
{
strPath += "liangdui.mp3";
break;
}
case SSS_CT_THREE:
{
strPath += "santiao.mp3";
break;
}
case SSS_CT_FIVE_MIXED_FLUSH_NO_A:
case SSS_CT_FIVE_MIXED_FLUSH_FIRST_A:
case SSS_CT_FIVE_MIXED_FLUSH_BACK_A:
{
strPath += "shunzi.mp3";
break;
}
case SSS_CT_FIVE_FLUSH:
{
strPath += "tonghua.mp3";
break;
}
case SSS_CT_FIVE_THREE_DEOUBLE:
{
strPath += "hulu.mp3";
break;
}
case SSS_CT_FIVE_FOUR_ONE:
{
strPath += "tiezhi.mp3";
break;
}
case SSS_CT_FIVE_STRAIGHT_FLUSH_NO_A:
case SSS_CT_FIVE_STRAIGHT_FLUSH_FIRST_A:
case SSS_CT_FIVE_STRAIGHT_FLUSH_BACK_A:
{
strPath += "tonghuashun.mp3";
break;
}
case SSS_CT_FIVE_BOMB:
{
break;
}
case SSS_CT_THREE_STRAIGHT:
{
strPath += "sanshunzi.mp3";
break;
}
case SSS_CT_THREE_FLUSH:
{
strPath += "santonghua.mp3";
break;
}
case SSS_CT_SIXPAIR:
{
strPath += "liuduiban.mp3";
break;
}
case SSS_CT_FIVEPAIR_THREE:
{
strPath += "wuduisantiao.mp3";
break;
}
case SSS_CT_FOUR_THREESAME:
{
strPath += "sitaosantiao.mp3";
break;
}
case SSS_CT_SAME_COLOR:
{
strPath += "couyisi.mp3";
break;
}
case SSS_CT_ALL_SMALL:
{
strPath += "quanxiao.mp3";
break;
}
case SSS_CT_ALL_BIG:
{
strPath += "quanda.mp3";
break;
}
case SSS_CT_THREE_BOMB:
{
strPath += "sanfentianxia.mp3";
break;
}
case SSS_CT_THREE_STRAIGHTFLUSH:
{
strPath += "santonghuashun.mp3";
break;
}
case SSS_CT_TWELVE_KING:
{
strPath += "12huangzu.mp3";
break;
}
case SSS_CT_THIRTEEN:
{
strPath += "yitiaolong.mp3";
break;
}
case SSS_CT_THIRTEEN_FLUSH:
{
strPath += "qinglong.mp3";
break;
}
default:
break;
}
return strPath;
}
//////////////////////////////////////////////////////////////////////////