1941 lines
48 KiB
C++
1941 lines
48 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "GameLogic.h"
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
const BYTE 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 BYTE CGameLogic::m_cbCardData16[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 BYTE CGameLogic::m_cbCardData15[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>
|
|||
|
|
CGameLogic::CGameLogic()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CGameLogic::~CGameLogic()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
BYTE CGameLogic::GetCardType(const BYTE cbCardData[], BYTE cbCardCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
switch (cbCardCount)
|
|||
|
|
{
|
|||
|
|
case 0: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return CT_ERROR;
|
|||
|
|
}
|
|||
|
|
case 1: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return CT_SINGLE;
|
|||
|
|
}
|
|||
|
|
case 2: //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (GetCardLogicValue(cbCardData[0]) == GetCardLogicValue(cbCardData[1])) return CT_DOUBLE;
|
|||
|
|
|
|||
|
|
return CT_ERROR;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagAnalyseResult 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 CT_BOMB_CARD;
|
|||
|
|
|
|||
|
|
// <20>Ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((AnalyseResult.cbBlockCount[3] == 1) && (cbCardCount == 5)) return 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 CT_FOUR_TAKE_THREE;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if ((AnalyseResult.cbBlockCount[3] == 1) && (cbCardCount == 7)) return CT_FOUR_TAKE_THREE;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//return CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 3Aը<41><D5A8>;
|
|||
|
|
if ((3 == cbCardCount) && IsHasGameRule(ePDKRuleEnum_3ABomb) && (1 == AnalyseResult.cbBlockCount[2]))
|
|||
|
|
{
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[2][0];
|
|||
|
|
BYTE cbCardValue = GetCardValue(cbCardData);
|
|||
|
|
if (0x01 == cbCardValue) // <20><>A;
|
|||
|
|
{
|
|||
|
|
return 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 CT_THREE_TAKE_TWO;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (5 == cbCardCount) return 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>
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[1][0];
|
|||
|
|
BYTE cbFirstLogicValue = GetCardLogicValue(cbCardData);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2>ܴ<EFBFBD>2;
|
|||
|
|
if (cbFirstLogicValue >= GetCardLogicValue(0x02)) return CT_ERROR;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
for (BYTE i = 1; i < AnalyseResult.cbBlockCount[1]; i++)
|
|||
|
|
{
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[1][i * 2];
|
|||
|
|
if (cbFirstLogicValue != (GetCardLogicValue(cbCardData) + i)) return CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((AnalyseResult.cbBlockCount[1] * 2) == cbCardCount) return CT_DOUBLE_LINE;
|
|||
|
|
|
|||
|
|
return 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>
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[0][0];
|
|||
|
|
BYTE cbFirstLogicValue = GetCardLogicValue(cbCardData);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʋ<EFBFBD><C6B2>ܴ<EFBFBD>2;
|
|||
|
|
if (cbFirstLogicValue >= GetCardLogicValue(0x02)) return CT_ERROR;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
for (BYTE i = 1; i < AnalyseResult.cbBlockCount[0]; i++)
|
|||
|
|
{
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[0][i];
|
|||
|
|
if (cbFirstLogicValue != (GetCardLogicValue(cbCardData) + i)) return CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return 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 CT_ERROR;
|
|||
|
|
BYTE cbCardType = CT_ERROR;
|
|||
|
|
|
|||
|
|
BYTE cbLineCardData[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++)
|
|||
|
|
{
|
|||
|
|
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, ST_ORDER);
|
|||
|
|
|
|||
|
|
BYTE cbLastValue = GetCardLogicValue(cbLineCardData[0]);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(3~A)
|
|||
|
|
if (cbLastValue > GetCardLogicValue(0x01)) return CT_ERROR;
|
|||
|
|
|
|||
|
|
// <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><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
if (isLastCard && (cbMaxThreeLength * 5 >= cbCardCount))
|
|||
|
|
{
|
|||
|
|
cbCardType = CT_THREE_LINE;
|
|||
|
|
}
|
|||
|
|
else if (!isLastCard)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>㼸<EFBFBD><E3BCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbTmpBlockCount = cbCardCount / 5;
|
|||
|
|
if (cbMaxThreeLength == cbTmpBlockCount)
|
|||
|
|
{
|
|||
|
|
cbCardType = CT_THREE_LINE;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbCardType;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return CT_ERROR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
VOID CGameLogic::SortCardList(BYTE cbCardData[], BYTE cbCardCount, BYTE cbSortType)
|
|||
|
|
{
|
|||
|
|
//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount==0) return;
|
|||
|
|
if (cbSortType==ST_CUSTOM) return;
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
BYTE cbSortValue[MAX_COUNT];
|
|||
|
|
for (BYTE i=0;i<cbCardCount;i++) cbSortValue[i]=GetCardLogicValue(cbCardData[i]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool bSorted=true;
|
|||
|
|
BYTE cbSwitchData=0,cbLast=cbCardCount-1;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
bSorted=true;
|
|||
|
|
for (BYTE 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==ST_COUNT)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbCardIndex=0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult;
|
|||
|
|
AnalysebCardData(&cbCardData[cbCardIndex],cbCardCount-cbCardIndex,AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>˿<EFBFBD>
|
|||
|
|
for (BYTE i=0;i<CountArray(AnalyseResult.cbBlockCount);i++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbIndex=CountArray(AnalyseResult.cbBlockCount)-i-1;
|
|||
|
|
CopyMemory(&cbCardData[cbCardIndex],AnalyseResult.cbCardData[cbIndex],AnalyseResult.cbBlockCount[cbIndex]*(cbIndex+1)*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbCardIndex+=AnalyseResult.cbBlockCount[cbIndex]*(cbIndex+1)*sizeof(BYTE);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
VOID CGameLogic::RandCard16List(BYTE cbCardBuffer[], BYTE cbBufferCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
BYTE cbCardData[CountArray(m_cbCardData16)];
|
|||
|
|
CopyMemory(cbCardData, m_cbCardData16, sizeof(m_cbCardData16));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbRandCount=0,cbPosition=0;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
cbPosition=rand()%(cbBufferCount-cbRandCount);
|
|||
|
|
cbCardBuffer[cbRandCount++]=cbCardData[cbPosition];
|
|||
|
|
cbCardData[cbPosition]=cbCardData[cbBufferCount-cbRandCount];
|
|||
|
|
} while (cbRandCount<cbBufferCount);
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
VOID CGameLogic::RandCard15List(BYTE cbCardBuffer[], BYTE cbBufferCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
BYTE cbCardData[CountArray(m_cbCardData15)];
|
|||
|
|
CopyMemory(cbCardData, m_cbCardData15, sizeof(m_cbCardData15));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE 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 CGameLogic::RemoveCardList(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(cbRemoveCount<=cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbDeleteCount=0,cbTempCardData[MAX_COUNT];
|
|||
|
|
if (cbCardCount>CountArray(cbTempCardData)) return false;
|
|||
|
|
CopyMemory(cbTempCardData,cbCardData,cbCardCount*sizeof(cbCardData[0]));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (BYTE i=0;i<cbRemoveCount;i++)
|
|||
|
|
{
|
|||
|
|
for (BYTE j=0;j<cbCardCount;j++)
|
|||
|
|
{
|
|||
|
|
if (cbRemoveCard[i]==cbTempCardData[j])
|
|||
|
|
{
|
|||
|
|
cbDeleteCount++;
|
|||
|
|
cbTempCardData[j]=0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (cbDeleteCount!=cbRemoveCount) return false;
|
|||
|
|
|
|||
|
|
ZeroMemory(cbCardData,cbCardCount*sizeof(cbCardData[0]));
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbCardPos=0;
|
|||
|
|
for (BYTE i=0;i<cbCardCount;i++)
|
|||
|
|
{
|
|||
|
|
if (cbTempCardData[i]!=0) cbCardData[cbCardPos++]=cbTempCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
bool CGameLogic::RemoveCard(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(cbRemoveCount<=cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbDeleteCount=0,cbTempCardData[MAX_COUNT];
|
|||
|
|
if (cbCardCount>CountArray(cbTempCardData)) return false;
|
|||
|
|
CopyMemory(cbTempCardData,cbCardData,cbCardCount*sizeof(cbCardData[0]));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (BYTE i=0;i<cbRemoveCount;i++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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>
|
|||
|
|
BYTE cbCardPos=0;
|
|||
|
|
for (BYTE i=0;i<cbCardCount;i++)
|
|||
|
|
{
|
|||
|
|
if (cbTempCardData[i]!=0) cbCardData[cbCardPos++]=cbTempCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
bool CGameLogic::RemoveCardEx(const BYTE cbRemoveCard[], BYTE cbRemoveCount, BYTE cbCardData[], BYTE cbCardCount)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(cbRemoveCount <= cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbDeleteCount = 0;
|
|||
|
|
BYTE cbTempCardData[FULL_COUNT] = {0};
|
|||
|
|
|
|||
|
|
if (cbCardCount > CountArray(cbTempCardData)) return false;
|
|||
|
|
CopyMemory(cbTempCardData, cbCardData, cbCardCount*sizeof(cbCardData[0]));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (BYTE i = 0; i < cbRemoveCount; i++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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>
|
|||
|
|
BYTE cbCardPos = 0;
|
|||
|
|
for (BYTE i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (cbTempCardData[i] != 0)
|
|||
|
|
{
|
|||
|
|
cbCardData[cbCardPos++] = cbTempCardData[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
VOID CGameLogic::SortOutCardList(BYTE cbCardData[], BYTE cbCardCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbCardType = GetCardType(cbCardData, cbCardCount, isLastCard);
|
|||
|
|
|
|||
|
|
// AAA+BB <20>ṹ;
|
|||
|
|
if (cbCardType == CT_THREE_TAKE_TWO)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbTmpCardCount = 3;
|
|||
|
|
//CopyMemory(cbCardData, AnalyseResult.cbCardData[2], sizeof(BYTE)*cbTmpCardCount);
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] == 1)
|
|||
|
|
{
|
|||
|
|
for (BYTE i = 0; i < cbTmpCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbCardData[i] = AnalyseResult.cbCardData[2][i];
|
|||
|
|
AnalyseResult.cbCardData[2][i] = 0x0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (AnalyseResult.cbBlockCount[3] == 1)
|
|||
|
|
{
|
|||
|
|
BYTE 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(BYTE)*(i + 1)*AnalyseResult.cbBlockCount[i]);
|
|||
|
|
|
|||
|
|
cbTmpCardCount += (i + 1)*AnalyseResult.cbBlockCount[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == CT_FOUR_TAKE_THREE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData( cbCardData,cbCardCount,AnalyseResult );
|
|||
|
|
|
|||
|
|
BYTE cbTmpCardCount = 4;
|
|||
|
|
CopyMemory(cbCardData, AnalyseResult.cbCardData[3], sizeof(BYTE)*cbTmpCardCount);
|
|||
|
|
|
|||
|
|
for( int i = CountArray(AnalyseResult.cbBlockCount)-1; i >= 0; i-- )
|
|||
|
|
{
|
|||
|
|
if( i == 3 ) continue;
|
|||
|
|
|
|||
|
|
if( AnalyseResult.cbBlockCount[i] > 0 )
|
|||
|
|
{
|
|||
|
|
CopyMemory(&cbCardData[cbCardCount], AnalyseResult.cbCardData[i], sizeof(BYTE)*(i + 1)*AnalyseResult.cbBlockCount[i]);
|
|||
|
|
|
|||
|
|
cbTmpCardCount += (i + 1)*AnalyseResult.cbBlockCount[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == CT_THREE_LINE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 1)
|
|||
|
|
{
|
|||
|
|
BYTE cbLineCardData[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, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDistributing 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><E3BCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbTmpBlockCount = cbCardCount / 5;
|
|||
|
|
if (cbMaxThreeLength == cbTmpBlockCount)
|
|||
|
|
{
|
|||
|
|
//cbCardData[0] = cbMaxThreeCardData;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ϳ鳤<CDBF><E9B3A4><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>;
|
|||
|
|
BYTE cbTmpCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbMaxIndex = GetCardLogicValue(cbMaxThreeCardData);
|
|||
|
|
|
|||
|
|
BYTE cbCount = 0;
|
|||
|
|
for (BYTE cbIndex = cbMaxIndex; cbIndex > (cbMaxIndex - cbTmpBlockCount); cbIndex--)
|
|||
|
|
{
|
|||
|
|
BYTE cbTmpCount = 0;
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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 (BYTE i = 0; i <= GetCardLogicValue(0x02); i++)
|
|||
|
|
{
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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 CGameLogic::SortOutCardList(BYTE cbCardData[], BYTE cbCardCount, BYTE cbCardType, BYTE cbBlockCount)
|
|||
|
|
{
|
|||
|
|
BYTE cbMaxCardData = 0x0;
|
|||
|
|
|
|||
|
|
// AAA+BB <20>ṹ;
|
|||
|
|
if (cbCardType == CT_THREE_TAKE_TWO)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagAnalyseResult 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 == CT_FOUR_TAKE_THREE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
if (AnalyseResult.cbBlockCount[3] == 1)
|
|||
|
|
{
|
|||
|
|
cbMaxCardData = AnalyseResult.cbCardData[3][0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (cbCardType == CT_THREE_LINE)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 1)
|
|||
|
|
{
|
|||
|
|
BYTE cbLineCardData[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, ST_ORDER);
|
|||
|
|
|
|||
|
|
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 CGameLogic::IsValidCard(BYTE cbCardData)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbCardColor = GetCardColor(cbCardData);
|
|||
|
|
BYTE 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>ֵ
|
|||
|
|
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
|
|||
|
|
{
|
|||
|
|
if (!IsValidCard(cbCardData)) return 0;
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbCardColor=GetCardColor(cbCardData);
|
|||
|
|
BYTE cbCardValue=GetCardValue(cbCardData);
|
|||
|
|
|
|||
|
|
if (cbCardValue <= 0 || cbCardValue > 0x0D) return 0;
|
|||
|
|
|
|||
|
|
ASSERT(cbCardValue>0 && cbCardValue <= 0x0D);
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
//if (cbCardColor==0x40) return cbCardValue+2;
|
|||
|
|
return (cbCardValue <= 2) ? (cbCardValue + 13) : cbCardValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE CGameLogic::GetMaxLogicValue(const BYTE cbHandCardData[], BYTE cbHandCardCount)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount <= 0) return 0;
|
|||
|
|
|
|||
|
|
BYTE cbCardData[MAX_COUNT] = {0};
|
|||
|
|
CopyMemory(cbCardData, cbHandCardData, cbHandCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
SortCardList(cbCardData, cbHandCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
return GetCardLogicValue(cbCardData[0]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
bool CGameLogic::CompareCard(const BYTE cbFirstCard[], const BYTE cbNextCard[], BYTE cbFirstCount, BYTE cbNextCount, bool isLastCard)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbNextType=GetCardType(cbNextCard,cbNextCount, isLastCard);
|
|||
|
|
BYTE cbFirstType=GetCardType(cbFirstCard,cbFirstCount, false);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbNextType==CT_ERROR) return false;
|
|||
|
|
if (cbNextType==CT_3A_BOMB_CARD) return true;
|
|||
|
|
|
|||
|
|
//ը<><D5A8><EFBFBD>ж<EFBFBD>
|
|||
|
|
if ((cbFirstType!=CT_BOMB_CARD)&&(cbNextType==CT_BOMB_CARD)) return true;
|
|||
|
|
if ((cbFirstType==CT_BOMB_CARD)&&(cbNextType!=CT_BOMB_CARD)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbFirstType!=cbNextType) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD>Ա<EFBFBD>
|
|||
|
|
switch (cbNextType)
|
|||
|
|
{
|
|||
|
|
case CT_SINGLE:
|
|||
|
|
case CT_DOUBLE:
|
|||
|
|
case CT_SINGLE_LINE:
|
|||
|
|
case CT_DOUBLE_LINE:
|
|||
|
|
case CT_BOMB_CARD:
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ;
|
|||
|
|
if (cbFirstCount != cbNextCount) return false;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
BYTE cbNextLogicValue=GetCardLogicValue(cbNextCard[0]);
|
|||
|
|
BYTE cbFirstLogicValue=GetCardLogicValue(cbFirstCard[0]);
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue>cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
case 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>
|
|||
|
|
tagAnalyseResult NextResult;
|
|||
|
|
tagAnalyseResult FirstResult;
|
|||
|
|
AnalysebCardData(cbNextCard,cbNextCount,NextResult);
|
|||
|
|
AnalysebCardData(cbFirstCard,cbFirstCount,FirstResult);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
BYTE cbFirstLogicValue = 0x0;
|
|||
|
|
BYTE 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 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>
|
|||
|
|
tagAnalyseResult NextResult;
|
|||
|
|
tagAnalyseResult FirstResult;
|
|||
|
|
AnalysebCardData(cbNextCard,cbNextCount,NextResult);
|
|||
|
|
AnalysebCardData(cbFirstCard,cbFirstCount,FirstResult);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
BYTE cbNextLogicValue=GetCardLogicValue(NextResult.cbCardData[3][0]);
|
|||
|
|
BYTE cbFirstLogicValue=GetCardLogicValue(FirstResult.cbCardData[3][0]);
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue>cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
case 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 cbFirstTurnCard[MAX_COUNT] = {0};
|
|||
|
|
BYTE cbNextTurnCard[MAX_COUNT] = {0};
|
|||
|
|
CopyMemory(cbFirstTurnCard, cbFirstCard, sizeof(BYTE)*cbFirstCount);
|
|||
|
|
CopyMemory(cbNextTurnCard, cbNextCard, sizeof(BYTE)*cbNextCount);
|
|||
|
|
|
|||
|
|
BYTE cbFirstCardData = SortOutCardList(cbFirstTurnCard, cbFirstCount, CT_THREE_LINE, cbFirstBlockCount);
|
|||
|
|
BYTE cbNextCardData = SortOutCardList(cbNextTurnCard, cbNextCount, CT_THREE_LINE, cbFirstBlockCount);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
|||
|
|
BYTE cbNextLogicValue = GetCardLogicValue(cbNextCardData);
|
|||
|
|
BYTE cbFirstLogicValue = GetCardLogicValue(cbFirstCardData);
|
|||
|
|
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
return cbNextLogicValue > cbFirstLogicValue;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE CGameLogic::MakeCardData(BYTE cbLogicValue, BYTE cbColorIndex)
|
|||
|
|
{
|
|||
|
|
//return (cbColorIndex<<4)|(cbValueIndex+1);
|
|||
|
|
|
|||
|
|
BYTE cbCardColor = (cbColorIndex << 4);
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD>ֵ
|
|||
|
|
if (cbLogicValue > 0x0D)
|
|||
|
|
{
|
|||
|
|
cbLogicValue -= 0x0D;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return (cbCardColor | cbLogicValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
VOID CGameLogic::AnalysebCardData(const BYTE cbCardData[], BYTE cbCardCount, tagAnalyseResult & AnalyseResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
ZeroMemory(&AnalyseResult,sizeof(AnalyseResult));
|
|||
|
|
|
|||
|
|
//<2F>˿˷<CBBF><CBB7><EFBFBD>
|
|||
|
|
for (BYTE i=0;i<cbCardCount;i++)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbSameCount=1,cbCardValueTemp=0;
|
|||
|
|
BYTE cbLogicValue=GetCardLogicValue(cbCardData[i]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
|||
|
|
for (BYTE j=i+1;j<cbCardCount;j++)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD>˿<EFBFBD>
|
|||
|
|
if (GetCardLogicValue(cbCardData[j])!=cbLogicValue) break;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
cbSameCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(cbSameCount > 4)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
ZeroMemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
BYTE cbIndex=AnalyseResult.cbBlockCount[cbSameCount-1]++;
|
|||
|
|
for (BYTE 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 CGameLogic::AnalysebDistributing(const BYTE cbCardData[], BYTE cbCardCount, tagDistributing & Distributing)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
ZeroMemory(&Distributing,sizeof(Distributing));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
for (BYTE i=0;i<cbCardCount;i++)
|
|||
|
|
{
|
|||
|
|
//if (cbCardData[i]==0) continue;
|
|||
|
|
|
|||
|
|
////<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
//BYTE cbCardColor=GetCardColor(cbCardData[i]);
|
|||
|
|
//BYTE cbCardValue=GetCardValue(cbCardData[i]);
|
|||
|
|
|
|||
|
|
////<2F>ֲ<EFBFBD><D6B2><EFBFBD>Ϣ
|
|||
|
|
//Distributing.cbCardCount++;
|
|||
|
|
//Distributing.cbDistributing[cbCardValue-1][cbIndexCount]++;
|
|||
|
|
//Distributing.cbDistributing[cbCardValue-1][cbCardColor>>4]++;
|
|||
|
|
|
|||
|
|
if (cbCardData[i] == 0) continue;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbCardColor = GetCardColor(cbCardData[i]);
|
|||
|
|
BYTE 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>
|
|||
|
|
BYTE CGameLogic::SearchOutCard( const BYTE cbHandCardData[], BYTE cbHandCardCount, const BYTE cbTurnCardData[], BYTE cbTurnCardCount,
|
|||
|
|
tagSearchCardResult *pSearchCardResult )
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
ASSERT( pSearchCardResult != NULL );
|
|||
|
|
if( pSearchCardResult == NULL ) return 0;
|
|||
|
|
ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
tagSearchCardResult tmpSearchCardResult = {};
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbCardData[MAX_COUNT];
|
|||
|
|
BYTE cbCardCount=cbHandCardCount;
|
|||
|
|
CopyMemory(cbCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbCardData,cbCardCount,ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>(<28><>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>);
|
|||
|
|
BYTE cbTurnOutType = GetCardType(cbTurnCardData, cbTurnCardCount, false);
|
|||
|
|
|
|||
|
|
if (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(BYTE)*cbCardCount);
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
|||
|
|
switch (cbTurnOutType)
|
|||
|
|
{
|
|||
|
|
case CT_SINGLE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
case CT_DOUBLE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbReferCard = cbTurnCardData[0];
|
|||
|
|
BYTE cbSameCount = 1;
|
|||
|
|
if (cbTurnOutType == CT_DOUBLE) cbSameCount = 2;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
|||
|
|
cbResultCount = SearchSameCard(cbCardData, cbCardCount, cbReferCard, cbSameCount, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case CT_SINGLE_LINE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
cbResultCount = SearchSingleLine(cbCardData, cbCardCount, cbReferCard, cbTurnCardCount, pSearchCardResult);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case CT_DOUBLE_LINE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbReferCard = cbTurnCardData[cbTurnCardCount - 1];
|
|||
|
|
BYTE cbLineCount = cbTurnCardCount / 2;
|
|||
|
|
cbResultCount = SearchDoubleLine(cbCardData, cbCardCount, cbReferCard, cbLineCount, pSearchCardResult);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case CT_THREE_LINE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount < cbTurnCardCount) break;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϼұ<CFBC>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbBlockCount = cbTurnCardCount / 5;
|
|||
|
|
|
|||
|
|
//BYTE cbTmpTurnCard[MAX_COUNT] = {};
|
|||
|
|
//CopyMemory(cbTmpTurnCard, cbTurnCardData, sizeof(BYTE)*cbTurnCardCount);
|
|||
|
|
//SortOutCardList(cbTmpTurnCard, cbTurnCardCount, false);
|
|||
|
|
BYTE cbTmpTurnCard = SortOutCardList((BYTE*)cbTurnCardData, cbTurnCardCount, CT_THREE_LINE, cbBlockCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>(Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>);
|
|||
|
|
//BYTE cbMinLogicValue = (GetCardLogicValue(cbTmpTurnCard[0]) - cbBlockCount + 1);
|
|||
|
|
BYTE cbMinLogicValue = (GetCardLogicValue(cbTmpTurnCard) - cbBlockCount + 1);
|
|||
|
|
cbResultCount = SearchThreeLineTakeTwo(cbCardData, cbCardCount, cbMinLogicValue, cbBlockCount, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case CT_THREE_TAKE_TWO: //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount < cbTurnCardCount) break;
|
|||
|
|
|
|||
|
|
//BYTE cbTmpTurnCard[MAX_COUNT] = {};
|
|||
|
|
//CopyMemory(cbTmpTurnCard, cbTurnCardData, sizeof(BYTE)*cbTurnCardCount);
|
|||
|
|
//SortOutCardList(cbTmpTurnCard, cbTurnCardCount, false);
|
|||
|
|
|
|||
|
|
BYTE cbTmpTurnCard = SortOutCardList((BYTE*)cbTurnCardData, cbTurnCardCount, CT_THREE_TAKE_TWO, 1);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbResultCount = SearchThreeTakeTwo(cbCardData, cbCardCount, cbTmpTurnCard, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case CT_FOUR_TAKE_THREE: //<2F>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (!IsHasGameRule(ePDKRuleEnum_FOUR_TAKE_THREE)) break;
|
|||
|
|
if (cbCardCount < cbTurnCardCount) break;
|
|||
|
|
|
|||
|
|
//BYTE cbTmpTurnCard[MAX_COUNT] = {};
|
|||
|
|
//CopyMemory(cbTmpTurnCard, cbTurnCardData, sizeof(BYTE)*cbTurnCardCount);
|
|||
|
|
//SortOutCardList(cbTmpTurnCard, cbTurnCardCount, false);
|
|||
|
|
BYTE cbTmpTurnCard = SortOutCardList((BYTE*)cbTurnCardData, cbTurnCardCount, CT_FOUR_TAKE_THREE, 1);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbResultCount = SearchFourTakeThree(cbCardData, cbCardCount, cbTmpTurnCard, pSearchCardResult);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>
|
|||
|
|
if ((cbCardCount >= 4) && (cbTurnOutType != CT_3A_BOMB_CARD))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbReferCard = 0;
|
|||
|
|
if (cbTurnOutType == CT_BOMB_CARD) cbReferCard = cbTurnCardData[0];
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>
|
|||
|
|
BYTE cbTmpResultCount = SearchSameCard(cbCardData, cbCardCount, cbReferCard, 4, &tmpSearchCardResult);
|
|||
|
|
for (BYTE i = 0; i < cbTmpResultCount; i++)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = tmpSearchCardResult.cbCardCount[i];
|
|||
|
|
CopyMemory(pSearchCardResult->cbResultCard[cbResultCount], tmpSearchCardResult.cbResultCard[i],
|
|||
|
|
sizeof(BYTE)*tmpSearchCardResult.cbCardCount[i]);
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(0x01,0x11,0x21)
|
|||
|
|
if (cbTurnOutType != CT_3A_BOMB_CARD && (cbCardCount >= 3) && (IsHasGameRule(ePDKRuleEnum_3ABomb)))
|
|||
|
|
{
|
|||
|
|
BYTE cbACard[3] = { 0 };
|
|||
|
|
BYTE cbACardCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A;
|
|||
|
|
for (BYTE 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>
|
|||
|
|
BYTE CGameLogic::SearchSameCard( const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbSameCardCount,
|
|||
|
|
tagSearchCardResult *pSearchCardResult )
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if( pSearchCardResult )
|
|||
|
|
ZeroMemory(pSearchCardResult,sizeof(tagSearchCardResult));
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbCardData[MAX_COUNT];
|
|||
|
|
BYTE cbCardCount=cbHandCardCount;
|
|||
|
|
CopyMemory(cbCardData,cbHandCardData,sizeof(BYTE)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbCardData,cbCardCount,ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData( cbCardData,cbCardCount,AnalyseResult );
|
|||
|
|
|
|||
|
|
BYTE cbReferLogicValue = cbReferCard==0?0:GetCardLogicValue(cbReferCard);
|
|||
|
|
BYTE cbBlockIndex = cbSameCardCount-1;
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
for( BYTE i = 0; i < AnalyseResult.cbBlockCount[cbBlockIndex]; i++ )
|
|||
|
|
{
|
|||
|
|
BYTE 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>
|
|||
|
|
CopyMemory( pSearchCardResult->cbResultCard[cbResultCount],&AnalyseResult.cbCardData[cbBlockIndex][cbIndex],
|
|||
|
|
cbSameCardCount*sizeof(BYTE) );
|
|||
|
|
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 CGameLogic::SearchMustOutCard(const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbMustOutCard)
|
|||
|
|
{
|
|||
|
|
if (!IsValidCard(cbMustOutCard)) return false;
|
|||
|
|
|
|||
|
|
for (BYTE i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardData[i] == cbMustOutCard)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳;
|
|||
|
|
BYTE CGameLogic::SearchSingleLine(const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbLineCount, tagSearchCardResult *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>
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
BYTE cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
ZeroMemory(pSearchCardResult, sizeof(tagSearchCardResult));
|
|||
|
|
|
|||
|
|
//<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>;
|
|||
|
|
BYTE cbNormalCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (BYTE i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
BYTE cbMaxIndex = GetCardLogicValue(0x01) - cbLineCount + 1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (BYTE i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
BYTE cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
for (BYTE 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>
|
|||
|
|
BYTE cbCount = 0;
|
|||
|
|
for (BYTE cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
BYTE cbTmpCount = 0;
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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>˫˳;
|
|||
|
|
BYTE CGameLogic::SearchDoubleLine(const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbLineCount, tagSearchCardResult *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>
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
BYTE cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
ZeroMemory(pSearchCardResult, sizeof(tagSearchCardResult));
|
|||
|
|
|
|||
|
|
//<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>;
|
|||
|
|
BYTE cbNormalCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (BYTE i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
BYTE cbMaxIndex = GetCardLogicValue(0x01) - cbLineCount + 1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (BYTE i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
BYTE cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
for (BYTE 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>
|
|||
|
|
BYTE cbCount = 0;
|
|||
|
|
for (BYTE cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
BYTE cbTmpCount = 0;
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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>;
|
|||
|
|
BYTE CGameLogic::SearchThreeTakeTwo(const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, tagSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount < 5) return 0;
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
BYTE cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
ZeroMemory(pSearchCardResult, sizeof(tagSearchCardResult));
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB>2;
|
|||
|
|
if (cbReferIndex > GetCardLogicValue(0x01)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbNormalCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbNormalCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbNormalCard, cbHandCardData, sizeof(BYTE)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbNormalCard, cbNormalCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
//BYTE cbMinIndex = GetCardLogicValue(0x03);
|
|||
|
|
BYTE cbMaxIndex = GetCardLogicValue(0x01); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (BYTE 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>;
|
|||
|
|
BYTE cbTmpCount = 0;
|
|||
|
|
BYTE cbTakeCard[5] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 3) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (BYTE j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (BYTE k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
BYTE 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 (BYTE 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(BYTE)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>;
|
|||
|
|
BYTE CGameLogic::SearchFourTakeThree(const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, tagSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
if (cbHandCardCount < 7) return 0;
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
BYTE cbReferIndex = GetCardLogicValue(cbReferCard) + 1; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
ZeroMemory(pSearchCardResult, sizeof(tagSearchCardResult));
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB>2;
|
|||
|
|
if (cbReferIndex > GetCardLogicValue(0x01)) return 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbNormalCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbNormalCardCount = cbHandCardCount;
|
|||
|
|
memcpy(cbNormalCard, cbHandCardData, sizeof(BYTE)*cbHandCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbNormalCard, cbNormalCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
BYTE cbMaxIndex = GetCardLogicValue(0x01); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (BYTE 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] == 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>;
|
|||
|
|
BYTE cbTmpCount = 0;
|
|||
|
|
BYTE cbTakeCard[7] = { 0 };
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE cbColorCount = 0; cbColorCount < Distributing.cbDistributing[i][cbColorIndex]; cbColorCount++)
|
|||
|
|
{
|
|||
|
|
cbTakeCard[cbTmpCount++] = MakeCardData(i, cbColorIndex);
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 4) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cbTmpCount == 4) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (BYTE j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (BYTE k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
BYTE 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 (BYTE 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(BYTE)*cbTmpCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbTmpCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD>;
|
|||
|
|
BYTE CGameLogic::SearchThreeLineTakeTwo(const BYTE cbHandCardData[], BYTE cbHandCardCount, BYTE cbReferCard, BYTE cbBlockCount, tagSearchCardResult *pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
|||
|
|
if (pSearchCardResult == nullptr) return 0;
|
|||
|
|
if (!IsValidCard(cbReferCard)) return 0;
|
|||
|
|
if (cbHandCardCount < cbBlockCount * 5) return 0;
|
|||
|
|
|
|||
|
|
BYTE 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(tagSearchCardResult));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>;
|
|||
|
|
BYTE cbNormalCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbNormalCardCount = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC>
|
|||
|
|
for (BYTE i = 0; i < cbHandCardCount; i++)
|
|||
|
|
{
|
|||
|
|
cbNormalCard[cbNormalCardCount++] = cbHandCardData[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
SortCardList(cbNormalCard, cbNormalCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
BYTE cbResultCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>(<28>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ);
|
|||
|
|
tagDistributing Distributing = {};
|
|||
|
|
AnalysebDistributing(cbNormalCard, cbNormalCardCount, Distributing);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|||
|
|
BYTE cbMaxIndex = GetCardLogicValue(0x01) - cbBlockCount + 1;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (BYTE i = cbReferIndex; i <= cbMaxIndex; i++)
|
|||
|
|
{
|
|||
|
|
if ((Distributing.cbDistributing[i][cbIndexCount] < 1) && (i != cbMaxIndex)) continue;
|
|||
|
|
|
|||
|
|
BYTE cbTmpLinkCount = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbUseMagicCount = 0; // <20>Ѿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbTmpCard[MAX_COUNT] = { 0 };
|
|||
|
|
|
|||
|
|
for (BYTE 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>
|
|||
|
|
BYTE cbCount = 0;
|
|||
|
|
for (BYTE cbIndex = i; cbIndex <= j; cbIndex++)
|
|||
|
|
{
|
|||
|
|
BYTE cbTmpCount = 0;
|
|||
|
|
for (BYTE cbColorIndex = 0; cbColorIndex < 4; cbColorIndex++)
|
|||
|
|
{
|
|||
|
|
for (BYTE 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>;
|
|||
|
|
BYTE cbTakeCard[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbTakeCardCount = cbNormalCardCount;
|
|||
|
|
CopyMemory(cbTakeCard, cbNormalCard, sizeof(BYTE)*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>;
|
|||
|
|
tagAnalyseResult AnalyseResult = {};
|
|||
|
|
AnalysebCardData(cbTakeCard, cbTakeCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
for (BYTE j = 0; j < CountArray(AnalyseResult.cbBlockCount); j++)
|
|||
|
|
{
|
|||
|
|
for (BYTE k = 0; k < AnalyseResult.cbBlockCount[j]; k++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
BYTE cbIndex = (AnalyseResult.cbBlockCount[j] - k - 1)*(j + 1);
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>;
|
|||
|
|
for (BYTE 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 != 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(BYTE)*cbCount);
|
|||
|
|
pSearchCardResult->cbCardCount[cbResultCount] = cbCount;
|
|||
|
|
cbResultCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pSearchCardResult)
|
|||
|
|
{
|
|||
|
|
pSearchCardResult->cbSearchCount = cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbResultCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
////<2F>õ<EFBFBD><C3B5>ɻ<EFBFBD><C9BB>Ŀ<EFBFBD><C4BF><EFBFBD>С;
|
|||
|
|
//BYTE CGameLogic::GetThreeLineBlockCount(const BYTE cbCardData[], BYTE 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>
|
|||
|
|
// tagAnalyseResult AnalyseResult = {};
|
|||
|
|
// AnalysebCardData(cbCardData, cbCardCount, AnalyseResult);
|
|||
|
|
//
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
// if (AnalyseResult.cbBlockCount[2] + AnalyseResult.cbBlockCount[3] > 1)
|
|||
|
|
// {
|
|||
|
|
// BYTE cbLineCardData[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, ST_ORDER);
|
|||
|
|
//
|
|||
|
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
// tagDistributing 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];
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// return cbMaxThreeLength;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// return 0;
|
|||
|
|
//}
|