2635 lines
70 KiB
C++
2635 lines
70 KiB
C++
|
|
#include "DZ_GameLogic.h"
|
|||
|
|
|
|||
|
|
#define IS_BOME_TYPE(x,y) (((x)>>(y))>0)
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
const uint8 cbIndexCount = 5;
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
const uint8 DZ_CGameLogic::m_cbCardData[DZ_FULL_COUNT] =
|
|||
|
|
{
|
|||
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //÷<><C3B7> A - K
|
|||
|
|
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x4E, 0x4F,
|
|||
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //÷<><C3B7> A - K
|
|||
|
|
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x4E, 0x4F,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
const uint8 DZ_CGameLogic::m_cbNoJokerCardData[DZ_NO_JOKER_COUNT] =
|
|||
|
|
{
|
|||
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //÷<><C3B7> A - K
|
|||
|
|
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //÷<><C3B7> A - K
|
|||
|
|
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
DZ_CGameLogic::DZ_CGameLogic()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DZ_CGameLogic::~DZ_CGameLogic()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int DZ_CGameLogic::GetCardType(const uint8 cbCardData[], uint8 cbCardCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
switch (cbCardCount)
|
|||
|
|
{
|
|||
|
|
case 0: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
case 1: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return TransListToInt(0,DZ_CT_SINGLE);
|
|||
|
|
}
|
|||
|
|
case 2: //<2F><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
//if ((cbCardData[0]==0x4F)&&(cbCardData[1]==0x4E)) return TransListToInt(0,DZ_CT_MISSILE_CARD);
|
|||
|
|
if (GetCardLogicValue(cbCardData[0])==GetCardLogicValue(cbCardData[1])) return TransListToInt(0,DZ_CT_DOUBLE);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if(GetCardLogicValue(cbCardData[0])!=GetCardLogicValue(cbCardData[1]))
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[0]) && !IsLaiZiCard(cbCardData[1]))
|
|||
|
|
{
|
|||
|
|
return TransListToInt(0, DZ_CT_DOUBLE);
|
|||
|
|
}
|
|||
|
|
else if (!IsLaiZiCard(cbCardData[0]) && IsLaiZiCard(cbCardData[1]))
|
|||
|
|
{
|
|||
|
|
return TransListToInt(0, DZ_CT_DOUBLE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (IsLaiZiCard(cbCardData[0]) || IsLaiZiCard(cbCardData[1]))
|
|||
|
|
//{
|
|||
|
|
// if(((cbCardData[0]!=0x4F) || (cbCardData[0]!=0x4E)) && (cbCardData[1]!=0x4F) && (cbCardData[1]!=0x4E))
|
|||
|
|
// {
|
|||
|
|
// return TransListToInt(0,DZ_CT_DOUBLE);
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
case 4: //<2F><>ը;
|
|||
|
|
{
|
|||
|
|
if ((cbCardData[0] == 0x4F) && (cbCardData[1] == 0x4F) && (cbCardData[2] == 0x4E) && (cbCardData[3] == 0x4E))
|
|||
|
|
{
|
|||
|
|
return TransListToInt(0, DZ_CT_BOMB_8);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int dCardType = DZ_CT_ERROR;
|
|||
|
|
|
|||
|
|
// ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCardCount >= 4 && cbCardCount <= 12)
|
|||
|
|
{
|
|||
|
|
bool isSameCard = true;
|
|||
|
|
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>;
|
|||
|
|
uint8 cbValue = GetCardValue(cbCardData[cbCardCount - 1]);
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
ASSERT(IsValidCard(cbCardData[i]));
|
|||
|
|
if (cbValue != GetCardValue(cbCardData[i]) && !IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
isSameCard = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ͬ<><CDAC><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (isSameCard)
|
|||
|
|
{
|
|||
|
|
// 4<><34>ը<EFBFBD><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E2B4A6>;
|
|||
|
|
if (isLastCard && (cbCardCount == 4))
|
|||
|
|
{
|
|||
|
|
dCardType = TransListToInt(dCardType, DZ_CT_THREE_TAKE_TWO);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint8 cbCardType = DZ_CT_BOMB_4 + cbCardCount - 4;
|
|||
|
|
cbCardType = (cbCardType > DZ_CT_BOMB_10) ? DZ_CT_BOMB_10 : cbCardType;
|
|||
|
|
dCardType = TransListToInt(dCardType, cbCardType);
|
|||
|
|
|
|||
|
|
return dCardType;// TransListToInt(0, cbCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = {0};
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCardCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount == 0)
|
|||
|
|
{
|
|||
|
|
uint8 bCardDataTemp[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(bCardDataTemp, cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZAnalyseResult AnalyseResult;
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
uint8 cbMaxCardData = 0;
|
|||
|
|
uint8 cbBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, cbMaxCardData, cbBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><D3B8><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dCardType&(1 << iCardType)) == 0)
|
|||
|
|
{
|
|||
|
|
dCardType = TransListToInt(dCardType, iCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (cbMagicCardCount >= 1)
|
|||
|
|
{
|
|||
|
|
tagDZAnalyseResult AnalyseResult;
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
|
|||
|
|
uint8 bCardDataTemp[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(&bCardDataTemp[cbMagicCardCount], cbNormalCard, sizeof(uint8)*cbNormalCardCount);
|
|||
|
|
|
|||
|
|
for (uint8 i = 0; i < 13; i++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[0] = m_cbCardData[i];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbMagicCardCount >= 2)
|
|||
|
|
{
|
|||
|
|
for (uint8 z = 0; z < 13; z++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[1] = m_cbCardData[z];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbMagicCardCount >= 3)
|
|||
|
|
{
|
|||
|
|
for (uint8 f = 0; f < 13; f++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[2] = m_cbCardData[f];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbMagicCardCount == 4)
|
|||
|
|
{
|
|||
|
|
for (uint8 l = 0; l < 13; l++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[3] = m_cbCardData[l];
|
|||
|
|
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbMaxCardData = 0;
|
|||
|
|
uint8 cbBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, cbMaxCardData, cbBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if (iCardType == 0) continue;
|
|||
|
|
|
|||
|
|
if ((dCardType&(1 << iCardType)) == 0)
|
|||
|
|
{
|
|||
|
|
dCardType = TransListToInt(dCardType, iCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbMaxCardData = 0;
|
|||
|
|
uint8 cbBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, cbMaxCardData, cbBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if (iCardType == 0) continue;
|
|||
|
|
|
|||
|
|
if ((dCardType&(1 << iCardType)) == 0)
|
|||
|
|
{
|
|||
|
|
dCardType = TransListToInt(dCardType, iCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbMaxCardData = 0;
|
|||
|
|
uint8 cbBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, cbMaxCardData, cbBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if (iCardType == 0) continue;
|
|||
|
|
|
|||
|
|
if ((dCardType&(1 << iCardType)) == 0)
|
|||
|
|
{
|
|||
|
|
dCardType = TransListToInt(dCardType, iCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbMaxCardData = 0;
|
|||
|
|
uint8 cbBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResult, bCardDataTemp, cbCardCount, cbMaxCardData, cbBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if (iCardType == 0) continue;
|
|||
|
|
|
|||
|
|
if ((dCardType&(1 << iCardType)) == 0)
|
|||
|
|
{
|
|||
|
|
dCardType = TransListToInt(dCardType, iCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return dCardType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD>
|
|||
|
|
int DZ_CGameLogic::GetType(tagDZAnalyseResult& AnalyseResult, const uint8 cbCardData[], uint8 cbCardCount, uint8& cbMaxCardData, uint8 &cbBlockCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ;
|
|||
|
|
cbMaxCardData = 0x0;
|
|||
|
|
cbBlockCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
switch (cbCardCount)
|
|||
|
|
{
|
|||
|
|
case 0: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
case 1: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = cbCardData[0];
|
|||
|
|
return DZ_CT_SINGLE;
|
|||
|
|
}
|
|||
|
|
case 2: //<2F><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
//if ((cbCardData[0]==0x4F)&&(cbCardData[1]==0x4E)) return TransListToInt(0,DZ_CT_MISSILE_CARD);
|
|||
|
|
if (GetCardLogicValue(cbCardData[0]) == GetCardLogicValue(cbCardData[1]))
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = cbCardData[0];
|
|||
|
|
return DZ_CT_DOUBLE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (GetCardLogicValue(cbCardData[0]) != GetCardLogicValue(cbCardData[1]))
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[0]) || IsLaiZiCard(cbCardData[1]))
|
|||
|
|
{
|
|||
|
|
if ((cbCardData[0] != 0x4F) && (cbCardData[0] != 0x4E) && (cbCardData[0] != 0x4F) && (cbCardData[1] != 0x4E))
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = cbCardData[cbCardCount - 1];
|
|||
|
|
|
|||
|
|
return DZ_CT_DOUBLE;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
case 4: //<2F><>ը;
|
|||
|
|
{
|
|||
|
|
if ((cbCardData[0] == 0x4F) && (cbCardData[1] == 0x4F) && (cbCardData[2] == 0x4E) && (cbCardData[3] == 0x4E))
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = cbCardData[0];
|
|||
|
|
return DZ_CT_BOMB_8;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[BLOCK_ONE] >= 5) && (AnalyseResult.cbBlockCount[BLOCK_ONE] == cbCardCount))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbFirstLogicValue = GetCardLogicValue(AnalyseResult.cbCardData[BLOCK_ONE][0]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbFirstLogicValue > 14) return DZ_CT_ERROR;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
for (uint8 i = 1; i < AnalyseResult.cbBlockCount[BLOCK_ONE]; i++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCardData = AnalyseResult.cbCardData[BLOCK_ONE][i];
|
|||
|
|
if (cbFirstLogicValue != (GetCardLogicValue(cbTmpCardData) + i))
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbMaxCardData = cbCardData[0];
|
|||
|
|
|
|||
|
|
return DZ_CT_SINGLE_LINE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[BLOCK_TWO] >= 2) && (AnalyseResult.cbBlockCount[BLOCK_TWO]*2 == cbCardCount))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbFirstLogicValue = GetCardLogicValue(AnalyseResult.cbCardData[BLOCK_TWO][0]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbFirstLogicValue > 14) return DZ_CT_ERROR;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
for (uint8 i = 1; i < AnalyseResult.cbBlockCount[BLOCK_TWO]; i++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCardData = AnalyseResult.cbCardData[BLOCK_TWO][i * 2];
|
|||
|
|
if (cbFirstLogicValue != (GetCardLogicValue(cbTmpCardData) + i))
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[BLOCK_TWO] * 2) == cbCardCount)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = cbCardData[0];
|
|||
|
|
return DZ_CT_DOUBLE_LINE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>DZ_CT_ERROR;
|
|||
|
|
for (int i = BLOCK_FIVE; i <= BLOCK_TWELVE; i++)
|
|||
|
|
{
|
|||
|
|
if (AnalyseResult.cbBlockCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (AnalyseResult.cbBlockCount[BLOCK_THREE] == 1 && cbCardCount == 5)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[BLOCK_THREE][0];
|
|||
|
|
return DZ_CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (isLastCard && AnalyseResult.cbBlockCount[BLOCK_THREE] == 1 && cbCardCount <= 5)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[BLOCK_THREE][0];
|
|||
|
|
return DZ_CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[BLOCK_FOUR] == 1) && (cbCardCount == 5))
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[BLOCK_FOUR][0];
|
|||
|
|
return DZ_CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (isLastCard && AnalyseResult.cbBlockCount[BLOCK_FOUR] == 1 && cbCardCount <= 5)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[BLOCK_FOUR][0];
|
|||
|
|
return DZ_CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[BLOCK_THREE] + AnalyseResult.cbBlockCount[BLOCK_FOUR] > 1)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>;
|
|||
|
|
if (!isLastCard && (cbCardCount % 5 != 0)) return DZ_CT_ERROR;
|
|||
|
|
uint8 cbCardType = DZ_CT_ERROR;
|
|||
|
|
|
|||
|
|
uint8 cbLineCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbLineLength = 0;
|
|||
|
|
|
|||
|
|
// Ŀǰֻ<C7B0><D6BB>3ȡ<33><C8A1>5<EFBFBD><35><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>(<28><>3<EFBFBD><33>5<EFBFBD><35><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>Ʒŵ<C6B7>ͬһ<CDAC><D2BB><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>);
|
|||
|
|
for (uint8 i = BLOCK_THREE; i <= BLOCK_FOUR; i++)
|
|||
|
|
{
|
|||
|
|
if (AnalyseResult.cbBlockCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 j = 0; j < AnalyseResult.cbBlockCount[i]; j++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCardDate = AnalyseResult.cbCardData[i][j*(i + 1)];
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>2;
|
|||
|
|
if (GetCardLogicValue(cbTmpCardDate) > 14) continue;
|
|||
|
|
|
|||
|
|
cbLineCardData[cbLineLength] = cbTmpCardDate;
|
|||
|
|
cbLineLength++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbLineCardData, cbLineLength, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
uint8 cbLastValue = GetCardLogicValue(cbLineCardData[0]);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(3~A)
|
|||
|
|
if (cbLastValue > 14) return DZ_CT_ERROR;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbMaxThreeLength = 1;
|
|||
|
|
uint8 cbThreeLength = 1;
|
|||
|
|
uint8 cbMaxThreeCardData = cbLineCardData[0];
|
|||
|
|
|
|||
|
|
for (uint8 i = 1; i < cbLineLength; i++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpValue = GetCardLogicValue(cbLineCardData[i]);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbLastValue != (cbTmpValue + 1))
|
|||
|
|
{
|
|||
|
|
if (cbMaxThreeLength < cbThreeLength)
|
|||
|
|
{
|
|||
|
|
cbMaxThreeLength = cbThreeLength;
|
|||
|
|
cbMaxThreeCardData = cbLineCardData[i - cbMaxThreeLength];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbThreeLength = 1;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbThreeLength++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbLastValue = cbTmpValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
if (cbMaxThreeLength < cbThreeLength)
|
|||
|
|
{
|
|||
|
|
cbMaxThreeLength = cbThreeLength;
|
|||
|
|
cbMaxThreeCardData = cbLineCardData[cbLineLength - cbMaxThreeLength];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
if (isLastCard && (cbMaxThreeLength * 5 >= cbCardCount))
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbMaxThreeLength;
|
|||
|
|
cbMaxCardData = cbMaxThreeCardData;
|
|||
|
|
cbCardType = DZ_CT_THREE_LINE;
|
|||
|
|
}
|
|||
|
|
else if (!isLastCard)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>㼸<EFBFBD><E3BCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbTmpBlockCount = cbCardCount / 5;
|
|||
|
|
if ((cbTmpBlockCount * 5 == cbCardCount) && (cbMaxThreeLength >= cbTmpBlockCount))
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbTmpBlockCount;
|
|||
|
|
cbMaxCardData = cbMaxThreeCardData;
|
|||
|
|
cbCardType = DZ_CT_THREE_LINE;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbCardType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return DZ_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void DZ_CGameLogic::SortCardList(uint8 cbCardData[], uint8 cbCardCount, uint8 cbSortType)
|
|||
|
|
{
|
|||
|
|
//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount == 0) return;
|
|||
|
|
|
|||
|
|
if (cbSortType == DZ_ST_ORDER)
|
|||
|
|
{
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
BYTE cbSortValue[DZ_MAX_COUNT];
|
|||
|
|
for (BYTE i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbSortValue[i] = GetCardLogicValue(cbCardData[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool bSorted = true;
|
|||
|
|
uint8 cbSwitchData = 0, cbLast = cbCardCount - 1;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
bSorted = true;
|
|||
|
|
for (uint8 i = 0; i < cbLast; i++)
|
|||
|
|
{
|
|||
|
|
if ((cbSortValue[i] < cbSortValue[i + 1]) ||
|
|||
|
|
((cbSortValue[i] == cbSortValue[i + 1]) && (cbCardData[i] < cbCardData[i + 1])))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD>־
|
|||
|
|
bSorted = false;
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbSwitchData = cbCardData[i];
|
|||
|
|
cbCardData[i] = cbCardData[i + 1];
|
|||
|
|
cbCardData[i + 1] = cbSwitchData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>Ȩλ
|
|||
|
|
cbSwitchData = cbSortValue[i];
|
|||
|
|
cbSortValue[i] = cbSortValue[i + 1];
|
|||
|
|
cbSortValue[i + 1] = cbSwitchData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
cbLast--;
|
|||
|
|
} while (bSorted == false);
|
|||
|
|
}
|
|||
|
|
//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
|||
|
|
else if (cbSortType == DZ_ST_COUNT)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardIndex = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZAnalyseResult AnalyseResult;
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
AnalysebCardData(&cbCardData[cbCardIndex], cbCardCount - cbCardIndex, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 i = 0; i < CountArray(AnalyseResult.cbBlockCount); i++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbIndex = CountArray(AnalyseResult.cbBlockCount) - i - 1;
|
|||
|
|
CopyMemory(&cbCardData[cbCardIndex], AnalyseResult.cbCardData[cbIndex], AnalyseResult.cbBlockCount[cbIndex] * (cbIndex + 1)*sizeof(uint8));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbCardIndex += AnalyseResult.cbBlockCount[cbIndex] * (cbIndex + 1)*sizeof(uint8);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void DZ_CGameLogic::RandCardList(uint8 cbCardBuffer[], uint8 cbBufferCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
uint8 cbCardData[CountArray(m_cbCardData)];
|
|||
|
|
CopyMemory(cbCardData,m_cbCardData,sizeof(m_cbCardData));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbRandCount=0,cbPosition=0;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
cbPosition=rand()%(cbBufferCount-cbRandCount);
|
|||
|
|
cbCardBuffer[cbRandCount++]=cbCardData[cbPosition];
|
|||
|
|
cbCardData[cbPosition]=cbCardData[cbBufferCount-cbRandCount];
|
|||
|
|
} while (cbRandCount<cbBufferCount);
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void DZ_CGameLogic::RandNoJokerCardList(uint8 cbCardBuffer[], uint8 cbBufferCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
uint8 cbCardData[CountArray(m_cbNoJokerCardData)];
|
|||
|
|
CopyMemory(cbCardData, m_cbNoJokerCardData, sizeof(m_cbNoJokerCardData));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbRandCount = 0, cbPosition = 0;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
cbPosition = rand() % (cbBufferCount - cbRandCount);
|
|||
|
|
cbCardBuffer[cbRandCount++] = cbCardData[cbPosition];
|
|||
|
|
cbCardData[cbPosition] = cbCardData[cbBufferCount - cbRandCount];
|
|||
|
|
} while (cbRandCount < cbBufferCount);
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
bool DZ_CGameLogic::RemoveCard(const uint8 cbRemoveCard[], uint8 cbRemoveCount, uint8 cbCardData[], uint8 cbCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(cbRemoveCount<=cbCardCount);
|
|||
|
|
if(cbRemoveCount>cbCardCount)
|
|||
|
|
return false ;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbDeleteCount=0,cbTempCardData[DZ_MAX_COUNT];
|
|||
|
|
if (cbCardCount>CountArray(cbTempCardData)) return false;
|
|||
|
|
CopyMemory(cbTempCardData,cbCardData,cbCardCount*sizeof(cbCardData[0]));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 i=0;i<cbRemoveCount;i++)
|
|||
|
|
{
|
|||
|
|
for (uint8 j=0;j<cbCardCount;j++)
|
|||
|
|
{
|
|||
|
|
if (cbRemoveCard[i]==cbTempCardData[j])
|
|||
|
|
{
|
|||
|
|
cbDeleteCount++;
|
|||
|
|
cbTempCardData[j]=0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (cbDeleteCount!=cbRemoveCount) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
zeromemory(cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
|
|||
|
|
uint8 cbCardPos=0;
|
|||
|
|
for (uint8 i=0;i<cbCardCount;i++)
|
|||
|
|
{
|
|||
|
|
if (cbTempCardData[i]!=0) cbCardData[cbCardPos++]=cbTempCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ч<EFBFBD>ж<EFBFBD>
|
|||
|
|
bool DZ_CGameLogic::IsValidCard(uint8 cbCardData)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardColor=GetCardColor(cbCardData);
|
|||
|
|
uint8 cbCardValue=GetCardValue(cbCardData);
|
|||
|
|
|
|||
|
|
//<2F><>Ч<EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((cbCardData==0x4E)||(cbCardData==0x4F)) return true;
|
|||
|
|
if ((cbCardColor<=0x30)&&(cbCardValue>=0x01)&&(cbCardValue<=0x0D)) return true;
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><EFBFBD><DFBC><EFBFBD>ֵ
|
|||
|
|
uint8 DZ_CGameLogic::GetCardLogicValue(uint8 cbCardData)
|
|||
|
|
{
|
|||
|
|
if (!IsValidCard(cbCardData)) return 0;
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardColor=GetCardColor(cbCardData);
|
|||
|
|
uint8 cbCardValue=GetCardValue(cbCardData);
|
|||
|
|
|
|||
|
|
//#ifdef _DEBUG
|
|||
|
|
// if(cbCardValue<=0 || cbCardValue>(DZ_MASK_VALUE&0x4f))
|
|||
|
|
// return 0 ;
|
|||
|
|
//#endif
|
|||
|
|
|
|||
|
|
ASSERT(cbCardValue>0 && cbCardValue <= (DZ_MASK_VALUE & 0x4f));
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
if (cbCardColor==0x40) return cbCardValue+2;
|
|||
|
|
|
|||
|
|
return (cbCardValue<=2)?(cbCardValue+13):cbCardValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
bool DZ_CGameLogic::CompareCard(const DZ_CMD_C_OutCard* pFirstOutCard, const DZ_CMD_C_OutCard* pNextOutCard)
|
|||
|
|
{
|
|||
|
|
if (pFirstOutCard == nullptr || pNextOutCard == nullptr) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
int cbFirstType = pFirstOutCard->cbCardType;
|
|||
|
|
int cbNextType = pNextOutCard->cbCardType;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbNextType == DZ_CT_ERROR) return false;
|
|||
|
|
|
|||
|
|
uint8 cbFirstCount = pFirstOutCard->cbCardCount;
|
|||
|
|
uint8 cbNextCount = pNextOutCard->cbCardCount;
|
|||
|
|
bool isFirstLastCard = pFirstOutCard->isLastCard;
|
|||
|
|
bool isNextLastCard = pNextOutCard->isLastCard;
|
|||
|
|
|
|||
|
|
uint8 cbFirstCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbNextCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(cbFirstCard, pFirstOutCard->cbCardData, sizeof(uint8)*cbFirstCount);
|
|||
|
|
CopyMemory(cbNextCard, pNextOutCard->cbCardData, sizeof(uint8)*cbNextCount);
|
|||
|
|
|
|||
|
|
//ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int cbTmpFirstType = (cbFirstType >> DZ_CT_BOMB_4);
|
|||
|
|
int cbTmpNextType = (cbNextType >> DZ_CT_BOMB_4);
|
|||
|
|
|
|||
|
|
if (cbTmpFirstType > 0 || cbTmpNextType > 0)
|
|||
|
|
{
|
|||
|
|
// <20><>ǰ<EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>ը<EFBFBD><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B2BBB5><EFBFBD>һ<EFBFBD><D2BB>ը<EFBFBD><D5A8><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpNextType < 0) return false;
|
|||
|
|
//if (cbTmpFirstType > 0) return true;
|
|||
|
|
|
|||
|
|
//<2F>Ǽ<EFBFBD><C7BC>Ƚ<EFBFBD>
|
|||
|
|
if (cbTmpFirstType != cbTmpNextType)
|
|||
|
|
{
|
|||
|
|
return cbTmpNextType > cbTmpFirstType;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// ȡ<><C8A1><EFBFBD><EFBFBD>һ<EFBFBD>ţ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3>Ǿ<EFBFBD><C7BE><EFBFBD>4<EFBFBD><34>ը;
|
|||
|
|
uint8 cbConsultNext = GetCardLogicValue(cbNextCard[cbNextCount - 1]);
|
|||
|
|
uint8 cbConsultFirst = GetCardLogicValue(cbFirstCard[cbFirstCount - 1]);
|
|||
|
|
|
|||
|
|
return cbConsultNext > cbConsultFirst;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>
|
|||
|
|
if (cbFirstType != cbNextType) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
uint8 cbNextLogicValue = 0;
|
|||
|
|
uint8 cbFirstLogicValue = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 NextResult[DZ_CT_COUNT] = {0};
|
|||
|
|
uint8 FirstResult[DZ_CT_COUNT] = { 0 };
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
if ((cbNextType&(1 << DZ_CT_SINGLE)) != 0 && cbFirstCount == cbNextCount)
|
|||
|
|
{
|
|||
|
|
if (cbFirstCount != 1) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(cbNextCard[0]);
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(cbFirstCard[0]);
|
|||
|
|
|
|||
|
|
if (cbNextLogicValue > cbFirstLogicValue) return true;
|
|||
|
|
}
|
|||
|
|
else if ((cbNextType&(1 << DZ_CT_DOUBLE)) != 0 && cbFirstCount == cbNextCount)
|
|||
|
|
{
|
|||
|
|
if (cbFirstCount != 2) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(cbNextCard[1]);
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(cbFirstCard[1]);
|
|||
|
|
|
|||
|
|
if (cbNextLogicValue > cbFirstLogicValue) return true;
|
|||
|
|
}
|
|||
|
|
else if ((cbNextType&(1 << DZ_CT_THREE_TAKE_TWO)) != 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (cbFirstCount < 3 || cbFirstCount > 5) return false;
|
|||
|
|
if (cbNextCount < 3 || cbNextCount > 5) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><35>;
|
|||
|
|
if (!isFirstLastCard && cbFirstCount != 5) return false;
|
|||
|
|
if (!isNextLastCard && cbNextCount != 5) return false;
|
|||
|
|
|
|||
|
|
uint8 cbNextBlockCount = 0, cbFirstBlockCount = 0;
|
|||
|
|
if (!AnalysebCompare(cbNextCard, cbNextCount, NextResult, cbNextBlockCount, DZ_CT_THREE_TAKE_TWO, isNextLastCard))return false;
|
|||
|
|
if (!AnalysebCompare(cbFirstCard, cbFirstCount, FirstResult, cbFirstBlockCount, DZ_CT_THREE_TAKE_TWO, isFirstLastCard))return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(NextResult[DZ_CT_THREE_TAKE_TWO]);
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(FirstResult[DZ_CT_THREE_TAKE_TWO]);
|
|||
|
|
|
|||
|
|
if (cbNextLogicValue > cbFirstLogicValue) return true;
|
|||
|
|
}
|
|||
|
|
else if ((cbNextType&(1 << DZ_CT_SINGLE_LINE)) != 0 && cbFirstCount == cbNextCount)
|
|||
|
|
{
|
|||
|
|
if (cbFirstCount < 5) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(cbNextCard[cbNextCount - 1]);
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(cbFirstCard[cbFirstCount - 1]);
|
|||
|
|
|
|||
|
|
if (cbNextLogicValue > cbFirstLogicValue) return true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if ((cbNextType&(1 << DZ_CT_DOUBLE_LINE)) != 0 && cbFirstCount == cbNextCount)
|
|||
|
|
{
|
|||
|
|
if ((cbFirstCount < 4) || (cbFirstCount%2)!=0) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(cbNextCard[cbNextCount - 1]);
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(cbFirstCard[cbFirstCount - 1]);
|
|||
|
|
|
|||
|
|
if (cbNextLogicValue > cbFirstLogicValue) return true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if ((cbNextType&(1 << DZ_CT_THREE_LINE)) != 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (cbFirstCount < 6 || cbNextCount < 6) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>;
|
|||
|
|
if (!isFirstLastCard && (cbFirstCount%5) != 0) return false;
|
|||
|
|
if (!isNextLastCard && (cbNextCount%5) != 0) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ;
|
|||
|
|
if (!isFirstLastCard &&!isNextLastCard && (cbNextCount != cbFirstCount)) return false;
|
|||
|
|
|
|||
|
|
uint8 cbNextBlockCount = 0, cbFirstBlockCount = 0;
|
|||
|
|
if (!AnalysebCompare(cbNextCard, cbNextCount, NextResult, cbNextBlockCount, DZ_CT_THREE_LINE, isNextLastCard))return false;
|
|||
|
|
if (!AnalysebCompare(cbFirstCard, cbFirstCount, FirstResult, cbFirstBlockCount, DZ_CT_THREE_LINE, isFirstLastCard))return false;
|
|||
|
|
|
|||
|
|
if (cbNextBlockCount != cbFirstBlockCount) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(NextResult[DZ_CT_THREE_LINE]);
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(FirstResult[DZ_CT_THREE_LINE]);
|
|||
|
|
|
|||
|
|
if (cbNextLogicValue > cbFirstLogicValue) return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|||
|
|
uint8 DZ_CGameLogic::GetLaiZiCount(const uint8 cbHandCardData[], uint8 cbHandCardCount)
|
|||
|
|
{
|
|||
|
|
uint8 bLaiZiCount=0;
|
|||
|
|
for(uint8 i=0;i<cbHandCardCount;i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbHandCardData[i]))
|
|||
|
|
bLaiZiCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return bLaiZiCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool DZ_CGameLogic::IsLaiZiCard(uint8 cbCard)
|
|||
|
|
{
|
|||
|
|
ASSERT(IsValidCard(cbCard));
|
|||
|
|
|
|||
|
|
if (0x40 == GetCardColor(cbCard))
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void DZ_CGameLogic::AnalysebCardData(const uint8 cbCardData[], uint8 cbCardCount, tagDZAnalyseResult & AnalyseResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
uint8 cbTmpCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(cbTmpCardData, cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
|
|||
|
|
SortCardList(cbTmpCardData, cbCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F>˿˷<CBBF><CBB7><EFBFBD>
|
|||
|
|
for (uint8 i=0;i<cbCardCount;i++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbSameCount=1,cbCardValueTemp=0;
|
|||
|
|
uint8 cbLogicValue = GetCardLogicValue(cbTmpCardData[i]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
|||
|
|
for (uint8 j=i+1;j<cbCardCount;j++)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD>˿<EFBFBD>
|
|||
|
|
if (GetCardLogicValue(cbTmpCardData[j]) != cbLogicValue) break;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
cbSameCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
uint8 cbIndex = AnalyseResult.cbBlockCount[cbSameCount - 1]++;
|
|||
|
|
for (uint8 j = 0; j < cbSameCount; j++)
|
|||
|
|
{
|
|||
|
|
AnalyseResult.cbCardData[cbSameCount - 1][cbIndex*cbSameCount + j] = cbTmpCardData[i + j];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
i+=cbSameCount-1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD>
|
|||
|
|
bool DZ_CGameLogic::AnalysebCompare(const uint8 cbCardData[], uint8 cbCardCount, uint8 cbMaxCardData[DZ_CT_COUNT], uint8 &cbBlockCount, int dCardType, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
cbBlockCount = 0;
|
|||
|
|
zeromemory(cbMaxCardData, sizeof(cbMaxCardData));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCardCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int dCardTypeTemp = DZ_CT_ERROR;
|
|||
|
|
dCardTypeTemp = (1 << dCardType);
|
|||
|
|
|
|||
|
|
// û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount == 0)
|
|||
|
|
{
|
|||
|
|
uint8 bCardDataTemp[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(bCardDataTemp, cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZAnalyseResult AnalyseResultTemp;
|
|||
|
|
zeromemory(&AnalyseResultTemp, sizeof(AnalyseResultTemp));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResultTemp);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbTmpMaxCardData = 0, cbTmpBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, cbTmpMaxCardData, cbTmpBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if ((dCardTypeTemp&(1 << iCardType)) != 0)
|
|||
|
|
{
|
|||
|
|
//AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
if (cbMaxCardData[iCardType] < cbTmpMaxCardData)
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbTmpBlockCount;
|
|||
|
|
cbMaxCardData[iCardType] = cbTmpMaxCardData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (cbMagicCardCount >= 1)
|
|||
|
|
{
|
|||
|
|
tagDZAnalyseResult AnalyseResultTemp;
|
|||
|
|
zeromemory(&AnalyseResultTemp, sizeof(AnalyseResultTemp));
|
|||
|
|
|
|||
|
|
uint8 bCardDataTemp[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(&bCardDataTemp[cbMagicCardCount], cbNormalCard, sizeof(uint8)*cbNormalCardCount);
|
|||
|
|
|
|||
|
|
for (uint8 i = 0; i < 13; i++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[0] = m_cbCardData[i];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbMagicCardCount >= 2)
|
|||
|
|
{
|
|||
|
|
for (uint8 z = 0; z < 13; z++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[1] = m_cbCardData[z];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbMagicCardCount >= 3)
|
|||
|
|
{
|
|||
|
|
for (uint8 f = 0; f < 13; f++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[2] = m_cbCardData[f];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbMagicCardCount == 4)
|
|||
|
|
{
|
|||
|
|
for (uint8 l = 0; l < 13; l++)
|
|||
|
|
{
|
|||
|
|
bCardDataTemp[3] = m_cbCardData[l];
|
|||
|
|
|
|||
|
|
zeromemory(&AnalyseResultTemp, sizeof(AnalyseResultTemp));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResultTemp);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbTmpMaxCardData = 0, cbTmpBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, cbTmpMaxCardData, cbTmpBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if ((dCardTypeTemp&(1 << iCardType)) != 0)
|
|||
|
|
{
|
|||
|
|
//AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
//if (cbMaxCardData[iCardType] < cbTmpMaxCardData)
|
|||
|
|
if (GetCardLogicValue(cbMaxCardData[iCardType]) < GetCardLogicValue(cbTmpMaxCardData))
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbTmpBlockCount;
|
|||
|
|
cbMaxCardData[iCardType] = cbTmpMaxCardData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
zeromemory(&AnalyseResultTemp, sizeof(AnalyseResultTemp));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResultTemp);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbTmpMaxCardData = 0, cbTmpBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, cbTmpMaxCardData, cbTmpBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if ((dCardTypeTemp&(1 << iCardType)) != 0)
|
|||
|
|
{
|
|||
|
|
//AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
//if (cbMaxCardData[iCardType] < cbTmpMaxCardData)
|
|||
|
|
if (GetCardLogicValue(cbMaxCardData[iCardType]) < GetCardLogicValue(cbTmpMaxCardData))
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbTmpBlockCount;
|
|||
|
|
cbMaxCardData[iCardType] = cbTmpMaxCardData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
zeromemory(&AnalyseResultTemp, sizeof(AnalyseResultTemp));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResultTemp);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbTmpMaxCardData = 0, cbTmpBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, cbTmpMaxCardData, cbTmpBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if ((dCardTypeTemp&(1 << iCardType)) != 0)
|
|||
|
|
{
|
|||
|
|
//AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
//if (cbMaxCardData[iCardType] < cbTmpMaxCardData)
|
|||
|
|
if (GetCardLogicValue(cbMaxCardData[iCardType]) < GetCardLogicValue(cbTmpMaxCardData))
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbTmpBlockCount;
|
|||
|
|
cbMaxCardData[iCardType] = cbTmpMaxCardData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
zeromemory(&AnalyseResultTemp, sizeof(AnalyseResultTemp));
|
|||
|
|
|
|||
|
|
AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResultTemp);
|
|||
|
|
|
|||
|
|
//int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, isLastCard);
|
|||
|
|
uint8 cbTmpMaxCardData = 0, cbTmpBlockCount = 0;
|
|||
|
|
int iCardType = GetType(AnalyseResultTemp, bCardDataTemp, cbCardCount, cbTmpMaxCardData, cbTmpBlockCount, isLastCard);
|
|||
|
|
|
|||
|
|
if ((dCardTypeTemp&(1 << iCardType)) != 0)
|
|||
|
|
{
|
|||
|
|
//AnalysebCardData(bCardDataTemp, cbCardCount, AnalyseResult);
|
|||
|
|
//if (cbMaxCardData[iCardType] < cbTmpMaxCardData)
|
|||
|
|
if (GetCardLogicValue(cbMaxCardData[iCardType]) < GetCardLogicValue(cbTmpMaxCardData))
|
|||
|
|
{
|
|||
|
|
cbBlockCount = cbTmpBlockCount;
|
|||
|
|
cbMaxCardData[iCardType] = cbTmpMaxCardData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 DZ_CGameLogic::GetRandomCard(void)
|
|||
|
|
{
|
|||
|
|
size_t cbIndex = rand()%(sizeof(m_cbCardData)) ;
|
|||
|
|
return m_cbCardData[cbIndex] ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void DZ_CGameLogic::SortOutCardList(uint8 cbCardData[], uint8 cbCardCount, int nCardType, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>(<28><>32<33><32><EFBFBD>Ƶ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊһ<CEAA><D2BB>32λ<32><CEBB><EFBFBD><EFBFBD>)
|
|||
|
|
int DZ_CGameLogic::TransListToInt(int iOldType,int iNewType)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
|||
|
|
if(iNewType == 0) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int nList = 0;
|
|||
|
|
ASSERT(iNewType != -1);
|
|||
|
|
nList |= (1<<iNewType);
|
|||
|
|
|
|||
|
|
return iOldType|nList;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool DZ_CGameLogic::IsHasCardType(int iCardType, CART_TYPE ct_value)
|
|||
|
|
{
|
|||
|
|
if (iCardType == DZ_CT_ERROR) return false;
|
|||
|
|
|
|||
|
|
return ((iCardType&(1 << ct_value)) != 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Dz<EFBFBD><C7B2><EFBFBD>ը<EFBFBD><D5A8>;
|
|||
|
|
bool DZ_CGameLogic::IsBombType(int iCardType)
|
|||
|
|
{
|
|||
|
|
return ((iCardType >> DZ_CT_BOMB_4) > 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>
|
|||
|
|
void DZ_CGameLogic::AnalysebDistributing(const uint8 cbCardData[], uint8 cbCardCount, tagDZDistributing & Distributing)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
zeromemory(&Distributing, sizeof(tagDZDistributing));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (cbCardData[i] == 0) continue;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardColor = GetCardColor(cbCardData[i]);
|
|||
|
|
//uint8 cbCardValue = GetCardValue(cbCardData[i]);
|
|||
|
|
uint8 cbCardValue = GetCardLogicValue(cbCardData[i]);
|
|||
|
|
|
|||
|
|
//<2F>ֲ<EFBFBD><D6B2><EFBFBD>Ϣ
|
|||
|
|
Distributing.cbCardCount++;
|
|||
|
|
Distributing.cbDistributing[cbCardValue][cbIndexCount]++;
|
|||
|
|
Distributing.cbDistributing[cbCardValue][cbCardColor >> 4]++;
|
|||
|
|
|
|||
|
|
//Distributing.cbDistributing[cbCardValue - 1][cbIndexCount]++;
|
|||
|
|
//Distributing.cbDistributing[cbCardValue - 1][cbCardColor >> 4]++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 DZ_CGameLogic::SearchOutCard(const uint8 cbHandCardData[], uint8 cbHandCardCount, const DZ_CMD_C_OutCard* pFirstOutCard, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
assert(pSearchCardResult != nullptr);
|
|||
|
|
if (pSearchCardResult == nullptr || pFirstOutCard == nullptr) return 0;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
int cbTurnOutType = pFirstOutCard->cbCardType;
|
|||
|
|
if (cbTurnOutType == DZ_CT_ERROR) return 0;
|
|||
|
|
|
|||
|
|
uint8 cbTurnCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbTurnCardCount = pFirstOutCard->cbCardCount;
|
|||
|
|
CopyMemory(cbTurnCardData, pFirstOutCard->cbCardData, sizeof(uint8)*cbTurnCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
tagDZSearchCardResult tmpSearchCardResult = {};
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
SortCardList(cbCardData, cbCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F>Ƿ<EFBFBD>һ<EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>
|
|||
|
|
int iLastCardType = GetCardType(cbCardData, cbCardCount, true);
|
|||
|
|
if (iLastCardType != DZ_CT_ERROR)
|
|||
|
|
{
|
|||
|
|
DZ_CMD_C_OutCard tmpOutCard;
|
|||
|
|
zeromemory(&tmpOutCard, sizeof(DZ_CMD_C_OutCard));
|
|||
|
|
tmpOutCard.isLastCard = true;
|
|||
|
|
tmpOutCard.cbCardCount = cbHandCardCount;
|
|||
|
|
tmpOutCard.cbCardType = iLastCardType;
|
|||
|
|
CopyMemory(tmpOutCard.cbCardData, cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
|
|||
|
|
if (CompareCard(pFirstOutCard, &tmpOutCard) == true)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCardCount;
|
|||
|
|
memcpy(pSearchCardResult->cbResultCard[cbResultCount], cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>;
|
|||
|
|
if (IsHasCardType(cbTurnOutType, DZ_CT_SINGLE))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
cbResultCount = SearchSingle(cbCardData, cbCardCount, cbReferCard, pSearchCardResult);
|
|||
|
|
}
|
|||
|
|
else if (IsHasCardType(cbTurnOutType, DZ_CT_DOUBLE))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
cbResultCount = SearchDouble(cbCardData, cbCardCount, cbReferCard, pSearchCardResult);
|
|||
|
|
}
|
|||
|
|
else if (IsHasCardType(cbTurnOutType, DZ_CT_SINGLE_LINE))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
cbResultCount = SearchSingleLine(cbCardData, cbCardCount, cbReferCard, cbTurnCardCount, pSearchCardResult);
|
|||
|
|
}
|
|||
|
|
else if (IsHasCardType(cbTurnOutType, DZ_CT_DOUBLE_LINE))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
uint8 cbLineCount = cbTurnCardCount / 2;
|
|||
|
|
cbResultCount = SearchDoubleLine(cbCardData, cbCardCount, cbReferCard, cbLineCount, pSearchCardResult);
|
|||
|
|
}
|
|||
|
|
else if (IsHasCardType(cbTurnOutType, DZ_CT_THREE_TAKE_TWO))
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount < 5) return cbResultCount;
|
|||
|
|
|
|||
|
|
uint8 cbFirstLogicValue = 0, cbBlockCount = 0;
|
|||
|
|
uint8 FirstResult[DZ_CT_COUNT] = { 0 };
|
|||
|
|
if (!AnalysebCompare(cbTurnCardData, cbTurnCardCount, FirstResult, cbBlockCount, DZ_CT_THREE_TAKE_TWO, pFirstOutCard->isLastCard))return 0;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(FirstResult[DZ_CT_THREE_TAKE_TWO]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
cbResultCount = SearchThreeTakeTwo(cbCardData, cbCardCount, cbFirstLogicValue, pSearchCardResult);
|
|||
|
|
}
|
|||
|
|
else if (IsHasCardType(cbTurnOutType, DZ_CT_THREE_LINE))
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount < 6) return cbResultCount;
|
|||
|
|
|
|||
|
|
uint8 cbFirstLogicValue = 0;
|
|||
|
|
uint8 cbBlockCount = 0;
|
|||
|
|
uint8 FirstResult[DZ_CT_COUNT] = { 0 };
|
|||
|
|
if (!AnalysebCompare(cbTurnCardData, cbTurnCardCount, FirstResult, cbBlockCount, DZ_CT_THREE_LINE, pFirstOutCard->isLastCard))return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>);
|
|||
|
|
cbFirstLogicValue = (GetCardLogicValue(FirstResult[DZ_CT_THREE_LINE]) - cbBlockCount + 1);
|
|||
|
|
cbResultCount = SearchThreeLineTakeTwo(cbCardData, cbCardCount, cbFirstLogicValue, cbBlockCount, pSearchCardResult);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>
|
|||
|
|
if (cbCardCount >= 4)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
SearchBomb(cbCardData, cbCardCount, cbReferCard, cbTurnCardCount, cbTurnOutType, pSearchCardResult, cbResultCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>);
|
|||
|
|
uint8 DZ_CGameLogic::SearchSingle(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult) zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbCardData, cbCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD>ֵ;
|
|||
|
|
uint8 cbReferLogicValue = (cbReferCard == 0) ? 0 : GetCardLogicValue(cbReferCard);
|
|||
|
|
uint8 cbBlockIndex = BLOCK_ONE;
|
|||
|
|
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
for (uint8 i = 0; i < AnalyseResult.cbBlockCount[cbBlockIndex]; i++)
|
|||
|
|
{
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[cbBlockIndex] - i - 1)*(cbBlockIndex + 1);
|
|||
|
|
|
|||
|
|
if (GetCardLogicValue(AnalyseResult.cbCardData[cbBlockIndex][cbIndex]) > cbReferLogicValue)
|
|||
|
|
{
|
|||
|
|
if (pSearchCardResult == NULL) return 1;
|
|||
|
|
|
|||
|
|
assert(cbResultCount < CountArray(pSearchCardResult->cbCardCount));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
memcpy(pSearchCardResult->cbResultCard[cbResultCount], &AnalyseResult.cbCardData[cbBlockIndex][cbIndex], sizeof(uint8));
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = 1;
|
|||
|
|
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbBlockIndex++;
|
|||
|
|
|
|||
|
|
} while (cbBlockIndex < CountArray(AnalyseResult.cbBlockCount));
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 DZ_CGameLogic::SearchDouble(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult) zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbCardData, cbCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD>ֵ;
|
|||
|
|
uint8 cbReferLogicValue = (cbReferCard == 0) ? 0 : GetCardLogicValue(cbReferCard);
|
|||
|
|
uint8 cbBlockIndex = BLOCK_TWO;
|
|||
|
|
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
for (uint8 i = 0; i < AnalyseResult.cbBlockCount[cbBlockIndex]; i++)
|
|||
|
|
{
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[cbBlockIndex] - i - 1)*(cbBlockIndex + 1);
|
|||
|
|
|
|||
|
|
if (GetCardLogicValue(AnalyseResult.cbCardData[cbBlockIndex][cbIndex]) > cbReferLogicValue)
|
|||
|
|
{
|
|||
|
|
if (pSearchCardResult == NULL) return 1;
|
|||
|
|
|
|||
|
|
assert(cbResultCount < CountArray(pSearchCardResult->cbCardCount));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
memcpy(pSearchCardResult->cbResultCard[cbResultCount], &AnalyseResult.cbCardData[cbBlockIndex][cbIndex], sizeof(uint8)*2);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = 2;
|
|||
|
|
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbBlockIndex++;
|
|||
|
|
|
|||
|
|
} while (cbBlockIndex < CountArray(AnalyseResult.cbBlockCount));
|
|||
|
|
|
|||
|
|
// һ<><D2BB><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>һ<EFBFBD>ŵ<EFBFBD><C5B5>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbMagicCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCard[cbMagicCardCount] = cbCardData[i];
|
|||
|
|
|
|||
|
|
cbMagicCardCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = 0; i < AnalyseResult.cbBlockCount[BLOCK_ONE]; i++)
|
|||
|
|
{
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[BLOCK_ONE] - i - 1);
|
|||
|
|
|
|||
|
|
if (IsLaiZiCard(AnalyseResult.cbCardData[BLOCK_ONE][cbIndex])) continue;
|
|||
|
|
|
|||
|
|
if (GetCardLogicValue(AnalyseResult.cbCardData[BLOCK_ONE][cbIndex]) > cbReferLogicValue)
|
|||
|
|
{
|
|||
|
|
if (pSearchCardResult == NULL) return 1;
|
|||
|
|
|
|||
|
|
assert(cbResultCount < CountArray(pSearchCardResult->cbCardCount));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][0] = cbMagicCard[cbMagicCardCount - 1];
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][1] = AnalyseResult.cbCardData[BLOCK_ONE][cbIndex];
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = 2;
|
|||
|
|
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳;
|
|||
|
|
uint8 DZ_CGameLogic::SearchSingleLine(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbLineCount, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
if (cbLineCount < 5) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
uint8 cbReferIndex = GetCardLogicValue(cbReferCard)+1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>A
|
|||
|
|
if (cbReferIndex + cbLineCount > GetCardLogicValue(0x01) + 1)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbHandCardCount < cbLineCount)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCard[cbMagicCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x01) - cbLineCount + 1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
uint8 cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
for (uint8 j = i; j <= GetCardLogicValue(0x01); j++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (Distributing.cbDistributing[j][cbIndexCount] < 1)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpLinkCount >= cbLineCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = MakeCardData(cbIndex, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 1) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 1) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
//for (uint8 cbMagic = 0; cbMagic < cbUseMagicCount; cbMagic++)
|
|||
|
|
//{
|
|||
|
|
// pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = cbMagicCard[cbMagic];
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
uint8 cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
for (uint8 j = i; j <= GetCardLogicValue(0x01); j++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (Distributing.cbDistributing[j][cbIndexCount] < 1)
|
|||
|
|
{
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount < cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
cbUseMagicCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpLinkCount >= cbLineCount)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3>Ͳ<EFBFBD><CDB2><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount <= 0) break;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = MakeCardData(cbIndex, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 1) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 1) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 cbMagic = 0; cbMagic < cbUseMagicCount; cbMagic++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = cbMagicCard[cbMagic];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˫˳;
|
|||
|
|
uint8 DZ_CGameLogic::SearchDoubleLine(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbLineCount, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
if (cbLineCount < 2) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
uint8 cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>A
|
|||
|
|
if (cbReferIndex + cbLineCount > GetCardLogicValue(0x01) + 1)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbHandCardCount < cbLineCount * 2)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCard[cbMagicCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x01) - cbLineCount + 1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
uint8 cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
for (uint8 j = i; j <= GetCardLogicValue(0x01); j++)
|
|||
|
|
{
|
|||
|
|
// <20><>2<EFBFBD><32><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[j][cbIndexCount] >= 2)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpLinkCount >= cbLineCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = MakeCardData(cbIndex, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 2) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 2) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
//for (uint8 cbMagic = 0; cbMagic < cbUseMagicCount; cbMagic++)
|
|||
|
|
//{
|
|||
|
|
// pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = cbMagicCard[cbMagic];
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
uint8 cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
for (uint8 j = i; j <= GetCardLogicValue(0x01); j++)
|
|||
|
|
{
|
|||
|
|
// <20><>2<EFBFBD><32><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[j][cbIndexCount] >= 2)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
}
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB>;
|
|||
|
|
else if (Distributing.cbDistributing[j][cbIndexCount] == 1)
|
|||
|
|
{
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount < cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
cbUseMagicCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// һ<>Ŷ<EFBFBD>û<EFBFBD><C3BB>;
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount + 2 <= cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
cbUseMagicCount += 2;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpLinkCount >= cbLineCount)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3>Ͳ<EFBFBD><CDB2><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount <= 0) break;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = MakeCardData(cbIndex, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 2) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 2) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 cbMagic = 0; cbMagic < cbUseMagicCount; cbMagic++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = cbMagicCard[cbMagic];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 DZ_CGameLogic::SearchThreeTakeTwo(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount < 5) return 0;
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
uint8 cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
if (cbReferIndex > GetCardLogicValue(0x02)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCard[cbMagicCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD>ͬ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>;
|
|||
|
|
if (GetCardLogicValue(cbNormalCard[0]) == GetCardLogicValue(cbNormalCard[cbNormalCardCount - 1]))
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbNormalCard, cbNormalCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
uint8 cbMinIndex = 0x03;
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x02);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
// û<>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == 0) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == 3)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ҵ<EFBFBD><D2B4>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
uint8 cbTakeCard[5] = {0};
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (uint8 j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (uint8 k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[j] - k - 1)*(j + 1);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>;
|
|||
|
|
if (i == GetCardLogicValue(AnalyseResult.cbCardData[j][cbIndex]))
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 n = 0; n < j+1; n++)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = AnalyseResult.cbCardData[j][cbIndex + n];
|
|||
|
|
if (cbTmpCount == 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD>Ŵ<EFBFBD><C5B4>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpCount == 4 && cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = cbMagicCard[cbMagicCardCount - 1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 5)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTakeCard, sizeof(uint8)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
// û<>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == 0) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == 2 && (Distributing.cbDistributing[i][cbIndexCount] + cbMagicCardCount) >= 3)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ҵ<EFBFBD><D2B4>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
uint8 cbTakeCard[5] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbUseMagicCardCount = 0;
|
|||
|
|
if (cbTmpCount < 3)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbMagicIndex = 0; cbMagicIndex < cbMagicCardCount; cbMagicIndex++)
|
|||
|
|
{
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>;
|
|||
|
|
cbTakeCard[cbTmpCount++] = cbMagicCard[cbMagicCardCount - cbMagicIndex - 1];
|
|||
|
|
cbUseMagicCardCount++;
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (uint8 k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[j] - k - 1)*(j + 1);
|
|||
|
|
|
|||
|
|
uint8 cbLogicValue = GetCardLogicValue(AnalyseResult.cbCardData[j][cbIndex]);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>;
|
|||
|
|
if (i == cbLogicValue) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B2BBBA><EFBFBD>;
|
|||
|
|
if (j > 0 && cbTmpCount == 3 && cbLogicValue > i) continue;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 n = 0; n < j + 1; n++)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = AnalyseResult.cbCardData[j][cbIndex + n];
|
|||
|
|
if (cbTmpCount == 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 5)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTakeCard, sizeof(uint8)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD>;
|
|||
|
|
uint8 DZ_CGameLogic::SearchThreeLineTakeTwo(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard,
|
|||
|
|
uint8 cbBlockCount, tagDZSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
if (cbHandCardCount < cbBlockCount*5) return 0;
|
|||
|
|
|
|||
|
|
// Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD><CFBC>ƣ<EFBFBD><C6A3><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ֵ;
|
|||
|
|
uint8 cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>A
|
|||
|
|
//if (cbReferIndex + cbBlockCount > 14) return 0;
|
|||
|
|
if (cbReferIndex + cbBlockCount > GetCardLogicValue(0x01) + 1) return 0;
|
|||
|
|
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagDZSearchCardResult));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbHandCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCard[cbMagicCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x01) - cbBlockCount + 1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
uint8 cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbTmpCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
|
|||
|
|
for (uint8 j = i; j <= GetCardLogicValue(0x01); j++)
|
|||
|
|
{
|
|||
|
|
// <20><>2<EFBFBD><32><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[j][cbIndexCount] >= 3)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpLinkCount >= cbBlockCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpCard[cbCount++] = MakeCardData(cbIndex, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>;
|
|||
|
|
uint8 cbTakeCard[DZ_MAX_COUNT] = {0};
|
|||
|
|
uint8 cbTakeCardCount = cbNormalCardCount;
|
|||
|
|
CopyMemory(cbTakeCard, cbNormalCard, sizeof(uint8)*cbNormalCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ѿ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>;
|
|||
|
|
if (RemoveCard(cbTmpCard, cbCount, cbTakeCard, cbNormalCardCount))
|
|||
|
|
{
|
|||
|
|
cbTakeCardCount -= cbCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD>;
|
|||
|
|
tagDZAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbTakeCard, cbTakeCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
for (uint8 j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (uint8 k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[j] - k - 1)*(j + 1);
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 n = 0; n < j + 1; n++)
|
|||
|
|
{
|
|||
|
|
cbTmpCard[cbCount++] = AnalyseResult.cbCardData[j][cbIndex + n];
|
|||
|
|
if (cbCount == cbBlockCount * 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbCount == cbBlockCount * 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbCount == cbBlockCount * 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCount != cbBlockCount * 5) break;
|
|||
|
|
|
|||
|
|
int iCardType = GetCardType(cbTmpCard, cbCount, false);
|
|||
|
|
if (!IsHasCardType(iCardType, DZ_CT_THREE_LINE)) break;
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCount == cbBlockCount * 5)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTmpCard, sizeof(uint8)*cbCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
uint8 cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbTmpCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
|
|||
|
|
for (uint8 j = i; j <= GetCardLogicValue(0x01); j++)
|
|||
|
|
{
|
|||
|
|
// <20><>2<EFBFBD><32><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[j][cbIndexCount] >= 3)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
}
|
|||
|
|
// ֻ<><D6BB>2<EFBFBD><32>;
|
|||
|
|
else if (Distributing.cbDistributing[j][cbIndexCount] == 2)
|
|||
|
|
{
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount < cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
cbUseMagicCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB>;
|
|||
|
|
else if (Distributing.cbDistributing[j][cbIndexCount] == 1)
|
|||
|
|
{
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount + 2 <= cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
cbUseMagicCount += 2;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// һ<>Ŷ<EFBFBD>û<EFBFBD><C3BB>;
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount + 3 <= cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
cbTmpLinkCount++;
|
|||
|
|
cbUseMagicCount += 3;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbTmpLinkCount >= cbBlockCount)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3>Ͳ<EFBFBD><CDB2><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount <= 0) break;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[cbIndex][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpCard[cbCount++] = MakeCardData(cbIndex, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>;
|
|||
|
|
uint8 cbTakeCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbTakeCardCount = cbNormalCardCount;
|
|||
|
|
CopyMemory(cbTakeCard, cbNormalCard, sizeof(uint8)*cbNormalCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ѿ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>;
|
|||
|
|
if (RemoveCard(cbTmpCard, cbCount, cbTakeCard, cbNormalCardCount))
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 cbMagic = 0; cbMagic < cbUseMagicCount; cbMagic++)
|
|||
|
|
{
|
|||
|
|
cbTmpCard[cbCount++] = cbMagicCard[cbMagic];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbTakeCardCount -= cbCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD>;
|
|||
|
|
tagDZAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbTakeCard, cbTakeCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
for (uint8 j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (uint8 k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
uint8 cbIndex = (AnalyseResult.cbBlockCount[j] - k - 1)*(j + 1);
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 n = 0; n < j + 1; n++)
|
|||
|
|
{
|
|||
|
|
cbTmpCard[cbCount++] = AnalyseResult.cbCardData[j][cbIndex + n];
|
|||
|
|
if (cbCount == cbBlockCount * 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbCount == cbBlockCount * 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbCount == cbBlockCount * 5) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
//for (uint8 cbMagic = 0; cbMagic < cbUseMagicCount; cbMagic++)
|
|||
|
|
//{
|
|||
|
|
// pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = cbMagicCard[cbMagic];
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCount < cbBlockCount * 5)
|
|||
|
|
{
|
|||
|
|
uint8 cbNeedCardCount = cbBlockCount * 5 - cbCount;
|
|||
|
|
|
|||
|
|
// ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbUseMagicCount + cbNeedCardCount <= cbMagicCardCount)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbMagic = 0; cbMagic < cbNeedCardCount; cbMagic++)
|
|||
|
|
{
|
|||
|
|
//pSearchCardResult->cbResultCard[cbResultCount][cbCount++] = cbMagicCard[cbUseMagicCount + cbMagic];
|
|||
|
|
cbTmpCard[cbCount++] = cbMagicCard[cbUseMagicCount + cbMagic];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCount != cbBlockCount * 5) break;
|
|||
|
|
|
|||
|
|
int iCardType = GetCardType(cbTmpCard, cbCount, false);
|
|||
|
|
if (!IsHasCardType(iCardType, DZ_CT_THREE_LINE)) break;
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCount == cbBlockCount * 5)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTmpCard, sizeof(uint8)*cbCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>;
|
|||
|
|
uint8 DZ_CGameLogic::SearchBomb(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbReferCount, int iReferCardType, tagDZSearchCardResult *pSearchCardResult, uint8 &cbResultCount)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount < 4) return cbResultCount;
|
|||
|
|
if (pSearchCardResult == nullptr) return cbResultCount;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return cbResultCount;
|
|||
|
|
|
|||
|
|
// Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD>ը<EFBFBD><D5A8>;
|
|||
|
|
bool isTurnBomb = ((iReferCardType >> DZ_CT_BOMB_4) > 0) ? true : false;
|
|||
|
|
uint8 cbTurnLogicValue = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCard[DZ_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMagicCardCount = 0; // <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (IsLaiZiCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
cbMagicCard[cbMagicCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, DZ_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDZDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
uint8 cbMinIndex = 0x03;
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x02);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>;
|
|||
|
|
if (!isTurnBomb)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(4~8<><38>);
|
|||
|
|
for (uint8 cbBombCardCount = 4; cbBombCardCount < 8; cbBombCardCount++)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = cbMinIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
uint8 cbTmpBombCard[12] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpBombCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTmpBombCard, sizeof(uint8)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(4~12<31><32>);
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbBombCardCount = 4; cbBombCardCount < 12; cbBombCardCount++)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = cbMinIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
// û<><C3BB><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] <= 0) continue;
|
|||
|
|
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] + cbMagicCardCount) == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
uint8 cbTmpBombCard[12] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpBombCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 cbMagicIndex = 0; cbMagicIndex < cbMagicCardCount; cbMagicIndex++)
|
|||
|
|
{
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>;
|
|||
|
|
cbTmpBombCard[cbTmpCount++] = cbMagicCard[cbMagicCardCount - cbMagicIndex - 1];
|
|||
|
|
|
|||
|
|
if (cbTmpCount == cbBombCardCount) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTmpBombCard, sizeof(uint8)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bool isJokerBomb = (cbReferCount == 4 && IsHasCardType(iReferCardType, DZ_CT_BOMB_8));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>ը<EFBFBD><D5A8><EFBFBD><EFBFBD>;
|
|||
|
|
if (!isJokerBomb)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(4~8<><38>);
|
|||
|
|
for (uint8 cbBombCardCount = cbReferCount; cbBombCardCount < 8; cbBombCardCount++)
|
|||
|
|
{
|
|||
|
|
uint8 i = cbMinIndex;
|
|||
|
|
if (cbBombCardCount == cbReferCount)
|
|||
|
|
{
|
|||
|
|
i = cbTurnLogicValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
uint8 cbTmpBombCard[12] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpBombCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTmpBombCard, sizeof(uint8)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(4~12<31><32>);
|
|||
|
|
if (cbMagicCardCount > 0)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbBombCardCount = cbReferCount; cbBombCardCount < 12; cbBombCardCount++)
|
|||
|
|
{
|
|||
|
|
uint8 i = cbMinIndex;
|
|||
|
|
if (cbBombCardCount == cbReferCount)
|
|||
|
|
{
|
|||
|
|
i = cbTurnLogicValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
// û<><C3BB><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] <= 0) continue;
|
|||
|
|
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] + cbMagicCardCount) == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
uint8 cbTmpCount = 0;
|
|||
|
|
uint8 cbTmpBombCard[12] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpBombCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 cbMagicIndex = 0; cbMagicIndex < cbMagicCardCount; cbMagicIndex++)
|
|||
|
|
{
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>;
|
|||
|
|
cbTmpBombCard[cbTmpCount++] = cbMagicCard[cbMagicCardCount - cbMagicIndex - 1];
|
|||
|
|
|
|||
|
|
if (cbTmpCount == cbBombCardCount) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == cbBombCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], cbTmpBombCard, sizeof(uint8)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 DZ_CGameLogic::MakeCardData(uint8 cbLogicValue, uint8 cbColorIndex)
|
|||
|
|
{
|
|||
|
|
uint8 cbCardColor = (cbColorIndex << 4);
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
if (cbCardColor == 0x40)
|
|||
|
|
{
|
|||
|
|
cbLogicValue -= 2;
|
|||
|
|
}
|
|||
|
|
else if (cbLogicValue > 0x0D)
|
|||
|
|
{
|
|||
|
|
cbLogicValue -= 0x0D;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return (cbCardColor | cbLogicValue);
|
|||
|
|
}
|