557 lines
14 KiB
C++
557 lines
14 KiB
C++
|
|
#include "Stdafx.h"
|
|||
|
|
#include "AndroidUserItemSink.h"
|
|||
|
|
#include "AndroidServiceManager.h"
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
#define TIME_LESS 1 //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
#define TIME_DISPATCH 5 //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
|
|||
|
|
//<2F><>Ϸʱ<CFB7><CAB1>
|
|||
|
|
#define TIME_OUT_CARD 3 //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
#define TIME_START_GAME 8 //<2F><>ʼʱ<CABC><CAB1>
|
|||
|
|
#define TIME_CALL_SCORE 5 //<2F>з<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
|
|||
|
|
//<2F><>Ϸʱ<CFB7><CAB1>
|
|||
|
|
#define IDI_OUT_CARD (0) //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
#define IDI_START_GAME (1) //<2F><>ʼʱ<CABC><CAB1>
|
|||
|
|
#define IDI_CALL_SCORE (2) //<2F>з<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CAndroidUserItemSink::CAndroidUserItemSink()
|
|||
|
|
{
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
m_wBankerUser=INVALID_CHAIR;
|
|||
|
|
m_cbCurrentLandScore = 255 ; //<2F>ѽз<D1BD><D0B7><EFBFBD>
|
|||
|
|
m_wOutCardUser = INVALID_CHAIR ;
|
|||
|
|
|
|||
|
|
//<2F>˿˱<CBBF><CBB1><EFBFBD>
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
ZeroMemory(m_cbHandCardData,sizeof(m_cbHandCardData));
|
|||
|
|
ZeroMemory(m_cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
|
|||
|
|
//<2F>ӿڱ<D3BF><DAB1><EFBFBD>
|
|||
|
|
m_pIAndroidUserItem=NULL;;
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CAndroidUserItemSink::~CAndroidUserItemSink()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ӿڲ<D3BF>ѯ
|
|||
|
|
VOID * CAndroidUserItemSink::QueryInterface(REFGUID Guid, DWORD dwQueryVer)
|
|||
|
|
{
|
|||
|
|
QUERYINTERFACE(IAndroidUserItemSink,Guid,dwQueryVer);
|
|||
|
|
QUERYINTERFACE_IUNKNOWNEX(IAndroidUserItemSink,Guid,dwQueryVer);
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
bool CAndroidUserItemSink::Initialization(IUnknownEx * pIUnknownEx)
|
|||
|
|
{
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
m_pIAndroidUserItem=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,IAndroidUserItem);
|
|||
|
|
if (m_pIAndroidUserItem==NULL) return false;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ýӿ<C3BD>
|
|||
|
|
bool CAndroidUserItemSink::RepositionSink()
|
|||
|
|
{
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
m_wBankerUser=INVALID_CHAIR;
|
|||
|
|
|
|||
|
|
//<2F>˿˱<CBBF><CBB1><EFBFBD>
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
ZeroMemory(m_cbHandCardData,sizeof(m_cbHandCardData));
|
|||
|
|
ZeroMemory(m_cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ʱ<><CAB1><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
bool CAndroidUserItemSink::OnEventTimer(UINT nTimerID)
|
|||
|
|
{
|
|||
|
|
switch (nTimerID)
|
|||
|
|
{
|
|||
|
|
case IDI_START_GAME: //<2F><>ʼ<EFBFBD><CABC>Ϸ
|
|||
|
|
{
|
|||
|
|
//<2F><>ʼ<EFBFBD>ж<EFBFBD>
|
|||
|
|
m_pIAndroidUserItem->SendUserReady(NULL,0);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_CALL_SCORE: //<2F>û<EFBFBD><C3BB>з<EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_C_CallScore CallScore;
|
|||
|
|
ZeroMemory(&CallScore,sizeof(CallScore));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
CallScore.cbCallScore=m_GameLogic.LandScore(m_pIAndroidUserItem->GetChairID(), m_cbCurrentLandScore);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pIAndroidUserItem->SendSocketData(SUB_C_CALL_SCORE,&CallScore,sizeof(CallScore));
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case IDI_OUT_CARD: //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
//<2F>˿˷<CBBF><CBB7><EFBFBD>
|
|||
|
|
tagOutCardResult OutCardResult;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
WORD wMeChairID=m_pIAndroidUserItem->GetChairID();
|
|||
|
|
|
|||
|
|
m_GameLogic.SearchOutCard(m_cbHandCardData, m_cbHandCardCount[wMeChairID], m_cbTurnCardData, m_cbTurnCardCount, m_pIAndroidUserItem->GetChairID(), m_wOutCardUser, OutCardResult);
|
|||
|
|
}
|
|||
|
|
catch(...)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>ʹ<EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD>
|
|||
|
|
ZeroMemory(OutCardResult.cbCardData, sizeof(OutCardResult.cbCardData));
|
|||
|
|
OutCardResult.cbCardCount = 10 ;
|
|||
|
|
}
|
|||
|
|
//<2F><><EFBFBD>ͺϷ<CDBA><CFB7>ж<EFBFBD>
|
|||
|
|
if (OutCardResult.cbCardCount>0 && CT_ERROR == m_GameLogic.GetCardType(OutCardResult.cbCardData, OutCardResult.cbCardCount))
|
|||
|
|
{
|
|||
|
|
ASSERT(false) ;
|
|||
|
|
ZeroMemory(&OutCardResult, sizeof(OutCardResult)) ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ȳ<EFBFBD><C8B3>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>
|
|||
|
|
if(m_cbTurnCardCount==0)
|
|||
|
|
{
|
|||
|
|
ASSERT(OutCardResult.cbCardCount>0) ;
|
|||
|
|
if(OutCardResult.cbCardCount==0)
|
|||
|
|
{
|
|||
|
|
WORD wMeChairID=m_pIAndroidUserItem->GetChairID();
|
|||
|
|
//<2F><>Сһ<D0A1><D2BB>
|
|||
|
|
OutCardResult.cbCardCount = 1 ;
|
|||
|
|
OutCardResult.cbCardData[0] = m_cbHandCardData[m_cbHandCardCount[wMeChairID] - 1];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if(OutCardResult.cbCardCount > 0)
|
|||
|
|
{
|
|||
|
|
if (!m_GameLogic.CompareCard(m_cbTurnCardData, OutCardResult.cbCardData, m_cbTurnCardCount, OutCardResult.cbCardCount))
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pIAndroidUserItem->SendSocketData(SUB_C_PASS_CARD);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (OutCardResult.cbCardCount>0)
|
|||
|
|
{
|
|||
|
|
WORD wMeChairID=m_pIAndroidUserItem->GetChairID();
|
|||
|
|
//ɾ<><C9BE><EFBFBD>˿<EFBFBD>
|
|||
|
|
m_cbHandCardCount[wMeChairID]-=OutCardResult.cbCardCount;
|
|||
|
|
m_GameLogic.RemoveCard(OutCardResult.cbCardData, OutCardResult.cbCardCount, m_cbHandCardData, m_cbHandCardCount[wMeChairID] + OutCardResult.cbCardCount);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_C_OutCard OutCard;
|
|||
|
|
ZeroMemory(&OutCard,sizeof(OutCard));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
OutCard.cbCardCount=OutCardResult.cbCardCount;
|
|||
|
|
CopyMemory(OutCard.cbCardData, OutCardResult.cbCardData, OutCardResult.cbCardCount*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wHeadSize=sizeof(OutCard)-sizeof(OutCard.cbCardData);
|
|||
|
|
m_pIAndroidUserItem->SendSocketData(SUB_C_OUT_CARD,&OutCard,wHeadSize+OutCard.cbCardCount*sizeof(BYTE));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pIAndroidUserItem->SendSocketData(SUB_C_PASS_CARD);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>Ϣ
|
|||
|
|
bool CAndroidUserItemSink::OnEventGameMessage(WORD wSubCmdID, VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
switch (wSubCmdID)
|
|||
|
|
{
|
|||
|
|
case SUB_S_GAME_START: //<2F><>Ϸ<EFBFBD><CFB7>ʼ
|
|||
|
|
{
|
|||
|
|
return OnSubGameStart(pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
case SUB_S_CALL_SCORE: //<2F>û<EFBFBD><C3BB>з<EFBFBD>
|
|||
|
|
{
|
|||
|
|
return OnSubCallScore(pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
case SUB_S_BANKER_INFO: //ׯ<><D7AF><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
{
|
|||
|
|
return OnSubBankerInfo(pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
case SUB_S_OUT_CARD: //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return OnSubOutCard(pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
case SUB_S_PASS_CARD: //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return OnSubPassCard(pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
case SUB_S_GAME_CONCLUDE: //<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
return OnSubGameEnd(pData,wDataSize);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// ASSERT(FALSE);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>Ϣ
|
|||
|
|
bool CAndroidUserItemSink::OnEventFrameMessage(WORD wSubCmdID, VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
bool CAndroidUserItemSink::OnEventSceneMessage(BYTE cbGameStatus, bool bLookonOther, VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
switch (cbGameStatus)
|
|||
|
|
{
|
|||
|
|
case GAME_SCENE_FREE: //<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_S_StatusFree));
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_StatusFree)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pData;
|
|||
|
|
IServerUserItem * pIServerUserItem=m_pIAndroidUserItem->GetMeUserItem();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (pIServerUserItem->GetUserStatus()!=US_READY)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_START_GAME+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_START_GAME,nElapse);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case GAME_SCENE_CALL: //<2F>з<EFBFBD>״̬
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_StatusCall)) return false;
|
|||
|
|
CMD_S_StatusCall * pStatusCall=(CMD_S_StatusCall *)pData;
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for (WORD i=0;i<GAME_PLAYER;i++) m_cbHandCardCount[i]=NORMAL_COUNT;
|
|||
|
|
CopyMemory(m_cbHandCardData,pStatusCall->cbHandCardData,sizeof(BYTE)*NORMAL_COUNT);
|
|||
|
|
|
|||
|
|
//<2F>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pIAndroidUserItem->GetChairID()==pStatusCall->wCurrentUser)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_CALL_SCORE+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_CALL_SCORE,nElapse+TIME_DISPATCH);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
case GAME_SCENE_PLAY: //<2F><>Ϸ״̬
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false;
|
|||
|
|
CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|||
|
|
m_cbTurnCardCount=pStatusPlay->cbTurnCardCount;
|
|||
|
|
CopyMemory(m_cbTurnCardData,pStatusPlay->cbTurnCardData,m_cbTurnCardCount*sizeof(BYTE));
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
WORD wMeChairID=m_pIAndroidUserItem->GetChairID();
|
|||
|
|
CopyMemory(m_cbHandCardCount,pStatusPlay->cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
CopyMemory(m_cbHandCardData,pStatusPlay->cbHandCardData,sizeof(BYTE)*m_cbHandCardCount[wMeChairID]);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (pStatusPlay->wCurrentUser==m_pIAndroidUserItem->GetChairID())
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_OUT_CARD+TIME_LESS+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_OUT_CARD,nElapse);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(FALSE);
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
VOID CAndroidUserItemSink::OnEventUserEnter(IAndroidUserItem * pIAndroidUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>뿪
|
|||
|
|
VOID CAndroidUserItemSink::OnEventUserLeave(IAndroidUserItem * pIAndroidUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
VOID CAndroidUserItemSink::OnEventUserScore(IAndroidUserItem * pIAndroidUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD>״̬
|
|||
|
|
VOID CAndroidUserItemSink::OnEventUserStatus(IAndroidUserItem * pIAndroidUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD>λ
|
|||
|
|
VOID CAndroidUserItemSink::OnEventUserSegment(IAndroidUserItem * pIAndroidUserItem, bool bLookonUser)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7>ʼ
|
|||
|
|
bool CAndroidUserItemSink::OnSubGameStart(VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_S_AndroidCard));
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_AndroidCard)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_AndroidCard * pAndroidCard=(CMD_S_AndroidCard *)pData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_pIAndroidUserItem->SetGameStatus(GAME_SCENE_CALL);
|
|||
|
|
m_cbCurrentLandScore = 255 ;
|
|||
|
|
|
|||
|
|
//<2F>˿˱<CBBF><CBB1><EFBFBD>
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
WORD wMeChairID=m_pIAndroidUserItem->GetChairID();
|
|||
|
|
for (WORD i=0;i<GAME_PLAYER;i++) m_cbHandCardCount[i]=NORMAL_COUNT;
|
|||
|
|
|
|||
|
|
for(WORD wChairID=0; wChairID<GAME_PLAYER; ++wChairID)
|
|||
|
|
{
|
|||
|
|
if(wChairID==wMeChairID)
|
|||
|
|
CopyMemory(m_cbHandCardData,pAndroidCard->cbHandCard[wChairID],sizeof(BYTE)*NORMAL_COUNT);
|
|||
|
|
|
|||
|
|
m_GameLogic.SetUserCard(wChairID, pAndroidCard->cbHandCard[wChairID], NORMAL_COUNT) ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
//BYTE cbLandScoreCardData[MAX_COUNT] ;
|
|||
|
|
//CopyMemory(cbLandScoreCardData, m_cbHandCardData,m_cbHandCardCount[wMeChairID]) ;
|
|||
|
|
//CopyMemory(cbLandScoreCardData+NORMAL_COUNT, pAndroidCard->cbBankerCard, 3*sizeof(BYTE)) ;
|
|||
|
|
//m_GameLogic.SetLandScoreCardData(cbLandScoreCardData, sizeof(cbLandScoreCardData)) ;
|
|||
|
|
m_GameLogic.SetBackCard(pAndroidCard->cbBankerCard, 3);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
m_GameLogic.SortCardList(m_cbHandCardData,m_cbHandCardCount[wMeChairID],ST_ORDER);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ҵ<EFBFBD><D2B4><EFBFBD>
|
|||
|
|
if (m_pIAndroidUserItem->GetChairID()==pAndroidCard->wCurrentUser)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_CALL_SCORE+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_CALL_SCORE,nElapse+TIME_DISPATCH);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB>з<EFBFBD>
|
|||
|
|
bool CAndroidUserItemSink::OnSubCallScore(VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_S_CallScore));
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_CallScore)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_CallScore * pCallScore=(CMD_S_CallScore *)pData;
|
|||
|
|
m_cbCurrentLandScore = pCallScore->cbCurrentScore ;
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pIAndroidUserItem->GetChairID()==pCallScore->wCurrentUser)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_CALL_SCORE+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_CALL_SCORE,nElapse);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ׯ<><D7AF><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
bool CAndroidUserItemSink::OnSubBankerInfo(VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_S_BankerInfo));
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_BankerInfo)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_BankerInfo * pBankerInfo=(CMD_S_BankerInfo *)pData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_pIAndroidUserItem->SetGameStatus(GAME_SCENE_PLAY);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_wBankerUser=pBankerInfo->wBankerUser;
|
|||
|
|
m_cbHandCardCount[m_wBankerUser]+=CountArray(pBankerInfo->cbBankerCard);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
if (pBankerInfo->wBankerUser==m_pIAndroidUserItem->GetChairID())
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
CopyMemory(&m_cbHandCardData[NORMAL_COUNT],pBankerInfo->cbBankerCard,sizeof(pBankerInfo->cbBankerCard));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|||
|
|
WORD wMeChairID=m_pIAndroidUserItem->GetChairID();
|
|||
|
|
m_GameLogic.SortCardList(m_cbHandCardData,m_cbHandCardCount[wMeChairID],ST_ORDER);
|
|||
|
|
}
|
|||
|
|
//<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>
|
|||
|
|
m_GameLogic.SetBackCard(pBankerInfo->wBankerUser, pBankerInfo->cbBankerCard, 3) ;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (pBankerInfo->wCurrentUser==m_pIAndroidUserItem->GetChairID())
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_OUT_CARD+TIME_LESS+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_OUT_CARD,nElapse);
|
|||
|
|
}
|
|||
|
|
m_GameLogic.SetBankerUser(pBankerInfo->wBankerUser);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CAndroidUserItemSink::OnSubOutCard(VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_OutCard * pOutCard=(CMD_S_OutCard *)pData;
|
|||
|
|
WORD wHeadSize=sizeof(CMD_S_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;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|||
|
|
if (pOutCard->wCurrentUser==pOutCard->wOutCardUser)
|
|||
|
|
{
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_cbTurnCardCount=pOutCard->cbCardCount;
|
|||
|
|
CopyMemory(m_cbTurnCardData,pOutCard->cbCardData,pOutCard->cbCardCount*sizeof(BYTE));
|
|||
|
|
m_wOutCardUser = pOutCard->wOutCardUser ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>˿<EFBFBD><CBBF><EFBFBD>Ŀ
|
|||
|
|
if (pOutCard->wOutCardUser!=m_pIAndroidUserItem->GetChairID())
|
|||
|
|
{
|
|||
|
|
m_cbHandCardCount[pOutCard->wOutCardUser]-=pOutCard->cbCardCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pIAndroidUserItem->GetChairID()==pOutCard->wCurrentUser)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_OUT_CARD+TIME_LESS+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_OUT_CARD,nElapse);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_GameLogic.RemoveUserCard(pOutCard->wOutCardUser, pOutCard->cbCardData, pOutCard->cbCardCount) ;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CAndroidUserItemSink::OnSubPassCard(VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_S_PassCard));
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_PassCard)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_PassCard * pPassCard=(CMD_S_PassCard *)pData;
|
|||
|
|
|
|||
|
|
//һ<><D2BB><EFBFBD>ж<EFBFBD>
|
|||
|
|
if (pPassCard->cbTurnOver==TRUE)
|
|||
|
|
{
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pIAndroidUserItem->GetChairID()==pPassCard->wCurrentUser)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_OUT_CARD+TIME_LESS+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_OUT_CARD,nElapse);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|||
|
|
bool CAndroidUserItemSink::OnSubGameEnd(VOID * pData, WORD wDataSize)
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(wDataSize==sizeof(CMD_S_GameConclude));
|
|||
|
|
if (wDataSize!=sizeof(CMD_S_GameConclude)) return false;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_S_GameConclude * pGameEnd=(CMD_S_GameConclude *)pData;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬
|
|||
|
|
m_pIAndroidUserItem->SetGameStatus(GAME_SCENE_FREE);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_cbTurnCardCount=0;
|
|||
|
|
ZeroMemory(m_cbTurnCardData,sizeof(m_cbTurnCardData));
|
|||
|
|
ZeroMemory(m_cbHandCardData,sizeof(m_cbHandCardData));
|
|||
|
|
ZeroMemory(m_cbHandCardCount,sizeof(m_cbHandCardCount));
|
|||
|
|
|
|||
|
|
//ɾ<><C9BE>ʱ<EFBFBD><CAB1>
|
|||
|
|
m_pIAndroidUserItem->KillGameTimer(IDI_OUT_CARD);
|
|||
|
|
m_pIAndroidUserItem->KillGameTimer(IDI_CALL_SCORE);
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|||
|
|
CGameServiceManager *pGameServiceManager=CGameServiceManager::GetInstance();
|
|||
|
|
ASSERT(pGameServiceManager!=NULL);
|
|||
|
|
if (pGameServiceManager==NULL) return true;
|
|||
|
|
WORD wServerType=pGameServiceManager->m_GameServiceOption.wServerType;
|
|||
|
|
if (wServerType!=GAME_GENRE_MATCH)
|
|||
|
|
{
|
|||
|
|
UINT nElapse=rand()%TIME_START_GAME+TIME_LESS;
|
|||
|
|
m_pIAndroidUserItem->SetGameTimer(IDI_START_GAME,nElapse);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|