1645 lines
43 KiB
C++
1645 lines
43 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "TableFrameSink.h"
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
#define IDI_CHECK_TABLE 1 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define IDI_USER_OUT_TIME 6 //<2F><><EFBFBD>ҳ<EFBFBD>ʱ
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD><CFB7>ʱ<EFBFBD><CAB1>
|
|||
|
|
enum tagServerTimerEnum
|
|||
|
|
{
|
|||
|
|
IDI_SEND_CARD = 1, //<2F><><EFBFBD>Ƽ<EFBFBD>ʱ<EFBFBD><CAB1>;
|
|||
|
|
IDI_OUT_CARD = 2, //<2F><><EFBFBD>Ƽ<EFBFBD>ʱ<EFBFBD><CAB1>;
|
|||
|
|
|
|||
|
|
IDT_SEND_CARD = 3000, //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>;
|
|||
|
|
IDT_OUT_CARD = 2000, //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CTableFrameSink::CTableFrameSink()
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pITableFrame=NULL;
|
|||
|
|
m_pGameCustomRule=NULL;
|
|||
|
|
m_pGameServiceOption=NULL;
|
|||
|
|
m_pGameServiceAttrib=NULL;
|
|||
|
|
m_bOffLineTrustee = false;
|
|||
|
|
|
|||
|
|
ZeroMemory(m_bActiveUser, sizeof(m_bActiveUser));
|
|||
|
|
|
|||
|
|
//ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_wFirstUser=INVALID_CHAIR;
|
|||
|
|
m_wBankerUser=INVALID_CHAIR;
|
|||
|
|
m_wCurrentUser=INVALID_CHAIR;
|
|||
|
|
ZeroMemory(m_cbOutCardCount,sizeof(m_cbOutCardCount));
|
|||
|
|
|
|||
|
|
for (byte i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
m_bUserTrustee[i] = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
m_wTimerControl=0;
|
|||
|
|
//m_cbBombCount=0;
|
|||
|
|
ZeroMemory(m_lBombScore, sizeof(m_lBombScore));
|
|||
|
|
ZeroMemory(m_aryOverTime, sizeof(m_aryOverTime));
|
|||
|
|
|
|||
|
|
//<2F>з<EFBFBD><D0B7><EFBFBD>Ϣ
|
|||
|
|
//m_cbBankerScore=0;
|
|||
|
|
ZeroMemory(m_bScoreInfo,sizeof(m_bScoreInfo));
|
|||
|
|
ZeroMemory(m_bScoreActive, sizeof(m_bScoreActive));
|
|||
|
|
m_cbCallScoreCount=0;
|
|||
|
|
m_cbMustOutCardData = 0x0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
m_wTurnWiner=INVALID_CHAIR;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD>Ϣ
|
|||
|
|
//ZeroMemory(m_cbBankerCard,sizeof(m_cbBankerCard));
|
|||
|
|
ZeroMemory(m_cbHandCardData,sizeof(m_cbHandCardData));
|
|||
|
|
ZeroMemory(m_cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_hControlInst = NULL;
|
|||
|
|
m_pServerControl = NULL;
|
|||
|
|
m_hControlInst = LoadLibrary(TEXT("LandServerControl.dll"));
|
|||
|
|
if ( m_hControlInst )
|
|||
|
|
{
|
|||
|
|
typedef void * (*CREATE)();
|
|||
|
|
CREATE ServerControl = (CREATE)GetProcAddress(m_hControlInst,"CreateServerControl");
|
|||
|
|
if ( ServerControl )
|
|||
|
|
{
|
|||
|
|
m_pServerControl = static_cast<IServerControl*>(ServerControl());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ZeroMemory(&m_PrivateEndInfo, sizeof(CMD_S_Private_End_Info));
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CTableFrameSink::~CTableFrameSink()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if( m_pServerControl )
|
|||
|
|
{
|
|||
|
|
delete m_pServerControl;
|
|||
|
|
m_pServerControl = NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( m_hControlInst )
|
|||
|
|
{
|
|||
|
|
FreeLibrary(m_hControlInst);
|
|||
|
|
m_hControlInst = NULL;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ӿڲ<D3BF>ѯ
|
|||
|
|
VOID * CTableFrameSink::QueryInterface(REFGUID Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
QUERYINTERFACE(ITableFrameSink,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE(ITableUserAction,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE_IUNKNOWNEX(ITableFrameSink,Guid,dwQueryVer);
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|||
|
|
VOID CTableFrameSink::RepositionSink()
|
|||
|
|
{
|
|||
|
|
ZeroMemory(m_bActiveUser, sizeof(m_bActiveUser));
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
m_wBankerUser=INVALID_CHAIR;
|
|||
|
|
m_wCurrentUser=INVALID_CHAIR;
|
|||
|
|
ZeroMemory(m_cbOutCardCount,sizeof(m_cbOutCardCount));
|
|||
|
|
ZeroMemory(m_lBombScore, sizeof(m_lBombScore));
|
|||
|
|
ZeroMemory(m_aryOverTime, sizeof(m_aryOverTime));
|
|||
|
|
|
|||
|
|
for (byte i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
m_bUserTrustee[i] = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>з<EFBFBD><D0B7><EFBFBD>Ϣ
|
|||
|
|
ZeroMemory(m_bScoreInfo, sizeof(m_bScoreInfo));
|
|||
|
|
ZeroMemory(m_bScoreActive, sizeof(m_bScoreActive));
|
|||
|
|
m_cbMustOutCardData = 0x0;
|
|||
|
|
m_cbCallScoreCount = 0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
m_wTurnWiner=INVALID_CHAIR;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD>Ϣ
|
|||
|
|
ZeroMemory(m_cbHandCardData,sizeof(m_cbHandCardData));
|
|||
|
|
ZeroMemory(m_cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_SEND_CARD);
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::Initialization(IUnknownEx * pIUnknownEx)
|
|||
|
|
{
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
m_pITableFrame=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,ITableFrame);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (m_pITableFrame==NULL)
|
|||
|
|
{
|
|||
|
|
CTraceService::TraceString(TEXT("<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> CTableFrameSink <20><>ѯ ITableFrame <20>ӿ<EFBFBD>ʧ<EFBFBD><CAA7>"),TraceLevel_Exception);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʼģʽ
|
|||
|
|
m_pITableFrame->SetStartMode(START_MODE_FULL_READY);
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
m_pGameServiceAttrib=m_pITableFrame->GetGameServiceAttrib();
|
|||
|
|
m_pGameServiceOption=m_pITableFrame->GetGameServiceOption();
|
|||
|
|
|
|||
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(m_pITableFrame->GetCustomRule()!=NULL);
|
|||
|
|
m_pGameCustomRule=(tagCustomRule *)m_pITableFrame->GetCustomRule();
|
|||
|
|
|
|||
|
|
m_bOffLineTrustee = CServerRule::IsAllowOffLineTrustee(m_pGameServiceOption->dwServerRule);
|
|||
|
|
|
|||
|
|
////////////////////////////////////////////////////////////////////////////
|
|||
|
|
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
//tagSearchCardResult mCardResult;
|
|||
|
|
|
|||
|
|
//BYTE cbHandCardData[16] = {0};
|
|||
|
|
//BYTE cbTurnCardData[16] = {0};
|
|||
|
|
|
|||
|
|
//cbHandCardData[0] = 0x01;
|
|||
|
|
//cbHandCardData[1] = 0x3c;
|
|||
|
|
//cbHandCardData[2] = 0x1c;
|
|||
|
|
//cbHandCardData[3] = 0x0c;
|
|||
|
|
//cbHandCardData[4] = 0x17;
|
|||
|
|
//cbHandCardData[5] = 0x03;
|
|||
|
|
|
|||
|
|
//cbTurnCardData[0] = 0x3a;
|
|||
|
|
//cbTurnCardData[1] = 0x2a;
|
|||
|
|
//cbTurnCardData[2] = 0x1a;
|
|||
|
|
//cbTurnCardData[3] = 0x15;
|
|||
|
|
//cbTurnCardData[4] = 0x14;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//BYTE cbResultCount = m_GameLogic.SearchOutCard(cbHandCardData, 6,
|
|||
|
|
// cbTurnCardData, 5, &mCardResult);
|
|||
|
|
|
|||
|
|
//if (cbResultCount > 0)
|
|||
|
|
//{
|
|||
|
|
// return true;
|
|||
|
|
//}
|
|||
|
|
////////////////////////////////////////////////////////////////////////////
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
SCORE CTableFrameSink::QueryConsumeQuota(IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
return 0L;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
|
|||
|
|
SCORE CTableFrameSink::QueryLessEnterScore(WORD wChairID, IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
return 0L;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>ʼ
|
|||
|
|
bool CTableFrameSink::OnEventGameStart()
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_pITableFrame->SetGameStatus(GAME_SCENE_SEND);
|
|||
|
|
|
|||
|
|
const tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
ASSERT(nullptr != pPrivateFrame);
|
|||
|
|
m_GameLogic.SetCardRule(pPrivateFrame->dwGameRule);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
m_wTurnWiner=INVALID_CHAIR;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
srand(GetTickCount() + m_pITableFrame->GetTableID());
|
|||
|
|
|
|||
|
|
// ͳ<><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; ++i)
|
|||
|
|
{
|
|||
|
|
IServerUserItem * pIServerUserItem = m_pITableFrame->GetTableUserItem(i);
|
|||
|
|
if (nullptr == pIServerUserItem) continue;
|
|||
|
|
|
|||
|
|
BYTE cbUserStatus = pIServerUserItem->GetUserStatus();
|
|||
|
|
BYTE cbReUserStatus = pIServerUserItem->GetReUserStatus();
|
|||
|
|
if (cbUserStatus == US_PLAYING || (US_OFFLINE == cbUserStatus && cbReUserStatus == US_PLAYING))
|
|||
|
|
{
|
|||
|
|
m_bActiveUser[i] = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>;
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; ++i)
|
|||
|
|
{
|
|||
|
|
m_PrivateEndInfo.aryActiveStatus[i] = m_bActiveUser[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 16<31><36><EFBFBD><EFBFBD>;
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_HandCardCount))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
BYTE cbRandCard[FULL_COUNT] = { 0 };
|
|||
|
|
m_GameLogic.RandCard16List(cbRandCard, FULL_COUNT);
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>˿<EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_bActiveUser[i])
|
|||
|
|
{
|
|||
|
|
m_cbHandCardCount[i] = MAX_COUNT;
|
|||
|
|
CopyMemory(&m_cbHandCardData[i], &cbRandCard[i*m_cbHandCardCount[i]], sizeof(BYTE)*m_cbHandCardCount[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BYTE cbRandCard[FULL_COUNT_15] = { 0 };
|
|||
|
|
m_GameLogic.RandCard15List(cbRandCard, FULL_COUNT_15);
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>˿<EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_bActiveUser[i])
|
|||
|
|
{
|
|||
|
|
m_cbHandCardCount[i] = MAX_COUNT - 1;
|
|||
|
|
CopyMemory(&m_cbHandCardData[i], &cbRandCard[i*m_cbHandCardCount[i]], sizeof(BYTE)*m_cbHandCardCount[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_GameStart GameStart;
|
|||
|
|
ZeroMemory(&GameStart, sizeof(CMD_S_GameStart));
|
|||
|
|
GameStart.dwGameRule = pPrivateFrame->dwGameRule;
|
|||
|
|
CopyMemory(GameStart.cbCardCount, m_cbHandCardCount, sizeof(BYTE)*GAME_PLAYER);
|
|||
|
|
CopyMemory(GameStart.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_bActiveUser[i] == false) continue;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
ASSERT(CountArray(GameStart.cbCardData) >= m_cbHandCardCount[i]);
|
|||
|
|
CopyMemory(GameStart.cbCardData, m_cbHandCardData[i], sizeof(BYTE)*m_cbHandCardCount[i]);
|
|||
|
|
|
|||
|
|
m_pITableFrame->SendTableData(i, SUB_S_GAME_START, &GameStart, sizeof(GameStart));
|
|||
|
|
m_pITableFrame->SendLookonData(i, SUB_S_GAME_START, &GameStart, sizeof(GameStart));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ¼<><C2BC><EFBFBD><EFBFBD>ʼ;
|
|||
|
|
starGameRecord();
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC>ʼ<EFBFBD><CABC>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_GAME_START, &GameStart, sizeof(CMD_S_GameStart));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
m_GameLogic.SortCardList(m_cbHandCardData[i], m_cbHandCardCount[i], ST_ORDER);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ƶ<EFBFBD>ʱ<EFBFBD><CAB1>;
|
|||
|
|
m_pITableFrame->SetGameTimer(IDI_SEND_CARD, IDT_SEND_CARD, 1, 0);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnEventGameConclude(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)
|
|||
|
|
{
|
|||
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1>;
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_USER_OUT_TIME);
|
|||
|
|
|
|||
|
|
switch (cbReason)
|
|||
|
|
{
|
|||
|
|
case GER_NORMAL: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_GameConclude GameConclude;
|
|||
|
|
ZeroMemory(&GameConclude,sizeof(GameConclude));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
GameConclude.lCellScore=m_pITableFrame->GetCellScore();
|
|||
|
|
CopyMemory(GameConclude.bActiveStatus, m_bActiveUser, sizeof(m_bActiveUser));
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>˿<EFBFBD>
|
|||
|
|
BYTE cbCardIndex=0;
|
|||
|
|
for (WORD i=0;i<GAME_PLAYER;i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
GameConclude.cbCardCount[i]=m_cbHandCardCount[i];
|
|||
|
|
CopyMemory(&GameConclude.cbHandCardData[cbCardIndex],m_cbHandCardData[i],m_cbHandCardCount[i]*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbCardIndex+=m_cbHandCardCount[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
|||
|
|
tagScoreInfo ScoreInfoArray[GAME_PLAYER];
|
|||
|
|
ZeroMemory(&ScoreInfoArray,sizeof(ScoreInfoArray));
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbInitHandCount = IsHasGameRule(ePDKRuleEnum_HandCardCount) ? NORMAL_COUNT : (NORMAL_COUNT - 1);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_wBankerUser != INVALID_CHAIR)
|
|||
|
|
{
|
|||
|
|
SCORE lScore = cbInitHandCount * 2;
|
|||
|
|
SCORE lBankScore = 0;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>;
|
|||
|
|
if (wChairID == m_wBankerUser)
|
|||
|
|
{
|
|||
|
|
//ͳ<>ƻ<EFBFBD><C6BB><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i])continue;
|
|||
|
|
if (i == m_wBankerUser) continue;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ScoreInfoArray[i].lScore = 0 - lScore;
|
|||
|
|
ScoreInfoArray[i].cbType = (ScoreInfoArray[i].lScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
|
|||
|
|
lBankScore += lScore;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//ͳ<>ƻ<EFBFBD><C6BB><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i])continue;
|
|||
|
|
if (i == m_wBankerUser) continue;
|
|||
|
|
|
|||
|
|
// ͳ<><CDB3>ը<EFBFBD><D5A8><EFBFBD><EFBFBD>;
|
|||
|
|
GetBombScore(i, m_cbHandCardData[i], m_cbHandCardCount[i]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ScoreInfoArray[i].lScore = lScore;
|
|||
|
|
ScoreInfoArray[i].cbType = (ScoreInfoArray[i].lScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
|
|||
|
|
lBankScore -= lScore;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ͳ<><CDB3>ը<EFBFBD><D5A8><EFBFBD><EFBFBD>;
|
|||
|
|
GetBombScore(m_wBankerUser, m_cbHandCardData[m_wBankerUser], m_cbHandCardCount[m_wBankerUser]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ׯ<>ҵ÷<D2B5>;
|
|||
|
|
ScoreInfoArray[m_wBankerUser].lScore = lBankScore;
|
|||
|
|
ScoreInfoArray[m_wBankerUser].cbType = (lBankScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ASSERT(m_cbHandCardCount[wChairID] == 0);
|
|||
|
|
|
|||
|
|
// Ӯ<><D3AE>;
|
|||
|
|
SCORE lWinScore = 0;
|
|||
|
|
|
|||
|
|
//ͳ<>ƻ<EFBFBD><C6BB><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (i == wChairID) continue;
|
|||
|
|
if (!m_bActiveUser[i])continue;
|
|||
|
|
|
|||
|
|
SCORE lUserScore = 0;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>);
|
|||
|
|
if (m_cbHandCardCount[i] >= cbInitHandCount)
|
|||
|
|
{
|
|||
|
|
lUserScore = m_cbHandCardCount[i] * 2;
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
else if (m_cbHandCardCount[i] > 1)
|
|||
|
|
{
|
|||
|
|
lUserScore = m_cbHandCardCount[i];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lUserScore = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ScoreInfoArray[i].lScore = 0 - lUserScore;
|
|||
|
|
ScoreInfoArray[i].cbType = (ScoreInfoArray[i].lScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
|
|||
|
|
//ͳ<><CDB3>ʤ<EFBFBD><CAA4><EFBFBD>ߵ÷<DFB5>;
|
|||
|
|
lWinScore += lUserScore;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ͳ<><CDB3>ʤ<EFBFBD><CAA4><EFBFBD>ߵ÷<DFB5>
|
|||
|
|
ScoreInfoArray[wChairID].lScore = lWinScore;
|
|||
|
|
ScoreInfoArray[wChairID].cbType = (lWinScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
GameConclude.lGameScore[i] = ScoreInfoArray[i].lScore; // <20><>Ϸ<EFBFBD>÷<EFBFBD>;
|
|||
|
|
GameConclude.lBombScore[i] = m_lBombScore[i]; // ը<><D5A8><EFBFBD>÷<EFBFBD>;
|
|||
|
|
GameConclude.lAllScore[i] = GameConclude.lGameScore[i] + m_lBombScore[i];// <20>ܵ÷<DCB5>;
|
|||
|
|
|
|||
|
|
ScoreInfoArray[i].lScore = GameConclude.lAllScore[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GAME_CONCLUDE,&GameConclude,sizeof(GameConclude));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GAME_CONCLUDE,&GameConclude,sizeof(GameConclude));
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_GAME_CONCLUDE, &GameConclude, sizeof(GameConclude));
|
|||
|
|
|
|||
|
|
/********************************˽<>˳<EFBFBD>ͳ<EFBFBD><CDB3>****************************************/
|
|||
|
|
tagPrivateFrameRecordInfo* pPrivateRecord = m_pITableFrame->GetPrivateFrameRecord();
|
|||
|
|
BYTE cbFinishCout = pPrivateRecord->cbFinishCout;
|
|||
|
|
|
|||
|
|
//ͳ<>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>ϸ
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (cbFinishCout < 16)
|
|||
|
|
{
|
|||
|
|
m_PrivateEndInfo.lDetails[i][cbFinishCout] = GameConclude.lAllScore[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>
|
|||
|
|
m_PrivateEndInfo.cbFinishCout = cbFinishCout + 1;
|
|||
|
|
|
|||
|
|
m_pITableFrame->addPrivatePlayCout(1);
|
|||
|
|
/********************************˽<>˳<EFBFBD>ͳ<EFBFBD><CDB3>****************************************/
|
|||
|
|
|
|||
|
|
//<2F>ƾֽ<C6BE><D6BD><EFBFBD><EFBFBD><EFBFBD>,ÿ8<C3BF><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>㾭<EFBFBD><E3BEAD>ֵ;
|
|||
|
|
if (IsPrivateEnd())
|
|||
|
|
{
|
|||
|
|
tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
SCORE lGrade = pPrivateFrame->dwPlayCost;
|
|||
|
|
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
ScoreInfoArray[i].lGrade = lGrade;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
DataStream kDataStream;
|
|||
|
|
m_kGameRecord.StreamValue(kDataStream, true);
|
|||
|
|
m_pITableFrame->WriteTableScore(ScoreInfoArray, CountArray(ScoreInfoArray), kDataStream);
|
|||
|
|
|
|||
|
|
//<2F>Ͼ<EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>¾ֵ<C2BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
m_wFirstUser=wChairID;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|||
|
|
m_pITableFrame->ConcludeGame(GAME_SCENE_FREE);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case GER_DISMISS: //<2F><>Ϸ<EFBFBD><CFB7>ɢ
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_GameConclude GameConclude;
|
|||
|
|
ZeroMemory(&GameConclude,sizeof(GameConclude));
|
|||
|
|
|
|||
|
|
CopyMemory(GameConclude.bActiveStatus, m_bActiveUser, sizeof(m_bActiveUser));
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>˿<EFBFBD>
|
|||
|
|
BYTE cbCardIndex=0;
|
|||
|
|
for (WORD i=0;i<GAME_PLAYER;i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
GameConclude.cbCardCount[i]=m_cbHandCardCount[i];
|
|||
|
|
CopyMemory(&GameConclude.cbHandCardData[cbCardIndex],m_cbHandCardData[i],m_cbHandCardCount[i]*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
cbCardIndex+=m_cbHandCardCount[i];
|
|||
|
|
|
|||
|
|
// ͳ<><CDB3>ը<EFBFBD><D5A8><EFBFBD><EFBFBD>;
|
|||
|
|
GetBombScore(i, m_cbHandCardData[i], m_cbHandCardCount[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
|||
|
|
tagScoreInfo ScoreInfoArray[GAME_PLAYER];
|
|||
|
|
ZeroMemory(&ScoreInfoArray, sizeof(ScoreInfoArray));
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbInitHandCount = IsHasGameRule(ePDKRuleEnum_HandCardCount) ? NORMAL_COUNT : (NORMAL_COUNT - 1);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4>;
|
|||
|
|
if (m_wBankerUser != INVALID_CHAIR)
|
|||
|
|
{
|
|||
|
|
SCORE lScore = cbInitHandCount * 2;
|
|||
|
|
SCORE lBankScore = 0;
|
|||
|
|
|
|||
|
|
//ͳ<>ƻ<EFBFBD><C6BB><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i])continue;
|
|||
|
|
if (i == m_wBankerUser) continue;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ScoreInfoArray[i].lScore = 0 - lScore;
|
|||
|
|
ScoreInfoArray[i].cbType = (ScoreInfoArray[i].lScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
|
|||
|
|
lBankScore += lScore;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ׯ<>ҵ÷<D2B5>;
|
|||
|
|
ScoreInfoArray[m_wBankerUser].lScore = lBankScore;
|
|||
|
|
ScoreInfoArray[m_wBankerUser].cbType = (lBankScore >= 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
//GameConclude.lGameScore[i] = 0; // <20><>Ϸ<EFBFBD>÷<EFBFBD>;
|
|||
|
|
GameConclude.lGameScore[i] = ScoreInfoArray[i].lScore; // <20><>Ϸ<EFBFBD>÷<EFBFBD>;
|
|||
|
|
GameConclude.lBombScore[i] = m_lBombScore[i]; // ը<><D5A8><EFBFBD>÷<EFBFBD>;
|
|||
|
|
GameConclude.lAllScore[i] = m_lBombScore[i] + GameConclude.lGameScore[i]; // <20>ܵ÷<DCB5>;
|
|||
|
|
|
|||
|
|
ScoreInfoArray[i].lScore = GameConclude.lAllScore[i];
|
|||
|
|
|
|||
|
|
if (ScoreInfoArray[i].lScore > 0)
|
|||
|
|
{
|
|||
|
|
ScoreInfoArray[i].cbType = SCORE_TYPE_WIN;
|
|||
|
|
}
|
|||
|
|
else if (ScoreInfoArray[i].lScore < 0)
|
|||
|
|
{
|
|||
|
|
ScoreInfoArray[i].cbType = SCORE_TYPE_LOSE;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ScoreInfoArray[i].cbType = SCORE_TYPE_DRAW;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/********************************˽<>˳<EFBFBD>ͳ<EFBFBD><CDB3>****************************************/
|
|||
|
|
tagPrivateFrameRecordInfo* pPrivateRecord = m_pITableFrame->GetPrivateFrameRecord();
|
|||
|
|
BYTE cbFinishCout = pPrivateRecord->cbFinishCout;
|
|||
|
|
|
|||
|
|
//ͳ<>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>ϸ
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (cbFinishCout < 16)
|
|||
|
|
{
|
|||
|
|
m_PrivateEndInfo.lDetails[i][cbFinishCout] = GameConclude.lAllScore[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>
|
|||
|
|
m_PrivateEndInfo.cbFinishCout = cbFinishCout + 1;
|
|||
|
|
|
|||
|
|
m_pITableFrame->addPrivatePlayCout(1);
|
|||
|
|
/********************************˽<>˳<EFBFBD>ͳ<EFBFBD><CDB3>****************************************/
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GAME_CONCLUDE, &GameConclude, sizeof(GameConclude));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GAME_CONCLUDE, &GameConclude, sizeof(GameConclude));
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_GAME_CONCLUDE, &GameConclude, sizeof(GameConclude));
|
|||
|
|
|
|||
|
|
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
DataStream kDataStream;
|
|||
|
|
m_kGameRecord.StreamValue(kDataStream, true);
|
|||
|
|
m_pITableFrame->WriteTableScore(ScoreInfoArray, CountArray(ScoreInfoArray), kDataStream);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|||
|
|
m_pITableFrame->ConcludeGame(GAME_SCENE_FREE);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnEventSendGameScene(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbGameStatus, bool bSendSecret)
|
|||
|
|
{
|
|||
|
|
switch (cbGameStatus)
|
|||
|
|
{
|
|||
|
|
case GAME_SCENE_FREE: //<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_StatusFree StatusFree;
|
|||
|
|
ZeroMemory(&StatusFree,sizeof(StatusFree));
|
|||
|
|
|
|||
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
StatusFree.cbTimeOutCard=m_pGameCustomRule->cbTimeOutCard;
|
|||
|
|
StatusFree.cbTimeCallScore=m_pGameCustomRule->cbTimeCallScore;
|
|||
|
|
StatusFree.cbTimeStartGame=m_pGameCustomRule->cbTimeStartGame;
|
|||
|
|
StatusFree.cbTimeHeadOutCard=m_pGameCustomRule->cbTimeHeadOutCard;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
|||
|
|
return m_pITableFrame->SendGameScene(pIServerUserItem,&StatusFree,sizeof(StatusFree));
|
|||
|
|
}
|
|||
|
|
case GAME_SCENE_SEND:
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_StatusSend StatusSend;
|
|||
|
|
ZeroMemory(&StatusSend, sizeof(StatusSend));
|
|||
|
|
|
|||
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
StatusSend.cbTimeOutCard = m_pGameCustomRule->cbTimeOutCard;
|
|||
|
|
StatusSend.cbTimeCallScore = m_pGameCustomRule->cbTimeCallScore;
|
|||
|
|
StatusSend.cbTimeStartGame = m_pGameCustomRule->cbTimeStartGame;
|
|||
|
|
StatusSend.cbTimeHeadOutCard = m_pGameCustomRule->cbTimeHeadOutCard;
|
|||
|
|
|
|||
|
|
const tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
ASSERT(nullptr != pPrivateFrame);
|
|||
|
|
StatusSend.dwGameRule = pPrivateFrame->dwGameRule;
|
|||
|
|
|
|||
|
|
CopyMemory(StatusSend.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>Ϣ
|
|||
|
|
CopyMemory(StatusSend.cbHandCardCount, m_cbHandCardCount, sizeof(BYTE)*GAME_PLAYER);
|
|||
|
|
CopyMemory(StatusSend.cbHandCardData, m_cbHandCardData[wChairID], m_cbHandCardCount[wChairID] * sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
|||
|
|
bool bSendResult = m_pITableFrame->SendGameScene(pIServerUserItem, &StatusSend, sizeof(StatusSend));
|
|||
|
|
|
|||
|
|
return bSendResult;
|
|||
|
|
}
|
|||
|
|
case GAME_SCENE_CALL: //<2F>з<EFBFBD>״̬
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_StatusCall StatusCall;
|
|||
|
|
ZeroMemory(&StatusCall,sizeof(StatusCall));
|
|||
|
|
|
|||
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
StatusCall.cbTimeOutCard=m_pGameCustomRule->cbTimeOutCard;
|
|||
|
|
StatusCall.cbTimeCallScore=m_pGameCustomRule->cbTimeCallScore;
|
|||
|
|
StatusCall.cbTimeStartGame=m_pGameCustomRule->cbTimeStartGame;
|
|||
|
|
StatusCall.cbTimeHeadOutCard=m_pGameCustomRule->cbTimeHeadOutCard;
|
|||
|
|
|
|||
|
|
const tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
ASSERT(nullptr != pPrivateFrame);
|
|||
|
|
StatusCall.dwGameRule = pPrivateFrame->dwGameRule;
|
|||
|
|
CopyMemory(StatusCall.bActiveStatus, m_bActiveUser, sizeof(m_bActiveUser));
|
|||
|
|
|
|||
|
|
StatusCall.wCurrentUser = m_wCurrentUser;
|
|||
|
|
StatusCall.cbMustOutCard = m_cbMustOutCardData;
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>Ϣ
|
|||
|
|
CopyMemory(StatusCall.bScoreInfo,m_bScoreInfo,sizeof(m_bScoreInfo));
|
|||
|
|
CopyMemory(StatusCall.bScoreActive, m_bScoreActive, sizeof(m_bScoreActive));
|
|||
|
|
CopyMemory(StatusCall.cbHandCardCount, m_cbHandCardCount, sizeof(m_cbHandCardCount));
|
|||
|
|
CopyMemory(StatusCall.cbHandCardData,m_cbHandCardData[wChairID],m_cbHandCardCount[wChairID]*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
|||
|
|
bool bSendResult = m_pITableFrame->SendGameScene(pIServerUserItem,&StatusCall,sizeof(StatusCall));
|
|||
|
|
|
|||
|
|
return bSendResult;
|
|||
|
|
}
|
|||
|
|
case GAME_SCENE_PLAY: //<2F><>Ϸ״̬
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_StatusPlay StatusPlay;
|
|||
|
|
ZeroMemory(&StatusPlay,sizeof(StatusPlay));
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
StatusPlay.wBankerUser=m_wBankerUser;
|
|||
|
|
StatusPlay.wCurrentUser=m_wCurrentUser;
|
|||
|
|
StatusPlay.cbMustOutCard = m_cbMustOutCardData;
|
|||
|
|
|
|||
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
StatusPlay.cbTimeOutCard=m_pGameCustomRule->cbTimeOutCard;
|
|||
|
|
StatusPlay.cbTimeCallScore=m_pGameCustomRule->cbTimeCallScore;
|
|||
|
|
StatusPlay.cbTimeStartGame=m_pGameCustomRule->cbTimeStartGame;
|
|||
|
|
StatusPlay.cbTimeHeadOutCard=m_pGameCustomRule->cbTimeHeadOutCard;
|
|||
|
|
|
|||
|
|
const tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
ASSERT(nullptr != pPrivateFrame);
|
|||
|
|
StatusPlay.dwGameRule = pPrivateFrame->dwGameRule;
|
|||
|
|
CopyMemory(StatusPlay.bActiveStatus, m_bActiveUser, sizeof(m_bActiveUser));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
StatusPlay.wTurnWiner=m_wTurnWiner;
|
|||
|
|
StatusPlay.cbTurnCardCount=m_cbTurnCardCount;
|
|||
|
|
CopyMemory(StatusPlay.cbTurnCardData,m_cbTurnCardData,m_cbTurnCardCount*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD>Ϣ
|
|||
|
|
CopyMemory(StatusPlay.cbHandCardCount,m_cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
CopyMemory(StatusPlay.cbHandCardData,m_cbHandCardData[wChairID],sizeof(BYTE)*m_cbHandCardCount[wChairID]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
|
|||
|
|
bool bSendResult = m_pITableFrame->SendGameScene(pIServerUserItem,&StatusPlay,sizeof(StatusPlay));
|
|||
|
|
|
|||
|
|
return bSendResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ʱ<><CAB1><EFBFBD>¼<EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnTimerMessage(DWORD wTimerID, WPARAM wBindParam)
|
|||
|
|
{
|
|||
|
|
if (wTimerID == IDI_SEND_CARD)
|
|||
|
|
{
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_SEND_CARD);
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
WORD wCurrentUser = INVALID_CHAIR;
|
|||
|
|
|
|||
|
|
m_cbMustOutCardData = 0x0;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_OutCardRule) || (INVALID_CHAIR == m_wFirstUser))
|
|||
|
|
{
|
|||
|
|
// <20>ȳ<EFBFBD><C8B3><EFBFBD>;
|
|||
|
|
static BYTE g_MustOutCard[MAX_MUSTCARD_COUT] = { 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D };
|
|||
|
|
|
|||
|
|
for (WORD k = 0; k < MAX_MUSTCARD_COUT; k++)
|
|||
|
|
{
|
|||
|
|
BYTE cbMustOutCard = g_MustOutCard[k];
|
|||
|
|
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_bActiveUser[i] == false) continue;
|
|||
|
|
|
|||
|
|
for (BYTE j = 0; j < m_cbHandCardCount[i]; j++)
|
|||
|
|
{
|
|||
|
|
if (m_cbHandCardData[i][j] == cbMustOutCard)
|
|||
|
|
{
|
|||
|
|
wCurrentUser = i;
|
|||
|
|
m_cbMustOutCardData = cbMustOutCard;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>Ѿ<EFBFBD><D1BE>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (wCurrentUser != INVALID_CHAIR && m_cbMustOutCardData != 0x0) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>Ѿ<EFBFBD><D1BE>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (wCurrentUser != INVALID_CHAIR && m_cbMustOutCardData != 0x0) break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﶼû<EFB6BC><C3BB><EFBFBD><EFBFBD>3;
|
|||
|
|
if (wCurrentUser == INVALID_CHAIR && 0x0 == m_cbMustOutCardData)
|
|||
|
|
{
|
|||
|
|
RepositionSink();
|
|||
|
|
OnEventGameStart();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
wCurrentUser = m_wFirstUser;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>;
|
|||
|
|
ASSERT(INVALID_CHAIR != wCurrentUser);
|
|||
|
|
if (INVALID_CHAIR != wCurrentUser)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|||
|
|
m_wFirstUser = wCurrentUser;
|
|||
|
|
m_wCurrentUser = wCurrentUser;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_DADU))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_pITableFrame->SetGameStatus(GAME_SCENE_CALL);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
CMD_S_SendCallScore SendCallScore;
|
|||
|
|
ZeroMemory(&SendCallScore, sizeof(CMD_S_SendCallScore));
|
|||
|
|
SendCallScore.wBankerUser = m_wCurrentUser;
|
|||
|
|
SendCallScore.cbMustOutCard = m_cbMustOutCardData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_START_SCORE, &SendCallScore, sizeof(SendCallScore));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_START_SCORE, &SendCallScore, sizeof(SendCallScore));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬;
|
|||
|
|
m_pITableFrame->SetGameStatus(GAME_SCENE_PLAY);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
CMD_S_BankerInfo BankerInfo;
|
|||
|
|
ZeroMemory(&BankerInfo, sizeof(CMD_S_BankerInfo));
|
|||
|
|
BankerInfo.wBankerUser = INVALID_CHAIR;
|
|||
|
|
BankerInfo.wCurrentUser = m_wCurrentUser;
|
|||
|
|
BankerInfo.bShowMustOutCard = true;
|
|||
|
|
BankerInfo.cbMustOutCard = m_cbMustOutCardData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_BANKER_INFO, &BankerInfo, sizeof(BankerInfo));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_BANKER_INFO, &BankerInfo, sizeof(BankerInfo));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else if (wTimerID == IDI_OUT_CARD)
|
|||
|
|
{
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_OUT_CARD);
|
|||
|
|
|
|||
|
|
//״̬Ч<CCAC><D0A7>;
|
|||
|
|
ASSERT(m_pITableFrame->GetGameStatus() == GAME_SCENE_PLAY);
|
|||
|
|
if (m_pITableFrame->GetGameStatus() != GAME_SCENE_PLAY) return true;
|
|||
|
|
|
|||
|
|
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>У<EFBFBD><D0A3>;
|
|||
|
|
ASSERT(m_wCurrentUser < GAME_PLAYER && m_wCurrentUser >= 0);
|
|||
|
|
if (m_wCurrentUser > GAME_PLAYER || m_wCurrentUser < 0) return true;
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD>Ч<EFBFBD><D0A7>;
|
|||
|
|
IServerUserItem* pServerUserItem = m_pITableFrame->GetTableUserItem(m_wCurrentUser);
|
|||
|
|
ASSERT(pServerUserItem != nullptr && pServerUserItem->GetUserStatus() == US_PLAYING);
|
|||
|
|
if (pServerUserItem && pServerUserItem->GetUserStatus() != US_PLAYING) return true;
|
|||
|
|
|
|||
|
|
if (m_bActiveUser[m_wCurrentUser] == false) return true;
|
|||
|
|
//if (m_cbHandCardCount[m_wCurrentUser] != 1) return true;
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_cbHandCardCount[m_wCurrentUser] == 1)
|
|||
|
|
{
|
|||
|
|
BYTE cbCardData[MAX_COUNT] = { 0 };
|
|||
|
|
BYTE cbCardCount = 0;
|
|||
|
|
|
|||
|
|
for (BYTE i = 0; i < m_cbHandCardCount[m_wCurrentUser]; i++)
|
|||
|
|
{
|
|||
|
|
if (m_cbHandCardData[m_wCurrentUser][i] == 0) break;
|
|||
|
|
|
|||
|
|
cbCardData[cbCardCount++] = m_cbHandCardData[m_wCurrentUser][i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 1. <20>ֵ<EFBFBD><D6B5>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_cbTurnCardCount == 0)
|
|||
|
|
{
|
|||
|
|
return OnUserOutCard(m_wCurrentUser, cbCardData, cbCardCount);
|
|||
|
|
}
|
|||
|
|
// 2. Ѻ<>ϼ<EFBFBD><CFBC><EFBFBD>;
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
if (m_GameLogic.CompareCard(m_cbTurnCardData, cbCardData, m_cbTurnCardCount, cbCardCount, true))
|
|||
|
|
{
|
|||
|
|
return OnUserOutCard(m_wCurrentUser, cbCardData, cbCardCount);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return OnUserPassCard(m_wCurrentUser);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
tagSearchCardResult mCardResult;
|
|||
|
|
BYTE cbResultCount = m_GameLogic.SearchOutCard(m_cbHandCardData[m_wCurrentUser], m_cbHandCardCount[m_wCurrentUser],
|
|||
|
|
m_cbTurnCardData, m_cbTurnCardCount, &mCardResult);
|
|||
|
|
|
|||
|
|
// û<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbResultCount <= 0)
|
|||
|
|
{
|
|||
|
|
OnUserPassCard(m_wCurrentUser);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnDataBaseMessage(WORD wRequestID, VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnUserScroeNotify(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>Ϣ
|
|||
|
|
bool CTableFrameSink::OnGameMessage(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
m_cbWaitTime=0;
|
|||
|
|
switch (wSubCmdID)
|
|||
|
|
{
|
|||
|
|
case SUB_C_CALL_SCORE: //<2F>û<EFBFBD><C3BB>з<EFBFBD>
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_C_CallScore));
|
|||
|
|
if (wDataSize!=sizeof(CMD_C_CallScore)) return false;
|
|||
|
|
|
|||
|
|
//״̬Ч<CCAC><D0A7>
|
|||
|
|
ASSERT(m_pITableFrame->GetGameStatus()==GAME_SCENE_CALL);
|
|||
|
|
if (m_pITableFrame->GetGameStatus()!=GAME_SCENE_CALL) return true;
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
|
ASSERT(pIServerUserItem->GetUserStatus()==US_PLAYING);
|
|||
|
|
if (pIServerUserItem->GetUserStatus()!=US_PLAYING) return true;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_C_CallScore * pCallScore=(CMD_C_CallScore *)pData;
|
|||
|
|
|
|||
|
|
//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|||
|
|
WORD wChairID=pIServerUserItem->GetChairID();
|
|||
|
|
return OnUserCallScore(wChairID,pCallScore->bCallScore);
|
|||
|
|
}
|
|||
|
|
case SUB_C_OUT_CARD: //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_C_OutCard * pOutCard=(CMD_C_OutCard *)pData;
|
|||
|
|
WORD wHeadSize=sizeof(CMD_C_OutCard)-sizeof(pOutCard->cbCardData);
|
|||
|
|
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT((wDataSize>=wHeadSize)&&(wDataSize==(wHeadSize+pOutCard->cbCardCount*sizeof(BYTE))));
|
|||
|
|
if ((wDataSize<wHeadSize)||(wDataSize!=(wHeadSize+pOutCard->cbCardCount*sizeof(BYTE)))) return false;
|
|||
|
|
|
|||
|
|
//״̬Ч<CCAC><D0A7>
|
|||
|
|
ASSERT(m_pITableFrame->GetGameStatus()==GAME_SCENE_PLAY);
|
|||
|
|
if (m_pITableFrame->GetGameStatus()!=GAME_SCENE_PLAY) return true;
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
|
ASSERT(pIServerUserItem->GetUserStatus()==US_PLAYING);
|
|||
|
|
if (pIServerUserItem->GetUserStatus()!=US_PLAYING) return true;
|
|||
|
|
|
|||
|
|
//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|||
|
|
WORD wChairID=pIServerUserItem->GetChairID();
|
|||
|
|
return OnUserOutCard(wChairID,pOutCard->cbCardData,pOutCard->cbCardCount);
|
|||
|
|
}
|
|||
|
|
case SUB_C_PASS_CARD: //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//״̬Ч<CCAC><D0A7>
|
|||
|
|
ASSERT(m_pITableFrame->GetGameStatus()==GAME_SCENE_PLAY);
|
|||
|
|
if (m_pITableFrame->GetGameStatus()!=GAME_SCENE_PLAY) return true;
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
|
ASSERT(pIServerUserItem->GetUserStatus()==US_PLAYING);
|
|||
|
|
if (pIServerUserItem->GetUserStatus()!=US_PLAYING) return true;
|
|||
|
|
|
|||
|
|
//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|||
|
|
return OnUserPassCard(pIServerUserItem->GetChairID());
|
|||
|
|
}
|
|||
|
|
//case SUB_C_TRUSTEE:
|
|||
|
|
// {
|
|||
|
|
// //Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// ASSERT(wDataSize==sizeof(CMD_C_TRUSTEE));
|
|||
|
|
// if (wDataSize!=sizeof(CMD_C_TRUSTEE)) return false;
|
|||
|
|
|
|||
|
|
// CMD_C_TRUSTEE* pCTrustee = (CMD_C_TRUSTEE*)pData;
|
|||
|
|
|
|||
|
|
// WORD wChairID = pIServerUserItem->GetChairID();
|
|||
|
|
// if (!pCTrustee->bTrustee)
|
|||
|
|
// {
|
|||
|
|
// m_aryOverTime[wChairID] = 0;
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// return OnUserTrustee(wChairID, pCTrustee->bTrustee);
|
|||
|
|
// }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
bool CTableFrameSink::OnFrameMessage(WORD wSubCmdID, VOID * pData, WORD wDataSize, IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˽<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
void CTableFrameSink::ResetPrivateEndInfo()
|
|||
|
|
{
|
|||
|
|
ZeroMemory(&m_PrivateEndInfo, sizeof(CMD_S_Private_End_Info));
|
|||
|
|
m_wFirstUser = INVALID_CHAIR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˽<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
|||
|
|
void CTableFrameSink::GetPrivateEndInfo(DataStream &kDataStream, bool bSend)
|
|||
|
|
{
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
// <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
IServerUserItem* pServerUserItem = m_pITableFrame->GetTableUserItem(i);
|
|||
|
|
if (pServerUserItem)
|
|||
|
|
{
|
|||
|
|
m_PrivateEndInfo.lAllScore[i] = pServerUserItem->GetUserScore();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_PrivateEndInfo.StreamValue(kDataStream, bSend);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ж<EFBFBD>˽<EFBFBD>˳<EFBFBD><CBB3>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::IsPrivateEnd()
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pITableFrame != nullptr);
|
|||
|
|
if (m_pITableFrame == nullptr) return false;
|
|||
|
|
|
|||
|
|
tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
tagPrivateFrameRecordInfo* pPrivateRecord = m_pITableFrame->GetPrivateFrameRecord();
|
|||
|
|
|
|||
|
|
if ((pPrivateFrame == nullptr) || (pPrivateRecord == nullptr)) return false;
|
|||
|
|
|
|||
|
|
if (pPrivateFrame->cbGameCout <= pPrivateRecord->cbFinishCout)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD CTableFrameSink::GetRealChairCount()
|
|||
|
|
{
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_PlayCount))
|
|||
|
|
{
|
|||
|
|
return GAME_PLAYER;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return GAME_PLAYER_2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CTableFrameSink::IsHasGameRule(ePDKRuleEnum eType)
|
|||
|
|
{
|
|||
|
|
ASSERT(m_pITableFrame != nullptr);
|
|||
|
|
if (m_pITableFrame == nullptr) return false;
|
|||
|
|
|
|||
|
|
const tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
|||
|
|
if (nullptr == pPrivateFrame) return false;
|
|||
|
|
return (pPrivateFrame->dwGameRule & eType) > 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnActionUserOffLine(WORD wChairID, IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
if(m_bOffLineTrustee && wChairID == m_wCurrentUser)
|
|||
|
|
{
|
|||
|
|
//IsOfflineTrustee();
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnActionUserConnect(WORD wChairID, IServerUserItem * pIServerUserItem)
|
|||
|
|
{
|
|||
|
|
if(m_bOffLineTrustee)
|
|||
|
|
{
|
|||
|
|
if (((m_pGameServiceOption->wServerType&GAME_GENRE_MATCH)!=0)&&(pIServerUserItem->GetChairID()==m_wCurrentUser))
|
|||
|
|
{
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_USER_OUT_TIME);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnActionUserSitDown(WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
//<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
|||
|
|
if (bLookonUser==false)
|
|||
|
|
{
|
|||
|
|
ASSERT(wChairID!=INVALID_CHAIR);
|
|||
|
|
m_HistoryScore.OnEventUserEnter(wChairID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnActionUserStandUp(WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
//<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
|
|||
|
|
if (bLookonUser==false)
|
|||
|
|
{
|
|||
|
|
ASSERT(wChairID!=INVALID_CHAIR);
|
|||
|
|
m_HistoryScore.OnEventUserLeave(wChairID);
|
|||
|
|
}
|
|||
|
|
m_bUserTrustee[wChairID] = false;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>й<EFBFBD>;
|
|||
|
|
bool CTableFrameSink::OnUserTrustee(WORD wChairID, bool bTrustee)
|
|||
|
|
{
|
|||
|
|
CMD_S_TRUSTEE pSTrustee;
|
|||
|
|
pSTrustee.wTrusteeUser = wChairID;
|
|||
|
|
pSTrustee.bTrustee = bTrustee;
|
|||
|
|
|
|||
|
|
m_bUserTrustee[wChairID] = bTrustee;
|
|||
|
|
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_TRUSTEE, &pSTrustee, sizeof(CMD_S_TRUSTEE));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_TRUSTEE, &pSTrustee, sizeof(CMD_S_TRUSTEE));
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnUserPassCard(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7>״̬
|
|||
|
|
ASSERT((wChairID==m_wCurrentUser)&&(m_cbTurnCardCount!=0));
|
|||
|
|
if ((wChairID!=m_wCurrentUser)||(m_cbTurnCardCount==0)) return true;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ʊ<EFBFBD>Ѻ, <20><>û<EFBFBD>п<EFBFBD><D0BF><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_MustOutCard) && (m_cbTurnCardCount > 0))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
tagSearchCardResult mCardResult;
|
|||
|
|
BYTE cbResultCount = m_GameLogic.SearchOutCard(m_cbHandCardData[wChairID], m_cbHandCardCount[wChairID],
|
|||
|
|
m_cbTurnCardData, m_cbTurnCardCount, &mCardResult);
|
|||
|
|
|
|||
|
|
if (cbResultCount > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_OUT_CARD);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_wCurrentUser = getNextChairID(m_wCurrentUser);
|
|||
|
|
|
|||
|
|
// һ<>ֳ<EFBFBD><D6B3>ƽ<EFBFBD><C6BD><EFBFBD>;
|
|||
|
|
if (m_wCurrentUser == m_wTurnWiner)
|
|||
|
|
{
|
|||
|
|
// ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
BYTE cbCardType = m_GameLogic.GetCardType(m_cbTurnCardData, m_cbTurnCardCount, false);
|
|||
|
|
if (cbCardType >= CT_BOMB_CARD)
|
|||
|
|
{
|
|||
|
|
CalcBombScore(m_wTurnWiner);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_cbTurnCardCount = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
CMD_S_PassCard PassCard;
|
|||
|
|
PassCard.wPassCardUser=wChairID;
|
|||
|
|
PassCard.wCurrentUser=m_wCurrentUser;
|
|||
|
|
PassCard.cbTurnOver=(m_cbTurnCardCount==0)?TRUE:FALSE;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_PASS_CARD,&PassCard,sizeof(PassCard));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_PASS_CARD,&PassCard,sizeof(PassCard));
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_PASS_CARD, &PassCard, sizeof(PassCard));
|
|||
|
|
|
|||
|
|
// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD>Ƶ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_cbHandCardCount[m_wCurrentUser] == 1)
|
|||
|
|
{
|
|||
|
|
m_pITableFrame->SetGameTimer(IDI_OUT_CARD, IDT_OUT_CARD, 1, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>з<EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnUserCallScore(WORD wChairID, bool bCallScore)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7>״̬
|
|||
|
|
ASSERT(m_bScoreActive[wChairID] == FALSE);
|
|||
|
|
if (m_bScoreActive[wChairID]) return true;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ýз<C3BD>
|
|||
|
|
m_bScoreInfo[wChairID] = bCallScore;
|
|||
|
|
m_bScoreActive[wChairID] = true;
|
|||
|
|
|
|||
|
|
// ͳ<>ƽз<C6BD><D0B7><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (bCallScore) m_cbCallScoreCount++;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_CallScore CallScore;
|
|||
|
|
CallScore.wCallScoreUser=wChairID;
|
|||
|
|
CallScore.bCurrentScore = bCallScore;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_CALL_SCORE,&CallScore,sizeof(CallScore));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_CALL_SCORE,&CallScore,sizeof(CallScore));
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>û<EFBFBD><C3BB>з<EFBFBD><D0B7><EFBFBD>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_CALL_SCORE, &CallScore, sizeof(CallScore));
|
|||
|
|
|
|||
|
|
bool bStartGame = true;
|
|||
|
|
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>;
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_bActiveUser[i] == FALSE) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_bScoreActive[i] == false)
|
|||
|
|
{
|
|||
|
|
bStartGame = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD>ж<EFBFBD>
|
|||
|
|
if (bStartGame)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>˽з<CBBD>;
|
|||
|
|
if (m_cbCallScoreCount > 1)
|
|||
|
|
{
|
|||
|
|
WORD wRandUser = rand() % GAME_PLAYER;
|
|||
|
|
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
// λ<><CEBB>ת<EFBFBD><D7AA>;
|
|||
|
|
WORD j = (wRandUser + i) % GAME_PLAYER;
|
|||
|
|
|
|||
|
|
if (m_bActiveUser[j] == FALSE) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>˷<EFBFBD>;
|
|||
|
|
if (m_bScoreInfo[j])
|
|||
|
|
{
|
|||
|
|
m_wBankerUser = j;
|
|||
|
|
m_wCurrentUser = m_wBankerUser;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// һ<><D2BB><EFBFBD>˽з<CBBD>;
|
|||
|
|
else if (m_cbCallScoreCount == 1)
|
|||
|
|
{
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_bActiveUser[i] == FALSE) continue;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>˷<EFBFBD>;
|
|||
|
|
if (m_bScoreInfo[i])
|
|||
|
|
{
|
|||
|
|
m_wBankerUser = i;
|
|||
|
|
m_wCurrentUser = m_wBankerUser;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// û<>˽з<CBBD>;
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_wBankerUser = INVALID_CHAIR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_pITableFrame->SetGameStatus(GAME_SCENE_PLAY);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|||
|
|
m_wTurnWiner = m_wCurrentUser;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱش<DAB1><D8B4><EFBFBD>;
|
|||
|
|
if (m_wBankerUser != INVALID_CHAIR)
|
|||
|
|
{
|
|||
|
|
m_cbMustOutCardData = 0x0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
CMD_S_BankerInfo BankerInfo;
|
|||
|
|
ZeroMemory(&BankerInfo, sizeof(BankerInfo));
|
|||
|
|
BankerInfo.wBankerUser = m_wBankerUser;
|
|||
|
|
BankerInfo.wCurrentUser = m_wCurrentUser;
|
|||
|
|
BankerInfo.bShowMustOutCard = false;
|
|||
|
|
BankerInfo.cbMustOutCard = m_cbMustOutCardData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_BANKER_INFO, &BankerInfo, sizeof(BankerInfo));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_BANKER_INFO, &BankerInfo, sizeof(BankerInfo));
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>û<EFBFBD><C3BB>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_BANKER_INFO, &BankerInfo, sizeof(BankerInfo));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CTableFrameSink::OnUserOutCard(WORD wChairID, BYTE cbCardData[], BYTE cbCardCount)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7>״̬
|
|||
|
|
ASSERT(wChairID==m_wCurrentUser);
|
|||
|
|
if (wChairID!=m_wCurrentUser) return true;
|
|||
|
|
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
bool isLastCard = (cbCardCount == m_cbHandCardCount[wChairID]);
|
|||
|
|
BYTE cbCardType = m_GameLogic.GetCardType(cbCardData, cbCardCount, isLastCard);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (cbCardType==CT_ERROR)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (m_cbTurnCardCount!=0)
|
|||
|
|
{
|
|||
|
|
//<2F>Ա<EFBFBD><D4B1>˿<EFBFBD>
|
|||
|
|
if (m_GameLogic.CompareCard(m_cbTurnCardData,cbCardData,m_cbTurnCardCount,cbCardCount, isLastCard)==false)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3;
|
|||
|
|
if (m_cbMustOutCardData != 0x0 && !m_GameLogic.SearchMustOutCard(cbCardData, cbCardCount, m_cbMustOutCardData))
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>¼<EFBFBD>ʣ<EFBFBD><CAA3>һ<EFBFBD><D2BB><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>;
|
|||
|
|
WORD wNextChairID = getNextChairID(m_wCurrentUser);
|
|||
|
|
if (cbCardType == CT_SINGLE && (m_cbHandCardCount[wNextChairID] == 1))
|
|||
|
|
{
|
|||
|
|
if (m_GameLogic.GetCardLogicValue(cbCardData[0]) != m_GameLogic.GetMaxLogicValue(m_cbHandCardData[wChairID], m_cbHandCardCount[wChairID]))
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
if (m_GameLogic.RemoveCardList(cbCardData,cbCardCount,m_cbHandCardData[wChairID],m_cbHandCardCount[wChairID])==false)
|
|||
|
|
{
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pITableFrame->KillGameTimer(IDI_OUT_CARD);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|||
|
|
m_cbOutCardCount[wChairID]++;
|
|||
|
|
|
|||
|
|
// ֻ<><D6BB>һ<EFBFBD>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD>Ч;
|
|||
|
|
if (m_cbMustOutCardData != 0x0) m_cbMustOutCardData = 0x0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_cbTurnCardCount = cbCardCount;
|
|||
|
|
m_cbHandCardCount[wChairID] -= cbCardCount;
|
|||
|
|
CopyMemory(m_cbTurnCardData, cbCardData, sizeof(BYTE)*cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F>л<EFBFBD><D0BB>û<EFBFBD>
|
|||
|
|
m_wTurnWiner = wChairID;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>;
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_DADU) && (m_wBankerUser != INVALID_CHAIR) && (wChairID != m_wBankerUser))
|
|||
|
|
{
|
|||
|
|
m_wCurrentUser = INVALID_CHAIR;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (m_cbHandCardCount[wChairID] != 0)
|
|||
|
|
{
|
|||
|
|
if (cbCardType != CT_3A_BOMB_CARD)
|
|||
|
|
{
|
|||
|
|
m_wCurrentUser = getNextChairID(m_wCurrentUser);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_wCurrentUser = INVALID_CHAIR;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_OutCard OutCard;
|
|||
|
|
ZeroMemory(&OutCard, sizeof(CMD_S_OutCard));
|
|||
|
|
|
|||
|
|
OutCard.wOutCardUser=wChairID;
|
|||
|
|
OutCard.cbCardCount=cbCardCount;
|
|||
|
|
OutCard.wCurrentUser=m_wCurrentUser;
|
|||
|
|
OutCard.bLastCard = isLastCard;
|
|||
|
|
CopyMemory(OutCard.cbCardData,m_cbTurnCardData,m_cbTurnCardCount*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wHeadSize=sizeof(OutCard)-sizeof(OutCard.cbCardData);
|
|||
|
|
WORD wSendSize=wHeadSize+OutCard.cbCardCount*sizeof(BYTE);
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_OUT_CARD,&OutCard,wSendSize);
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_OUT_CARD,&OutCard,wSendSize);
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
addGameRecordAction(SUB_S_OUT_CARD, &OutCard, wSendSize);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardType == CT_3A_BOMB_CARD)
|
|||
|
|
{
|
|||
|
|
m_cbTurnCardCount = 0;
|
|||
|
|
|
|||
|
|
if (m_wCurrentUser == wChairID)
|
|||
|
|
{
|
|||
|
|
CalcBombScore(wChairID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (m_wCurrentUser == INVALID_CHAIR)
|
|||
|
|
{
|
|||
|
|
// ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbCardType >= CT_BOMB_CARD)
|
|||
|
|
{
|
|||
|
|
CalcBombScore(wChairID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
OnEventGameConclude(wChairID, NULL, GER_NORMAL);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD>Ƶ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_cbHandCardCount[m_wCurrentUser] == 1)
|
|||
|
|
{
|
|||
|
|
m_pITableFrame->SetGameTimer(IDI_OUT_CARD, IDT_OUT_CARD, 1, 0);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ʊ<EFBFBD>Ѻ, <20><>û<EFBFBD>п<EFBFBD><D0BF><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_cbTurnCardCount > 0)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
tagSearchCardResult mCardResult;
|
|||
|
|
BYTE cbResultCount = m_GameLogic.SearchOutCard(m_cbHandCardData[m_wCurrentUser], m_cbHandCardCount[m_wCurrentUser],
|
|||
|
|
m_cbTurnCardData, m_cbTurnCardCount, &mCardResult);
|
|||
|
|
|
|||
|
|
// û<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (cbResultCount <= 0)
|
|||
|
|
{
|
|||
|
|
m_pITableFrame->SetGameTimer(IDI_OUT_CARD, IDT_OUT_CARD, 1, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
|
|||
|
|
void CTableFrameSink::SetGameBaseScore(LONG lBaseScore)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_SET_BASESCORE,&lBaseScore,sizeof(lBaseScore));
|
|||
|
|
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_SET_BASESCORE,&lBaseScore,sizeof(lBaseScore));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8><EFBFBD><EFBFBD>;
|
|||
|
|
void CTableFrameSink::CalcBombScore(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
// У<><D0A3><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD>;
|
|||
|
|
ASSERT((wChairID >= 0) && (wChairID < GAME_PLAYER));
|
|||
|
|
if (wChairID < 0 || wChairID >= GAME_PLAYER) return;
|
|||
|
|
if (!IsHasGameRule(ePDKRuleEnum_Bomb_Score)) return;
|
|||
|
|
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (i == wChairID) continue;
|
|||
|
|
if (!m_bActiveUser[i]) continue;
|
|||
|
|
|
|||
|
|
m_lBombScore[i] -= 10;
|
|||
|
|
m_lBombScore[wChairID] += 10;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CTableFrameSink::GetBombScore(WORD wChairID, BYTE cbHandCardData[], BYTE cbHandCardCount)
|
|||
|
|
{
|
|||
|
|
if (!IsHasGameRule(ePDKRuleEnum_Bomb_Score)) return;
|
|||
|
|
if (cbHandCardCount <= 0) return;
|
|||
|
|
|
|||
|
|
// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>;
|
|||
|
|
m_GameLogic.SortCardList(cbHandCardData, cbHandCardCount, ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
tagAnalyseResult AnalyseResult;
|
|||
|
|
ZeroMemory(&AnalyseResult, sizeof(AnalyseResult));
|
|||
|
|
m_GameLogic.AnalysebCardData(cbHandCardData, cbHandCardCount, AnalyseResult);
|
|||
|
|
|
|||
|
|
// 3<><33>A
|
|||
|
|
if (IsHasGameRule(ePDKRuleEnum_3ABomb) && AnalyseResult.cbBlockCount[2] > 0)
|
|||
|
|
{
|
|||
|
|
BYTE cbACardValue = m_GameLogic.GetCardLogicValue(0x01);
|
|||
|
|
|
|||
|
|
for (BYTE j = 0; j < AnalyseResult.cbBlockCount[2]; j++)
|
|||
|
|
{
|
|||
|
|
ASSERT((j * 3) < MAX_COUNT);
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[2][j * 3];
|
|||
|
|
BYTE cbCardValue = m_GameLogic.GetCardLogicValue(cbCardData);
|
|||
|
|
|
|||
|
|
// <20>Dz<EFBFBD><C7B2><EFBFBD>A<EFBFBD><41>
|
|||
|
|
if (cbCardValue == cbACardValue)
|
|||
|
|
{
|
|||
|
|
// ͳ<><CDB3>ը<EFBFBD><D5A8>;
|
|||
|
|
CalcBombScore(wChairID);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>;
|
|||
|
|
if (AnalyseResult.cbBlockCount[3] > 0)
|
|||
|
|
{
|
|||
|
|
for (BYTE j = 0; j < AnalyseResult.cbBlockCount[3]; j++)
|
|||
|
|
{
|
|||
|
|
ASSERT((j * 4) < MAX_COUNT);
|
|||
|
|
BYTE cbCardData = AnalyseResult.cbCardData[3][j * 4];
|
|||
|
|
|
|||
|
|
if (m_GameLogic.IsValidCard(cbCardData))
|
|||
|
|
{
|
|||
|
|
// ͳ<><CDB3>ը<EFBFBD><D5A8>;
|
|||
|
|
CalcBombScore(wChairID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>Ӻ<EFBFBD>;
|
|||
|
|
WORD CTableFrameSink::getNextChairID(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
//<2F>¼<EFBFBD>ʣ<EFBFBD><CAA3>һ<EFBFBD><D2BB><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>;
|
|||
|
|
WORD wNextChairID = (wChairID + 1) % GAME_PLAYER;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(һ<><D2BB>3<EFBFBD><33>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD>˴<EFBFBD><CBB4>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>ֻ<EFBFBD>ж<EFBFBD>һ<EFBFBD>ξͺ<CEBE><CDBA><EFBFBD>);
|
|||
|
|
if (!m_bActiveUser[wNextChairID])
|
|||
|
|
{
|
|||
|
|
wNextChairID = (wNextChairID + 1) % GAME_PLAYER;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return wNextChairID;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/////////////////////////////// <20><>Ϸ¼<CFB7><C2BC> ///////////////////////////////////////////
|
|||
|
|
void CTableFrameSink::addGameRecordAction(WORD wSubCmdID, void* pSubMessage, int nMessageSize)
|
|||
|
|
{
|
|||
|
|
tagGameRecordOperateResult kOperateRecord;
|
|||
|
|
kOperateRecord.wSubCmdID = wSubCmdID;
|
|||
|
|
kOperateRecord.subMessageData.pushValue(pSubMessage, nMessageSize);
|
|||
|
|
m_kGameRecord.actionVec.push_back(kOperateRecord);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CTableFrameSink::starGameRecord()
|
|||
|
|
{
|
|||
|
|
m_kGameRecord = tagGameRecord();
|
|||
|
|
|
|||
|
|
m_kGameRecord.wBankerUser = m_wBankerUser;
|
|||
|
|
m_kGameRecord.wEastUser = 0;
|
|||
|
|
|
|||
|
|
for (WORD i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
IServerUserItem* pUserItem = m_pITableFrame->GetTableUserItem(i);
|
|||
|
|
if (pUserItem == nullptr) continue;
|
|||
|
|
tagUserInfo* pUserInfo = pUserItem->GetUserInfo();
|
|||
|
|
if (NULL == pUserInfo) continue;
|
|||
|
|
|
|||
|
|
tagGameRecordPlayer kReocrdPlayer;
|
|||
|
|
kReocrdPlayer.dwUserID = pUserItem->GetUserID();
|
|||
|
|
kReocrdPlayer.dwGameID = pUserItem->GetGameID();
|
|||
|
|
kReocrdPlayer.wChairID = pUserItem->GetChairID();
|
|||
|
|
kReocrdPlayer.cbSex = pUserItem->GetGender();
|
|||
|
|
kReocrdPlayer.lScore = pUserItem->GetUserScore();
|
|||
|
|
kReocrdPlayer.strHead = pUserInfo->szHeadHttp;
|
|||
|
|
kReocrdPlayer.strNickName = pUserItem->GetNickName();
|
|||
|
|
|
|||
|
|
for (BYTE j = 0; j < NORMAL_COUNT; j++)
|
|||
|
|
{
|
|||
|
|
kReocrdPlayer.cbCardData.push_back(m_cbHandCardData[i][j]);
|
|||
|
|
}
|
|||
|
|
m_kGameRecord.playersVec.push_back(kReocrdPlayer);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|