1885 lines
48 KiB
C++
1885 lines
48 KiB
C++
|
|
#include "PDK_GameLogic.h"
|
|||
|
|
#include <assert.h>
|
|||
|
|
#include <string.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
const uint8 cbIndexCount = 5;
|
|||
|
|
|
|||
|
|
//16<31><36><EFBFBD>淨<EFBFBD><E6B7A8>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>3<EFBFBD><33>2<EFBFBD><32>1<EFBFBD><31>A
|
|||
|
|
const uint8 CPDKGameLogic::m_cbCardData16[PDK_FULL_COUNT] =
|
|||
|
|
{
|
|||
|
|
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //÷<><C3B7> A - K
|
|||
|
|
0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x01, 0x11, 0x21, 0x22
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//15<31><35><EFBFBD>淨<EFBFBD><E6B7A8>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>3<EFBFBD><33>2<EFBFBD><32>3<EFBFBD><33>A<EFBFBD><41>1<EFBFBD><31>K
|
|||
|
|
const uint8 CPDKGameLogic::m_cbCardData15[PDK_FULL_COUNT_15] =
|
|||
|
|
{
|
|||
|
|
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, //÷<><C3B7> A - K
|
|||
|
|
0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, //<2F><><EFBFBD><EFBFBD> A - K
|
|||
|
|
0x21, 0x22
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CPDKGameLogic::CPDKGameLogic()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CPDKGameLogic::~CPDKGameLogic()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
uint8 CPDKGameLogic::GetCardType(const uint8 cbCardData[], uint8 cbCardCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
switch (cbCardCount)
|
|||
|
|
{
|
|||
|
|
case 0: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
case 1: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return PDK_CT_SINGLE;
|
|||
|
|
}
|
|||
|
|
case 2: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (GetCardLogicValue(cbCardData[0]) == GetCardLogicValue(cbCardData[1])) return PDK_CT_DOUBLE;
|
|||
|
|
|
|||
|
|
return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult;
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (AnalyseResult.cbBlockCount[3] == 1)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[3] == 1) && (cbCardCount == 4)) return PDK_CT_BOMB_CARD;
|
|||
|
|
|
|||
|
|
// <20>Ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((AnalyseResult.cbBlockCount[3] == 1) && (cbCardCount == 5)) return PDK_CT_THREE_TAKE_TWO;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>;
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_FOUR_TAKE_THREE))
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ը<EFBFBD><D5A8><EFBFBD>Դ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (isLastCard)
|
|||
|
|
{
|
|||
|
|
if ((AnalyseResult.cbBlockCount[3] == 1) && (cbCardCount <= 7) && (cbCardCount > 5)) return PDK_CT_FOUR_TAKE_THREE;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if ((AnalyseResult.cbBlockCount[3] == 1) && (cbCardCount == 7)) return PDK_CT_FOUR_TAKE_THREE;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 3Aը<41><D5A8>;
|
|||
|
|
if ((3 == cbCardCount) && IsHasGameRule(ePDKRuleEnum_3ABomb) && (1 == AnalyseResult.cbBlockCount[2]))
|
|||
|
|
{
|
|||
|
|
uint8 cbCardData = AnalyseResult.cbCardData[2][0];
|
|||
|
|
uint8 cbCardValue = GetCardValue(cbCardData);
|
|||
|
|
if (0x01 == cbCardValue) // <20><>A;
|
|||
|
|
{
|
|||
|
|
return PDK_CT_3A_BOMB_CARD;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ֻ<><D6BB>һ<EFBFBD><D2BB>3<EFBFBD><33>);
|
|||
|
|
if (1 == AnalyseResult.cbBlockCount[2])
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (isLastCard)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (5 >= cbCardCount) return PDK_CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (5 == cbCardCount) return PDK_CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ȫ<>Ƕ<EFBFBD><C7B6><EFBFBD>);
|
|||
|
|
if ((AnalyseResult.cbBlockCount[1] >= 2) && (AnalyseResult.cbBlockCount[1] * 2 == cbCardCount))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardData = AnalyseResult.cbCardData[1][0];
|
|||
|
|
uint8 cbFirstLogicValue = GetCardLogicValue(cbCardData);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2>ܴ<EFBFBD>2;
|
|||
|
|
if (cbFirstLogicValue >= GetCardLogicValue(0x02)) return PDK_CT_ERROR;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
for (uint8 i = 1; i < AnalyseResult.cbBlockCount[1]; i++)
|
|||
|
|
{
|
|||
|
|
uint8 cbCardData = AnalyseResult.cbCardData[1][i * 2];
|
|||
|
|
if (cbFirstLogicValue != (GetCardLogicValue(cbCardData) + i)) return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[1] * 2) == cbCardCount) return PDK_CT_DOUBLE_LINE;
|
|||
|
|
|
|||
|
|
return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>(ȫ<>ǵ<EFBFBD><C7B5><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>);
|
|||
|
|
if ((AnalyseResult.cbBlockCount[0] >= 5) && (AnalyseResult.cbBlockCount[0] == cbCardCount))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardData = AnalyseResult.cbCardData[0][0];
|
|||
|
|
uint8 cbFirstLogicValue = GetCardLogicValue(cbCardData);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2>ܴ<EFBFBD>2;
|
|||
|
|
if (cbFirstLogicValue >= GetCardLogicValue(0x02)) return PDK_CT_ERROR;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
for (uint8 i = 1; i < AnalyseResult.cbBlockCount[0]; i++)
|
|||
|
|
{
|
|||
|
|
uint8 cbCardData = AnalyseResult.cbCardData[0][i];
|
|||
|
|
if (cbFirstLogicValue != (GetCardLogicValue(cbCardData) + i)) return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return PDK_CT_SINGLE_LINE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 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 PDK_CT_ERROR;
|
|||
|
|
uint8 cbCardType = PDK_CT_ERROR;
|
|||
|
|
|
|||
|
|
uint8 cbLineCardData[PDK_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 = 2; i <= 3; i++)
|
|||
|
|
{
|
|||
|
|
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) >= GetCardLogicValue(0x02)) continue;
|
|||
|
|
|
|||
|
|
cbLineCardData[cbLineLength] = cbTmpCardDate;
|
|||
|
|
cbLineLength++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbLineCardData, cbLineLength, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
uint8 cbLastValue = GetCardLogicValue(cbLineCardData[0]);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(3~A)
|
|||
|
|
if (cbLastValue > GetCardLogicValue(0x01)) return PDK_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))
|
|||
|
|
{
|
|||
|
|
cbCardType = PDK_CT_THREE_LINE;
|
|||
|
|
}
|
|||
|
|
else if (!isLastCard)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>㼸<EFBFBD><E3BCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbTmpBlockCount = cbCardCount / 5;
|
|||
|
|
if (cbMaxThreeLength == cbTmpBlockCount)
|
|||
|
|
{
|
|||
|
|
cbCardType = PDK_CT_THREE_LINE;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbCardType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return PDK_CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void CPDKGameLogic::SortCardList(uint8 cbCardData[], uint8 cbCardCount, uint8 cbSortType)
|
|||
|
|
{
|
|||
|
|
//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount == 0) return;
|
|||
|
|
if (cbSortType == PDK_ST_CUSTOM) return;
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
uint8 cbSortValue[PDK_MAX_COUNT];
|
|||
|
|
for (uint8 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>
|
|||
|
|
if (cbSortType == PDK_ST_COUNT)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardIndex = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult 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;
|
|||
|
|
memcpy(&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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
bool CPDKGameLogic::RemoveCardList(const uint8 cbRemoveCard[], uint8 cbRemoveCount, uint8 cbCardData[], uint8 cbCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
assert(cbRemoveCount <= cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbDeleteCount = 0, cbTempCardData[PDK_MAX_COUNT];
|
|||
|
|
if (cbCardCount > CountArray(cbTempCardData)) return false;
|
|||
|
|
memcpy(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>
|
|||
|
|
uint8 cbCardPos = 0;
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (cbTempCardData[i] != 0) cbCardData[cbCardPos++] = cbTempCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
bool CPDKGameLogic::RemoveCard(const uint8 cbRemoveCard[], uint8 cbRemoveCount, uint8 cbCardData[], uint8 cbCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
assert(cbRemoveCount <= cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbDeleteCount = 0, cbTempCardData[PDK_MAX_COUNT];
|
|||
|
|
if (cbCardCount > CountArray(cbTempCardData)) return false;
|
|||
|
|
memcpy(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>
|
|||
|
|
uint8 cbCardPos = 0;
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (cbTempCardData[i] != 0) cbCardData[cbCardPos++] = cbTempCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void CPDKGameLogic::SortOutCardList(uint8 cbCardData[], uint8 cbCardCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardType = GetCardType(cbCardData, cbCardCount, isLastCard);
|
|||
|
|
|
|||
|
|
// AAA+BB <20>ṹ;
|
|||
|
|
if (cbCardType == PDK_CT_THREE_TAKE_TWO)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 cbTmpCardCount = 3;
|
|||
|
|
//CopyMemory(cbCardData, AnalyseResult.cbCardData[2], sizeof(uint8)*cbTmpCardCount);
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] == 1)
|
|||
|
|
{
|
|||
|
|
for (uint8 i = 0; i < cbTmpCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbCardData[i] = AnalyseResult.cbCardData[2][i];
|
|||
|
|
AnalyseResult.cbCardData[2][i] = 0x0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (AnalyseResult.cbBlockCount[3] == 1)
|
|||
|
|
{
|
|||
|
|
uint8 i = 0;
|
|||
|
|
for (i = 0; i < cbTmpCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbCardData[i] = AnalyseResult.cbCardData[3][i];
|
|||
|
|
AnalyseResult.cbCardData[3][i] = 0x0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
cbCardData[i] = AnalyseResult.cbCardData[3][i];
|
|||
|
|
AnalyseResult.cbCardData[3][i] = 0x0;
|
|||
|
|
cbTmpCardCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = CountArray(AnalyseResult.cbBlockCount) - 1; i >= 0; i--)
|
|||
|
|
{
|
|||
|
|
if (i >= 2) continue;
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
CopyMemory(&cbCardData[cbTmpCardCount], AnalyseResult.cbCardData[i], sizeof(uint8)*(i + 1)*AnalyseResult.cbBlockCount[i]);
|
|||
|
|
|
|||
|
|
cbTmpCardCount += (i + 1)*AnalyseResult.cbBlockCount[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == PDK_CT_FOUR_TAKE_THREE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
uint8 cbTmpCardCount = 4;
|
|||
|
|
CopyMemory(cbCardData, AnalyseResult.cbCardData[3], sizeof(uint8)*cbTmpCardCount);
|
|||
|
|
|
|||
|
|
for (int i = CountArray(AnalyseResult.cbBlockCount) - 1; i >= 0; i--)
|
|||
|
|
{
|
|||
|
|
if (i == 3) continue;
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
CopyMemory(&cbCardData[cbTmpCardCount], AnalyseResult.cbCardData[i], sizeof(uint8)*(i + 1)*AnalyseResult.cbBlockCount[i]);
|
|||
|
|
|
|||
|
|
cbTmpCardCount += (i + 1)*AnalyseResult.cbBlockCount[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == PDK_CT_THREE_LINE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 1)
|
|||
|
|
{
|
|||
|
|
uint8 cbLineCardData[PDK_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 = 2; i <= 3; 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) > GetCardLogicValue(0x02)) continue;
|
|||
|
|
|
|||
|
|
cbLineCardData[cbLineLength] = cbTmpCardDate;
|
|||
|
|
cbLineLength++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbLineCardData, cbLineLength, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbCardData, cbCardCount, Distributing);
|
|||
|
|
|
|||
|
|
uint8 cbLastValue = GetCardLogicValue(cbLineCardData[0]);
|
|||
|
|
|
|||
|
|
// <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><E3BCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbTmpBlockCount = cbCardCount / 5;
|
|||
|
|
if (isLastCard || (cbMaxThreeLength == cbTmpBlockCount))
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ϳ鳤<CDBF><E9B3A4><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>;
|
|||
|
|
uint8 cbTmpCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(cbMaxThreeCardData);
|
|||
|
|
|
|||
|
|
uint8 cbCount = 0;
|
|||
|
|
for (uint8 cbIndex = cbMaxIndex; cbIndex > (cbMaxIndex - cbTmpBlockCount); 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);
|
|||
|
|
|
|||
|
|
Distributing.cbDistributing[cbIndex][3 - cbColorIndex]--;
|
|||
|
|
|
|||
|
|
if (++cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
for (uint8 i = 0; i <= GetCardLogicValue(0x02); i++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (uint8 cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][3 - cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTmpCard[cbCount++] = MakeCardData(i, 3 - cbColorIndex);
|
|||
|
|
|
|||
|
|
Distributing.cbDistributing[i][3 - cbColorIndex]--;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbCardCount == cbCount)
|
|||
|
|
{
|
|||
|
|
CopyMemory(cbCardData, cbTmpCard, cbCount);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE CPDKGameLogic::SortOutCardList(BYTE cbCardData[], BYTE cbCardCount, BYTE cbCardType, BYTE cbBlockCount)
|
|||
|
|
{
|
|||
|
|
BYTE cbMaxCardData = 0x0;
|
|||
|
|
|
|||
|
|
// AAA+BB <20>ṹ;
|
|||
|
|
if (cbCardType == PDK_CT_THREE_TAKE_TWO)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] == 1)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[2][0];
|
|||
|
|
}
|
|||
|
|
else if (AnalyseResult.cbBlockCount[3] == 1)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[3][0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == PDK_CT_FOUR_TAKE_THREE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[3] == 1)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[3][0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == PDK_CT_THREE_LINE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 1)
|
|||
|
|
{
|
|||
|
|
BYTE cbLineCardData[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbLineLength = 0;
|
|||
|
|
|
|||
|
|
// Ŀǰֻ<C7B0><D6BB>3ȡ<33><C8A1>4<EFBFBD><34><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>(<28><>3<EFBFBD><33>4<EFBFBD><34><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 (BYTE i = 2; i <= 3; i++)
|
|||
|
|
{
|
|||
|
|
if (AnalyseResult.cbBlockCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
for (BYTE j = 0; j < AnalyseResult.cbBlockCount[i]; j++)
|
|||
|
|
{
|
|||
|
|
BYTE cbTmpCardDate = AnalyseResult.cbCardData[i][j*(i + 1)];
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>2;
|
|||
|
|
if (GetCardLogicValue(cbTmpCardDate) >= GetCardLogicValue(0x02)) continue;
|
|||
|
|
|
|||
|
|
cbLineCardData[cbLineLength] = cbTmpCardDate;
|
|||
|
|
cbLineLength++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbLineCardData, cbLineLength, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbCardData, cbCardCount, Distributing);
|
|||
|
|
|
|||
|
|
BYTE cbLastValue = GetCardLogicValue(cbLineCardData[0]);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbMaxThreeLength = 1;
|
|||
|
|
BYTE cbThreeLength = 1;
|
|||
|
|
BYTE cbMaxThreeCardData = cbLineCardData[0];
|
|||
|
|
|
|||
|
|
for (BYTE i = 1; i < cbLineLength; i++)
|
|||
|
|
{
|
|||
|
|
BYTE 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><EFBFBD><EFBFBD>ȱȽ<C8B1>;
|
|||
|
|
if (cbMaxThreeLength >= cbBlockCount)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = cbMaxThreeCardData;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbMaxCardData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ч<EFBFBD>ж<EFBFBD>
|
|||
|
|
bool CPDKGameLogic::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 CPDKGameLogic::GetCardLogicValue(uint8 cbCardData)
|
|||
|
|
{
|
|||
|
|
if (!IsValidCard(cbCardData)) return 0;
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardColor = GetCardColor(cbCardData);
|
|||
|
|
uint8 cbCardValue = GetCardValue(cbCardData);
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
if (cbCardColor == 0x40) return cbCardValue + 2;
|
|||
|
|
return (cbCardValue <= 2) ? (cbCardValue + 13) : cbCardValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 CPDKGameLogic::GetMaxLogicValue(const uint8 cbHandCardData[], uint8 cbHandCardCount)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount <= 0) return 0;
|
|||
|
|
|
|||
|
|
uint8 cbCardData[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(cbCardData, cbHandCardData, cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbCardData, cbHandCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
return GetCardLogicValue(cbCardData[0]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 CPDKGameLogic::GetMaxCardData(const uint8 cbHandCardData[], uint8 cbHandCardCount)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount <= 0) return 0;
|
|||
|
|
|
|||
|
|
uint8 cbCardData[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
CopyMemory(cbCardData, cbHandCardData, cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbCardData, cbHandCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
return (cbCardData[0]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
bool CPDKGameLogic::CompareCard(const uint8 cbFirstCard[], const uint8 cbNextCard[], uint8 cbFirstCount, uint8 cbNextCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbNextType = GetCardType(cbNextCard, cbNextCount, isLastCard);
|
|||
|
|
uint8 cbFirstType = GetCardType(cbFirstCard, cbFirstCount, false);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbNextType == PDK_CT_ERROR) return false;
|
|||
|
|
if (cbNextType == PDK_CT_3A_BOMB_CARD) return true;
|
|||
|
|
|
|||
|
|
//ը<><D5A8><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((cbFirstType != PDK_CT_BOMB_CARD) && (cbNextType == PDK_CT_BOMB_CARD)) return true;
|
|||
|
|
if ((cbFirstType == PDK_CT_BOMB_CARD) && (cbNextType != PDK_CT_BOMB_CARD)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbFirstType != cbNextType) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD>Ա<EFBFBD>
|
|||
|
|
switch (cbNextType)
|
|||
|
|
{
|
|||
|
|
case PDK_CT_SINGLE:
|
|||
|
|
case PDK_CT_DOUBLE:
|
|||
|
|
case PDK_CT_SINGLE_LINE:
|
|||
|
|
case PDK_CT_DOUBLE_LINE:
|
|||
|
|
case PDK_CT_BOMB_CARD:
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ;
|
|||
|
|
if (cbFirstCount != cbNextCount) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
uint8 cbNextLogicValue = GetCardLogicValue(cbNextCard[0]);
|
|||
|
|
uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstCard[0]);
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue > cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_THREE_TAKE_TWO:
|
|||
|
|
{
|
|||
|
|
// <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 (cbFirstCount != 5) return false;
|
|||
|
|
if (!isLastCard && cbNextCount != 5) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult NextResult;
|
|||
|
|
tagPDKAnalyseResult FirstResult;
|
|||
|
|
AnalysebCardData(cbNextCard, cbNextCount, NextResult);
|
|||
|
|
AnalysebCardData(cbFirstCard, cbFirstCount, FirstResult);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
//uint8 cbFirstLogicValue = GetCardLogicValue(FirstResult.cbCardData[2][0]);
|
|||
|
|
uint8 cbFirstLogicValue = 0x0;
|
|||
|
|
uint8 cbNextLogicValue = 0x0;
|
|||
|
|
|
|||
|
|
// <20>Ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (1 == FirstResult.cbBlockCount[2])
|
|||
|
|
{
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(FirstResult.cbCardData[2][0]);
|
|||
|
|
}
|
|||
|
|
else if (1 == FirstResult.cbBlockCount[3])
|
|||
|
|
{
|
|||
|
|
cbFirstLogicValue = GetCardLogicValue(FirstResult.cbCardData[3][0]);
|
|||
|
|
}
|
|||
|
|
if (1 == NextResult.cbBlockCount[2])
|
|||
|
|
{
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(NextResult.cbCardData[2][0]);
|
|||
|
|
}
|
|||
|
|
else if (1 == NextResult.cbBlockCount[3])
|
|||
|
|
{
|
|||
|
|
cbNextLogicValue = GetCardLogicValue(NextResult.cbCardData[3][0]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue > cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_FOUR_TAKE_THREE:
|
|||
|
|
{
|
|||
|
|
// <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (cbFirstCount < 5 || cbFirstCount > 7) return false;
|
|||
|
|
if (cbNextCount < 5 || cbNextCount > 7) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>7<EFBFBD><37>;
|
|||
|
|
if (cbFirstCount != 7) return false;
|
|||
|
|
if (!isLastCard && cbNextCount != 7) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult NextResult;
|
|||
|
|
tagPDKAnalyseResult FirstResult;
|
|||
|
|
AnalysebCardData(cbNextCard, cbNextCount, NextResult);
|
|||
|
|
AnalysebCardData(cbFirstCard, cbFirstCount, FirstResult);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
uint8 cbNextLogicValue = GetCardLogicValue(NextResult.cbCardData[3][0]);
|
|||
|
|
uint8 cbFirstLogicValue = GetCardLogicValue(FirstResult.cbCardData[3][0]);
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue > cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_THREE_LINE:
|
|||
|
|
{
|
|||
|
|
// <20>ɻ<EFBFBD><C9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3*2;
|
|||
|
|
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 ((cbFirstCount % 5) != 0) return false;
|
|||
|
|
if (!isLastCard && (cbNextCount % 5) != 0) return false;
|
|||
|
|
|
|||
|
|
// <20><><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 (!isLastCard && (cbNextCount != cbFirstCount)) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϼҳ<CFBC><D2B3><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (isLastCard && (cbNextCount > cbFirstCount)) return false;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbFirstBlockCount = cbFirstCount / 5;
|
|||
|
|
BYTE cbFirstCardData = SortOutCardList((BYTE*)cbFirstCard, cbFirstCount, PDK_CT_THREE_LINE, cbFirstBlockCount);
|
|||
|
|
BYTE cbNextCardData = SortOutCardList((BYTE*)cbNextCard, cbNextCount, PDK_CT_THREE_LINE, cbFirstBlockCount);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardData);
|
|||
|
|
BYTE cbFirstLogicValue = GetCardLogicValue(cbFirstCardData);
|
|||
|
|
|
|||
|
|
//// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
//uint8 cbFirstBlockCount = GetThreeLineBlockCount(cbFirstCard, cbFirstCount, false);
|
|||
|
|
//uint8 cbNextBlockCount = GetThreeLineBlockCount(cbNextCard, cbNextCount, isLastCard);
|
|||
|
|
|
|||
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>һ<EFBFBD><D2BB>;
|
|||
|
|
//if (cbNextBlockCount >= cbFirstBlockCount) return false;
|
|||
|
|
|
|||
|
|
//uint8 cbFirstTurnCard[PDK_MAX_COUNT] = {};
|
|||
|
|
//CopyMemory(cbFirstTurnCard, cbFirstCard, sizeof(uint8)*cbFirstCount);
|
|||
|
|
//SortOutCardList(cbFirstTurnCard, cbFirstCount, false);
|
|||
|
|
|
|||
|
|
//uint8 cbNextTurnCard[PDK_MAX_COUNT] = {};
|
|||
|
|
//CopyMemory(cbNextTurnCard, cbNextCard, sizeof(uint8)*cbNextCount);
|
|||
|
|
//SortOutCardList(cbNextTurnCard, cbNextCount, isLastCard);
|
|||
|
|
|
|||
|
|
////<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
//uint8 cbNextLogicValue = GetCardLogicValue(cbNextTurnCard[0]);
|
|||
|
|
//uint8 cbFirstLogicValue = GetCardLogicValue(cbFirstTurnCard[0]);
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue > cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 CPDKGameLogic::MakeCardData(uint8 cbLogicValue, uint8 cbColorIndex)
|
|||
|
|
{
|
|||
|
|
//return (cbColorIndex << 4) | (cbValueIndex + 1);
|
|||
|
|
|
|||
|
|
uint8 cbCardColor = (cbColorIndex << 4);
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
if (cbLogicValue > 0x0D)
|
|||
|
|
{
|
|||
|
|
cbLogicValue -= 0x0D;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return (cbCardColor | cbLogicValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
void CPDKGameLogic::AnalysebCardData(const uint8 cbCardData[], uint8 cbCardCount, tagPDKAnalyseResult & AnalyseResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
zeromemory(&AnalyseResult, sizeof(tagPDKAnalyseResult));
|
|||
|
|
|
|||
|
|
//<2F>˿˷<CBBF><CBB7><EFBFBD>
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbSameCount = 1;
|
|||
|
|
uint8 cbLogicValue = GetCardLogicValue(cbCardData[i]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
|||
|
|
for (uint8 j = i + 1; j < cbCardCount; j++)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD>˿<EFBFBD>
|
|||
|
|
if (GetCardLogicValue(cbCardData[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] = cbCardData[i + j];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
i += cbSameCount - 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>
|
|||
|
|
void CPDKGameLogic::AnalysebDistributing(const uint8 cbCardData[], uint8 cbCardCount, tagPDKDistributing & Distributing)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
zeromemory(&Distributing, sizeof(tagPDKDistributing));
|
|||
|
|
|
|||
|
|
//<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]);
|
|||
|
|
|
|||
|
|
////<2F>ֲ<EFBFBD><D6B2><EFBFBD>Ϣ
|
|||
|
|
//Distributing.cbCardCount++;
|
|||
|
|
//Distributing.cbDistributing[cbCardValue - 1][cbIndexCount]++;
|
|||
|
|
//Distributing.cbDistributing[cbCardValue - 1][cbCardColor >> 4]++;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbCardColor = GetCardColor(cbCardData[i]);
|
|||
|
|
uint8 cbCardValue = GetCardLogicValue(cbCardData[i]);
|
|||
|
|
|
|||
|
|
//<2F>ֲ<EFBFBD><D6B2><EFBFBD>Ϣ
|
|||
|
|
Distributing.cbCardCount++;
|
|||
|
|
Distributing.cbDistributing[cbCardValue][cbIndexCount]++;
|
|||
|
|
Distributing.cbDistributing[cbCardValue][cbCardColor >> 4]++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 CPDKGameLogic::SearchOutCard(const uint8 cbHandCardData[], uint8 cbHandCardCount, const uint8 cbTurnCardData[], uint8 cbTurnCardCount,
|
|||
|
|
tagPDKSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
ASSERT(pSearchCardResult != NULL);
|
|||
|
|
if (pSearchCardResult == NULL) return 0;
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagPDKSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
tagPDKSearchCardResult tmpSearchCardResult = {};
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
CopyMemory(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbCardData, cbCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>(<28><>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>);
|
|||
|
|
uint8 cbTurnOutType = GetCardType(cbTurnCardData, cbTurnCardCount, false);
|
|||
|
|
|
|||
|
|
if (PDK_CT_ERROR == cbTurnOutType) return 0;
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>;
|
|||
|
|
if (CompareCard(cbTurnCardData, cbCardData, cbTurnCardCount, cbCardCount, true) == true)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCardCount;
|
|||
|
|
memcpy(pSearchCardResult->cbResultCard[cbResultCount], cbCardData, sizeof(uint8)*cbCardCount);
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
|||
|
|
switch (cbTurnOutType)
|
|||
|
|
{
|
|||
|
|
case PDK_CT_SINGLE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
case PDK_CT_DOUBLE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[0];
|
|||
|
|
uint8 cbSameCount = 1;
|
|||
|
|
if (cbTurnOutType == PDK_CT_DOUBLE) cbSameCount = 2;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
|||
|
|
cbResultCount = SearchSameCard(cbCardData, cbCardCount, cbReferCard, cbSameCount, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_SINGLE_LINE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
cbResultCount = SearchSingleLine(cbCardData, cbCardCount, cbReferCard, cbTurnCardCount, pSearchCardResult);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_DOUBLE_LINE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
uint8 cbLineCount = cbTurnCardCount / 2;
|
|||
|
|
cbResultCount = SearchDoubleLine(cbCardData, cbCardCount, cbReferCard, cbLineCount, pSearchCardResult);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_THREE_LINE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount < cbTurnCardCount) break;
|
|||
|
|
|
|||
|
|
uint8 cbBlockCount = cbTurnCardCount / 5;
|
|||
|
|
|
|||
|
|
//uint8 cbTmpTurnCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
//CopyMemory(cbTmpTurnCard, cbTurnCardData, sizeof(uint8)*cbTurnCardCount);
|
|||
|
|
//SortOutCardList(cbTmpTurnCard, cbTurnCardCount, false);
|
|||
|
|
|
|||
|
|
BYTE cbTmpTurnCard = SortOutCardList((BYTE*)cbTurnCardData, cbTurnCardCount, PDK_CT_THREE_LINE, cbBlockCount);
|
|||
|
|
cbResultCount = SearchThreeLineTakeTwo(cbCardData, cbCardCount, cbTmpTurnCard, cbBlockCount, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_THREE_TAKE_TWO: //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount < cbTurnCardCount) break;
|
|||
|
|
|
|||
|
|
//uint8 cbTmpTurnCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
//CopyMemory(cbTmpTurnCard, cbTurnCardData, sizeof(uint8)*cbTurnCardCount);
|
|||
|
|
//SortOutCardList(cbTmpTurnCard, cbTurnCardCount, false);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbTmpTurnCard = SortOutCardList((BYTE*)cbTurnCardData, cbTurnCardCount, PDK_CT_THREE_TAKE_TWO, 1);
|
|||
|
|
cbResultCount = SearchThreeTakeTwo(cbCardData, cbCardCount, cbTmpTurnCard, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case PDK_CT_FOUR_TAKE_THREE: //<2F>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (!IsHasGameRule(ePDKRuleEnum_FOUR_TAKE_THREE)) break;
|
|||
|
|
if (cbCardCount < cbTurnCardCount) break;
|
|||
|
|
|
|||
|
|
//uint8 cbTmpTurnCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
//CopyMemory(cbTmpTurnCard, cbTurnCardData, sizeof(uint8)*cbTurnCardCount);
|
|||
|
|
//SortOutCardList(cbTmpTurnCard, cbTurnCardCount, false);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbTmpTurnCard = SortOutCardList((BYTE*)cbTurnCardData, cbTurnCardCount, PDK_CT_FOUR_TAKE_THREE, 1);
|
|||
|
|
cbResultCount = SearchFourTakeThree(cbCardData, cbCardCount, cbTmpTurnCard, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>
|
|||
|
|
if ((cbCardCount >= 4) && (cbTurnOutType != PDK_CT_3A_BOMB_CARD))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbReferCard = 0;
|
|||
|
|
if (cbTurnOutType == PDK_CT_BOMB_CARD) cbReferCard = cbTurnCardData[0];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>
|
|||
|
|
uint8 cbTmpResultCount = SearchSameCard(cbCardData, cbCardCount, cbReferCard, 4, &tmpSearchCardResult);
|
|||
|
|
for (uint8 i = 0; i < cbTmpResultCount; i++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[i];
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], tmpSearchCardResult.cbResultCard[i],
|
|||
|
|
sizeof(uint8)*tmpSearchCardResult.cbCardCount[i]);
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0x01,0x11,0x21)
|
|||
|
|
if (cbTurnOutType != PDK_CT_3A_BOMB_CARD && (cbCardCount >= 3) && (IsHasGameRule(ePDKRuleEnum_3ABomb)))
|
|||
|
|
{
|
|||
|
|
uint8 cbACard[3] = { 0 };
|
|||
|
|
uint8 cbACardCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A;
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (GetCardValue(cbCardData[i]) == 0x01)
|
|||
|
|
{
|
|||
|
|
cbACard[cbACardCount] = cbCardData[i];
|
|||
|
|
cbACardCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 3Aը<41><D5A8>
|
|||
|
|
if (3 == cbACardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = 3;
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][0] = cbACard[0];
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][1] = cbACard[1];
|
|||
|
|
pSearchCardResult->cbResultCard[cbResultCount][2] = cbACard[2];
|
|||
|
|
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 CPDKGameLogic::SearchSameCard(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbSameCardCount,
|
|||
|
|
tagPDKSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagPDKSearchCardResult));
|
|||
|
|
}
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbCardData[PDK_MAX_COUNT];
|
|||
|
|
uint8 cbCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbCardData, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbCardData, cbCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
uint8 cbReferLogicValue = (cbReferCard == 0) ? 0 : GetCardLogicValue(cbReferCard);
|
|||
|
|
uint8 cbBlockIndex = cbSameCardCount - 1;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
for (uint8 i = 0; i < AnalyseResult.cbBlockCount[cbBlockIndex]; i++)
|
|||
|
|
{
|
|||
|
|
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],
|
|||
|
|
cbSameCardCount*sizeof(uint8));
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbSameCardCount;
|
|||
|
|
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cbBlockIndex++;
|
|||
|
|
} while (cbBlockIndex < CountArray(AnalyseResult.cbBlockCount));
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD>;
|
|||
|
|
bool CPDKGameLogic::SearchMustOutCard(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbMustOutCard)
|
|||
|
|
{
|
|||
|
|
if (!IsValidCard(cbMustOutCard)) return false;
|
|||
|
|
|
|||
|
|
for (uint8 i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardData[i] == cbMustOutCard)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳;
|
|||
|
|
uint8 CPDKGameLogic::SearchSingleLine(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbLineCount, tagPDKSearchCardResult *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(tagPDKSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>A
|
|||
|
|
if (cbReferIndex + cbLineCount > GetCardLogicValue(0x01) + 1)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbHandCardCount < cbLineCount)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing 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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˫˳;
|
|||
|
|
uint8 CPDKGameLogic::SearchDoubleLine(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, uint8 cbLineCount, tagPDKSearchCardResult *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(tagPDKSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>A
|
|||
|
|
if (cbReferIndex + cbLineCount > GetCardLogicValue(0x01) + 1)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbHandCardCount < cbLineCount * 2)
|
|||
|
|
{
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing 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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<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 CPDKGameLogic::SearchThreeTakeTwo(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, tagPDKSearchCardResult *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(tagPDKSearchCardResult));
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ;
|
|||
|
|
if (cbReferIndex > GetCardLogicValue(0x01)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbNormalCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbNormalCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbNormalCard, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbNormalCard, cbNormalCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x01);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>ֵ-1);
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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><C4B4><EFBFBD>;
|
|||
|
|
uint8 CPDKGameLogic::SearchFourTakeThree(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard, tagPDKSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount < 7) 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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>;
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagPDKSearchCardResult));
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>ﲻ<EFBFBD><EFB2BB><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbReferIndex > GetCardLogicValue(0x01)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
uint8 cbNormalCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbNormalCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbNormalCard, cbHandCardData, sizeof(uint8)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbNormalCard, cbNormalCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//uint8 cbMinIndex = GetCardLogicValue(0x03);
|
|||
|
|
uint8 cbMaxIndex = GetCardLogicValue(0x01);
|
|||
|
|
|
|||
|
|
// <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><C4B4><EFBFBD>;
|
|||
|
|
if (Distributing.cbDistributing[i][cbIndexCount] == 4)
|
|||
|
|
{
|
|||
|
|
// <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[7] = { 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 == 4) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 4) 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 == 7) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 7) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 7) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 7)
|
|||
|
|
{
|
|||
|
|
//<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 CPDKGameLogic::SearchThreeLineTakeTwo(const uint8 cbHandCardData[], uint8 cbHandCardCount, uint8 cbReferCard,
|
|||
|
|
uint8 cbBlockCount, tagPDKSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
if (cbHandCardCount < cbBlockCount * 5) return 0;
|
|||
|
|
|
|||
|
|
uint8 cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>A
|
|||
|
|
if ((cbReferIndex + cbBlockCount) > GetCardLogicValue(0x01)) return 0;
|
|||
|
|
|
|||
|
|
zeromemory(pSearchCardResult, sizeof(tagPDKSearchCardResult));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
uint8 cbNormalCard[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
uint8 cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (uint8 i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, PDK_ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
uint8 cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagPDKDistributing 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[PDK_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[PDK_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>;
|
|||
|
|
tagPDKAnalyseResult 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 (iCardType != PDK_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><C3B5>ɻ<EFBFBD><C9BB>Ŀ<EFBFBD><C4BF><EFBFBD>С;
|
|||
|
|
//uint8 CPDKGameLogic::GetThreeLineBlockCount(const uint8 cbCardData[], uint8 cbCardCount, bool isLastCard)
|
|||
|
|
//{
|
|||
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>;
|
|||
|
|
// if (!isLastCard) return cbCardCount / 5;
|
|||
|
|
//
|
|||
|
|
// // 5<>ı<EFBFBD><C4B1><EFBFBD>;
|
|||
|
|
// if ((cbCardCount % 5) == 0) return cbCardCount / 5;
|
|||
|
|
//
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// tagPDKAnalyseResult AnalyseResult = {};
|
|||
|
|
// AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
//
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
// if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 1)
|
|||
|
|
// {
|
|||
|
|
// uint8 cbLineCardData[PDK_MAX_COUNT] = { 0 };
|
|||
|
|
// uint8 cbLineLength = 0;
|
|||
|
|
//
|
|||
|
|
// // Ŀǰֻ<C7B0><D6BB>3ȡ<33><C8A1>4<EFBFBD><34><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>(<28><>3<EFBFBD><33>4<EFBFBD><34><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 = 2; i <= 3; 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) >= GetCardLogicValue(0x02)) continue;
|
|||
|
|
//
|
|||
|
|
// cbLineCardData[cbLineLength] = cbTmpCardDate;
|
|||
|
|
// cbLineLength++;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
// SortCardList(cbLineCardData, cbLineLength, PDK_ST_ORDER);
|
|||
|
|
//
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
// tagPDKDistributing Distributing = {};
|
|||
|
|
// AnalysebDistributing(cbCardData, cbCardCount, Distributing);
|
|||
|
|
//
|
|||
|
|
// uint8 cbLastValue = GetCardLogicValue(cbLineCardData[0]);
|
|||
|
|
//
|
|||
|
|
// // <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];
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// return cbMaxThreeLength;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// return 0;
|
|||
|
|
//}
|