2663 lines
73 KiB
C++
2663 lines
73 KiB
C++
#include "StdAfx.h"
|
||
#include "TableFrameSink.h"
|
||
#include <fstream>
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
//静态变量
|
||
const WORD CTableFrameSink::m_wPlayerCount=GAME_PLAYER; //游戏人数
|
||
//const enStartMode CTableFrameSink::m_GameStartMode=enStartMode_FullReady; //开始模式
|
||
|
||
#define DROPPED_DEFAULT 0 // 自动掉线
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
//构造函数
|
||
CTableFrameSink::CTableFrameSink()
|
||
{
|
||
//游戏变量
|
||
m_wSiceCount=MAKEWORD(1,1);
|
||
m_wSiceCount2=MAKEWORD(1,1);
|
||
m_wSiceCount3=MAKEWORD(1,1);
|
||
m_wBankerUser=INVALID_CHAIR;
|
||
ZeroMemory(m_bCallCard,sizeof(m_bCallCard));
|
||
ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex));
|
||
ZeroMemory(m_cbBatch,sizeof(m_cbBatch));
|
||
ZeroMemory(m_bTrustee,sizeof(m_bTrustee));
|
||
ZeroMemory(m_bBatchEnd,sizeof(m_bBatchEnd));
|
||
|
||
//出牌信息
|
||
m_cbOutCardData=0;
|
||
m_cbOutCardCount=0;
|
||
m_wOutCardUser=INVALID_CHAIR;
|
||
ZeroMemory(m_cbDiscardCard,sizeof(m_cbDiscardCard));
|
||
ZeroMemory(m_cbDiscardCount,sizeof(m_cbDiscardCount));
|
||
m_cbGangCount=0;
|
||
m_BankContinueCount = 1;
|
||
m_cbMustLeft =MUST_LEFT_COUNT;
|
||
|
||
//历史积分
|
||
memset(m_lAllTurnScore,0,sizeof(m_lAllTurnScore));
|
||
memset(m_lLastTurnScore,0,sizeof(m_lLastTurnScore));
|
||
memset(m_cbAllGangCounts, 0, sizeof(m_cbAllGangCounts));
|
||
|
||
|
||
ZeroMemory(m_cbDelCardIndex, sizeof(m_cbDelCardIndex));
|
||
|
||
//发牌信息
|
||
m_cbSendCardData=0;
|
||
m_cbSendCardCount=0;
|
||
m_cbLeftCardCount=0;
|
||
ZeroMemory(m_cbRepertoryCard,sizeof(m_cbRepertoryCard));
|
||
|
||
//运行变量
|
||
m_cbProvideCard=0;
|
||
m_wResumeUser=INVALID_CHAIR;
|
||
m_wCurrentUser=INVALID_CHAIR;
|
||
m_wProvideUser=INVALID_CHAIR;
|
||
|
||
//状态变量
|
||
m_bSendStatus=false;
|
||
m_bGangStatus=false;
|
||
//ZeroMemory(m_bEnjoinChiHu,sizeof(m_bEnjoinChiHu));
|
||
|
||
//用户状态
|
||
ZeroMemory(m_bResponse,sizeof(m_bResponse));
|
||
ZeroMemory(m_wUserAction,sizeof(m_wUserAction));
|
||
ZeroMemory(m_cbOperateCard,sizeof(m_cbOperateCard));
|
||
ZeroMemory(m_wPerformAction,sizeof(m_wPerformAction));
|
||
|
||
//组合扑克
|
||
ZeroMemory(m_WeaveItemArray,sizeof(m_WeaveItemArray));
|
||
ZeroMemory(m_cbWeaveItemCount,sizeof(m_cbWeaveItemCount));
|
||
|
||
//结束信息
|
||
m_cbChiHuCard=0;
|
||
ZeroMemory(&m_ChiHuResult,sizeof(m_ChiHuResult));
|
||
|
||
ZeroMemory(m_cbMasterCheckCard, sizeof(m_cbMasterCheckCard));
|
||
|
||
//组件变量
|
||
m_pITableFrame=NULL;
|
||
m_pGameServiceOption=NULL;
|
||
|
||
|
||
ZeroMemory(m_genDaLiHuCards, sizeof(m_genDaLiHuCards));
|
||
ZeroMemory(m_genHuCards, sizeof(m_genHuCards));
|
||
ZeroMemory(m_genPengCards, sizeof(m_genPengCards));
|
||
|
||
ZeroMemory(m_cbContinueGangs, sizeof(m_cbContinueGangs));
|
||
ZeroMemory(m_cbContinueGangTypes, sizeof(m_cbContinueGangTypes));
|
||
|
||
m_wDropped = 0;
|
||
|
||
m_wProvideMingGangUser = INVALID_CHAIR;
|
||
|
||
ZeroMemory(m_bActiveUser, sizeof(m_bActiveUser));
|
||
|
||
return;
|
||
}
|
||
|
||
//析构函数
|
||
CTableFrameSink::~CTableFrameSink(void)
|
||
{
|
||
}
|
||
|
||
//接口查询
|
||
void * CTableFrameSink::QueryInterface(const IID & Guid, DWORD dwQueryVer)
|
||
{
|
||
QUERYINTERFACE(ITableFrameSink,Guid,dwQueryVer);
|
||
QUERYINTERFACE(ITableUserAction,Guid,dwQueryVer);
|
||
#ifdef __SPECIAL___
|
||
QUERYINTERFACE(ITableUserActionEX,Guid,dwQueryVer);
|
||
#endif
|
||
QUERYINTERFACE_IUNKNOWNEX(ITableFrameSink,Guid,dwQueryVer);
|
||
return NULL;
|
||
}
|
||
|
||
//初始化
|
||
bool CTableFrameSink::Initialization(IUnknownEx * pIUnknownEx)
|
||
{
|
||
//查询接口
|
||
ASSERT(pIUnknownEx!=NULL);
|
||
m_pITableFrame=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,ITableFrame);
|
||
if (m_pITableFrame==NULL) return false;
|
||
|
||
//获取参数
|
||
m_pGameServiceOption=m_pITableFrame->GetGameServiceOption();
|
||
ASSERT(m_pGameServiceOption!=NULL);
|
||
|
||
srand(GetTickCount() | (m_pITableFrame->GetTableID() << 8));
|
||
|
||
//开始模式
|
||
m_pITableFrame->SetStartMode(START_MODE_FULL_READY);
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
//
|
||
//m_bSendStatus = true;
|
||
//m_bGangStatus = true;
|
||
//
|
||
|
||
////发牌处理
|
||
//if (m_bSendStatus == true)
|
||
//{
|
||
//
|
||
|
||
// //牌型权位
|
||
// WORD wChiHuRight = 0;
|
||
// if (m_bGangStatus == true) wChiHuRight |= CHR_QIANG_GANG;
|
||
|
||
// WORD wCurrentUser = 2;
|
||
|
||
// BYTE cbRule = eWNMJHURuleEnum_YiBianDaoHU;
|
||
|
||
// m_cbSendCardData = 0x12;
|
||
|
||
// //胡牌判断
|
||
// BYTE cbTempCardIndex[MAX_INDEX] = {0};
|
||
// BYTE cbTempCardData[MAX_COUNT] = { 0 };
|
||
|
||
// cbTempCardData[0] = 0x23;
|
||
// cbTempCardData[1] = 0x23;
|
||
// cbTempCardData[2] = 0x29;
|
||
// cbTempCardData[3] = 0x29;
|
||
// //0x31, 0x33, 0x34,
|
||
// cbTempCardData[4] = 0x31;
|
||
// cbTempCardData[5] = 0x33;
|
||
// cbTempCardData[6] = 0x34;
|
||
|
||
// for (int i = 0; i < MAX_COUNT; i++)
|
||
// {
|
||
// if (cbTempCardData[i] != 0)
|
||
// {
|
||
// cbTempCardIndex[m_GameLogic.SwitchToCardIndex(cbTempCardData[i])]++;
|
||
// }
|
||
// }
|
||
|
||
// // 组合牌;
|
||
// m_WeaveItemArray[wCurrentUser][0].wWeaveKind = WIK_GANG;
|
||
// m_WeaveItemArray[wCurrentUser][0].cbCenterCard = 0x25;
|
||
|
||
// m_WeaveItemArray[wCurrentUser][1].wWeaveKind = WIK_PENG;
|
||
// m_WeaveItemArray[wCurrentUser][1].cbCenterCard = 0x21;
|
||
|
||
// m_cbWeaveItemCount[wCurrentUser] = 2;
|
||
//
|
||
// m_wUserAction[wCurrentUser] = 0;
|
||
|
||
// tagChiHuResult ChiHuResult;
|
||
// m_wUserAction[wCurrentUser] |= m_GameLogic.AnalyseChiHuCard(cbTempCardIndex,
|
||
// m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, wChiHuRight, ChiHuResult, cbRule, true, (m_bGangStatus ? false : true));
|
||
|
||
// if (m_bGangStatus && ((m_wUserAction[wCurrentUser] & WIK_CHI_HU) != WIK_CHI_HU))
|
||
// {
|
||
// bool bTingCard = m_GameLogic.IsTingCard(cbTempCardIndex, m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, wChiHuRight, ChiHuResult, cbRule);
|
||
// if (!bTingCard)
|
||
// {
|
||
// m_wUserAction[wCurrentUser] |= m_GameLogic.AnalyseTingCard(cbTempCardIndex, m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, wChiHuRight, ChiHuResult, cbRule, true, false, bTingCard);
|
||
// }
|
||
// else
|
||
// {
|
||
// m_wUserAction[wCurrentUser] |= WIK_CHI_HU;
|
||
// }
|
||
// }
|
||
//}
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
return true;
|
||
}
|
||
|
||
//复位桌子
|
||
void CTableFrameSink::RepositionSink()
|
||
{
|
||
//游戏变量
|
||
m_wSiceCount=MAKEWORD(1,1);
|
||
m_wSiceCount2=MAKEWORD(1,1);
|
||
m_wSiceCount3=MAKEWORD(1,1);
|
||
ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex));
|
||
ZeroMemory(m_bCallCard,sizeof(m_bCallCard));
|
||
ZeroMemory(m_cbBatch,sizeof(m_cbBatch));
|
||
ZeroMemory(m_bTrustee,sizeof(m_bTrustee));
|
||
ZeroMemory(m_bBatchEnd,sizeof(m_bBatchEnd));
|
||
|
||
|
||
//出牌信息
|
||
m_cbOutCardData=0;
|
||
m_cbOutCardCount=0;
|
||
m_wOutCardUser=INVALID_CHAIR;
|
||
ZeroMemory(m_cbDiscardCard,sizeof(m_cbDiscardCard));
|
||
ZeroMemory(m_cbDiscardCount,sizeof(m_cbDiscardCount));
|
||
m_cbGangCount=0;
|
||
m_cbMustLeft =MUST_LEFT_COUNT;
|
||
|
||
ZeroMemory(m_cbDelCardIndex, sizeof(m_cbDelCardIndex));
|
||
|
||
//发牌信息
|
||
m_cbSendCardData=0;
|
||
m_cbSendCardCount=0;
|
||
m_cbLeftCardCount=0;
|
||
ZeroMemory(m_cbRepertoryCard,sizeof(m_cbRepertoryCard));
|
||
|
||
|
||
//运行变量
|
||
m_cbProvideCard=0;
|
||
m_wResumeUser=INVALID_CHAIR;
|
||
m_wCurrentUser=INVALID_CHAIR;
|
||
m_wProvideUser=INVALID_CHAIR;
|
||
|
||
//状态变量
|
||
m_bSendStatus=false;
|
||
m_bGangStatus=false;
|
||
//ZeroMemory(m_bEnjoinChiHu,sizeof(m_bEnjoinChiHu));
|
||
|
||
//用户状态
|
||
ZeroMemory(m_bResponse,sizeof(m_bResponse));
|
||
ZeroMemory(m_wUserAction,sizeof(m_wUserAction));
|
||
ZeroMemory(m_cbOperateCard,sizeof(m_cbOperateCard));
|
||
ZeroMemory(m_wPerformAction,sizeof(m_wPerformAction));
|
||
|
||
//组合扑克
|
||
ZeroMemory(m_WeaveItemArray,sizeof(m_WeaveItemArray));
|
||
ZeroMemory(m_cbWeaveItemCount,sizeof(m_cbWeaveItemCount));
|
||
|
||
//结束信息
|
||
m_cbChiHuCard=0;
|
||
ZeroMemory(&m_ChiHuResult,sizeof(m_ChiHuResult));
|
||
|
||
m_wCheatChairID = INVALID_CHAIR;
|
||
|
||
ZeroMemory(m_genDaLiHuCards, sizeof(m_genDaLiHuCards));
|
||
ZeroMemory(m_genHuCards, sizeof(m_genHuCards));
|
||
ZeroMemory(m_genPengCards, sizeof(m_genPengCards));
|
||
|
||
ZeroMemory(m_cbContinueGangs, sizeof(m_cbContinueGangs));
|
||
ZeroMemory(m_GangPaiResult, sizeof(m_GangPaiResult));
|
||
ZeroMemory(m_cbContinueGangTypes, sizeof(m_cbContinueGangTypes));
|
||
|
||
m_wProvideMingGangUser = INVALID_CHAIR;
|
||
ZeroMemory(m_bActiveUser, sizeof(m_bActiveUser));
|
||
|
||
return;
|
||
}
|
||
|
||
////开始模式
|
||
//enStartMode CTableFrameSink::GetGameStartMode()
|
||
//{
|
||
// return m_GameStartMode;
|
||
//}
|
||
|
||
//游戏状态
|
||
bool CTableFrameSink::IsUserPlaying(WORD wChairID)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
//游戏结束
|
||
bool CTableFrameSink::OnEventGameConclude(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason)
|
||
{
|
||
switch (cbReason)
|
||
{
|
||
case GER_NORMAL: //常规结束
|
||
{
|
||
//变量定义
|
||
CMD_S_GameEnd GameEnd;
|
||
ZeroMemory(&GameEnd,sizeof(GameEnd));
|
||
|
||
//结束信息
|
||
GameEnd.wProvideUser=m_wProvideUser;
|
||
GameEnd.cbChiHuCard=m_cbChiHuCard;
|
||
CopyMemory(GameEnd.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
||
|
||
//统计积分
|
||
if (wChairID!=INVALID_CHAIR)
|
||
{
|
||
bool bZhiAnGangFanbei = IsHasGameRule(eWNMJRuleEnum_ZhiAnGang);
|
||
|
||
//自摸类型
|
||
if ((m_ChiHuResult[wChairID].wChiHuKind!=CHK_NULL) &&(wChairID == m_wProvideUser))
|
||
{
|
||
LONG lScore=0L;
|
||
LONG lTimes=0L;
|
||
LONG lExtScore = 0L;
|
||
|
||
BYTE cbFanShuType = GetFanShuType();
|
||
//翻数计算;
|
||
WORD wChiHuOrder = m_GameLogic.CalScore(m_ChiHuResult[wChairID], lScore, lTimes, lExtScore, cbFanShuType, bZhiAnGangFanbei);
|
||
|
||
if (!bZhiAnGangFanbei)
|
||
{
|
||
if (m_ChiHuResult[wChairID].wChiHuRight&CHR_GANG_FLOWER && (m_cbContinueGangs[wChairID] > 1))
|
||
{
|
||
wChiHuOrder *= (1 << (m_cbContinueGangs[wChairID] - 1));
|
||
|
||
int nMaxTimes = 0;
|
||
if (cbFanShuType == eWNMJRuleEnum_OneTwoFAN)
|
||
{ //16分封顶;
|
||
nMaxTimes = 16;
|
||
}
|
||
else if (cbFanShuType == eWNMJRuleEnum_TwoThreeFAN)
|
||
{ //24分封顶;
|
||
nMaxTimes = 24;
|
||
}
|
||
|
||
if (wChiHuOrder > nMaxTimes)
|
||
{
|
||
wChiHuOrder = nMaxTimes;
|
||
}
|
||
|
||
m_ChiHuResult[wChairID].wChiHuRight = CHR_LIAN_GANG_FLOWER; //修改成连杠胡权位;
|
||
}
|
||
|
||
//循环累计
|
||
for (WORD i = 0; i < m_wPlayerCount; i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
//赢家过滤
|
||
if (m_ChiHuResult[i].wChiHuKind != CHK_NULL) continue;
|
||
|
||
//自摸算分;
|
||
GameEnd.lGameScore[i] -= m_pGameServiceOption->lCellScore*(wChiHuOrder + lExtScore);
|
||
GameEnd.lGameScore[wChairID] += m_pGameServiceOption->lCellScore*(wChiHuOrder + lExtScore);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
WORD wProvideChiHuOrder = 0;
|
||
if (m_ChiHuResult[wChairID].wChiHuRight&CHR_GANG_FLOWER)
|
||
{
|
||
if (m_cbContinueGangs[wChairID] > 0)
|
||
{
|
||
wChiHuOrder *= (1 << (m_cbContinueGangs[wChairID] - 1));
|
||
for (BYTE j = 0; j < m_cbContinueGangs[wChairID]; ++j)
|
||
{ //连杠如果是暗杠*2;
|
||
if (m_cbContinueGangTypes[wChairID][j] == eGangType_AnGang)
|
||
{
|
||
wChiHuOrder *= 2;
|
||
}
|
||
}
|
||
|
||
if (m_cbContinueGangs[wChairID] > 1)
|
||
{
|
||
m_ChiHuResult[wChairID].wChiHuRight = CHR_LIAN_GANG_FLOWER; //修改成连杠胡权位;
|
||
}
|
||
}
|
||
|
||
if (m_wProvideMingGangUser != INVALID_CHAIR)
|
||
{
|
||
wProvideChiHuOrder = (wChiHuOrder * 2);
|
||
}
|
||
|
||
int nMaxTimes = 0;
|
||
if (cbFanShuType == eWNMJRuleEnum_OneTwoFAN)
|
||
{ //16分封顶;
|
||
nMaxTimes = 16;
|
||
}
|
||
else if (cbFanShuType == eWNMJRuleEnum_TwoThreeFAN)
|
||
{ //24分封顶;
|
||
nMaxTimes = 24;
|
||
}
|
||
nMaxTimes *= 2;
|
||
|
||
if (wProvideChiHuOrder > nMaxTimes)
|
||
{
|
||
wProvideChiHuOrder = nMaxTimes;
|
||
}
|
||
if (wChiHuOrder > nMaxTimes)
|
||
{
|
||
wChiHuOrder = nMaxTimes;
|
||
}
|
||
}
|
||
|
||
//循环累计
|
||
for (WORD i = 0; i < m_wPlayerCount; i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
//赢家过滤;
|
||
if (m_ChiHuResult[i].wChiHuKind != CHK_NULL) continue;
|
||
|
||
if (m_wProvideMingGangUser == i)
|
||
{ //自摸算分;
|
||
GameEnd.lGameScore[i] -= m_pGameServiceOption->lCellScore*(wProvideChiHuOrder + lExtScore);
|
||
GameEnd.lGameScore[wChairID] += m_pGameServiceOption->lCellScore*(wProvideChiHuOrder + lExtScore);
|
||
}
|
||
else
|
||
{
|
||
//自摸算分;
|
||
GameEnd.lGameScore[i] -= m_pGameServiceOption->lCellScore*(wChiHuOrder + lExtScore);
|
||
GameEnd.lGameScore[wChairID] += m_pGameServiceOption->lCellScore*(wChiHuOrder + lExtScore);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//庄家设置;
|
||
m_wBankerUser = wChairID;
|
||
|
||
}
|
||
|
||
//捉炮类型
|
||
if ((m_ChiHuResult[wChairID].wChiHuKind!=CHK_NULL) &&(wChairID != m_wProvideUser))
|
||
{
|
||
LONG lScore=0L;
|
||
LONG lTimes=0L;
|
||
LONG lExtScore = 0L;
|
||
|
||
BYTE cbFanShuType = GetFanShuType();
|
||
//翻数计算
|
||
WORD wChiHuOrder = m_GameLogic.CalScore(m_ChiHuResult[wChairID], lScore, lTimes, lExtScore, cbFanShuType, bZhiAnGangFanbei);
|
||
|
||
if (m_ChiHuResult[wChairID].wChiHuRight&CHR_QIANG_GANG && (m_cbContinueGangs[m_wProvideUser] > 1))
|
||
{
|
||
wChiHuOrder *= (1 << (m_cbContinueGangs[m_wProvideUser] - 1));
|
||
|
||
int nMaxTimes = 0;
|
||
if (cbFanShuType == eWNMJRuleEnum_OneTwoFAN)
|
||
{ //16分封顶;
|
||
nMaxTimes = 16;
|
||
}
|
||
else if (cbFanShuType == eWNMJRuleEnum_TwoThreeFAN)
|
||
{ //24分封顶;
|
||
nMaxTimes = 24;
|
||
}
|
||
if (bZhiAnGangFanbei)
|
||
{
|
||
nMaxTimes *= 2;
|
||
}
|
||
|
||
if (wChiHuOrder > nMaxTimes)
|
||
{
|
||
wChiHuOrder = nMaxTimes;
|
||
}
|
||
|
||
m_ChiHuResult[wChairID].wChiHuRight = CHR_QIANG_LIAN_GANG; //修改成抢连杠胡权位;
|
||
}
|
||
|
||
//算分;
|
||
GameEnd.lGameScore[m_wProvideUser] -= m_pGameServiceOption->lCellScore*(wChiHuOrder + lExtScore);
|
||
GameEnd.lGameScore[wChairID] += m_pGameServiceOption->lCellScore*(wChiHuOrder + lExtScore);
|
||
|
||
//庄家设置;
|
||
m_wBankerUser = wChairID;
|
||
////判断是否连庄
|
||
//if(wChairID != m_wBankerUser)
|
||
//{ //庄家设置;
|
||
// m_wBankerUser=(m_wBankerUser+1)%GAME_PLAYER;
|
||
//}
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
//荒庄处理
|
||
GameEnd.cbChiHuCard=0;
|
||
m_wBankerUser = 0; //荒庄后,应该是做东的位置做庄;
|
||
//m_wBankerUser=(m_wBankerUser+1)%GAME_PLAYER;
|
||
}
|
||
|
||
|
||
//胡牌得分
|
||
CopyMemory(GameEnd.lGameHuScore,GameEnd.lGameScore,sizeof(GameEnd.lGameHuScore));
|
||
|
||
|
||
|
||
//结束信息
|
||
for (WORD i=0;i<GAME_PLAYER;i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
GameEnd.dwChiHuKind[i]=m_ChiHuResult[i].wChiHuKind;
|
||
GameEnd.dwChiHuRight[i]=m_ChiHuResult[i].wChiHuRight;
|
||
GameEnd.cbCardCount[i]=m_GameLogic.SwitchToCardData(m_cbCardIndex[i],GameEnd.cbCardData[i],MAX_COUNT);
|
||
|
||
GameEnd.cbWeaveItemCount[i] = m_cbWeaveItemCount[i];
|
||
CopyMemory(GameEnd.WeaveItemArray[i], m_WeaveItemArray[i], sizeof(tagWeaveItem)*MAX_WEAVE);
|
||
}
|
||
|
||
////最终成绩
|
||
//for (WORD i=0;i<GAME_PLAYER;i++)
|
||
//{
|
||
// IServerUserItem * pIServerUserItem = m_pITableFrame->GetTableUserItem(i);
|
||
// if ( pIServerUserItem == NULL ) continue;
|
||
//
|
||
// MyLog("name:[%s], ChairID:[%d], lGameScore:[%ld],lGameHuScore[%ld].",
|
||
// pIServerUserItem->GetNickName(), i, GameEnd.lGameScore[i], GameEnd.lGameHuScore[i]);
|
||
//}
|
||
|
||
|
||
//金币房间
|
||
//if(m_pGameServiceOption->wServerType&GAME_GENRE_GOLD)
|
||
//{
|
||
// //积分过滤
|
||
// LONG lDifference = 0;
|
||
// for (WORD i=0;i<m_wPlayerCount;i++)
|
||
// {
|
||
// if (m_bActiveUser[i] == false) continue;
|
||
|
||
// IServerUserItem * pIServerUserItem=m_pITableFrame->GetTableUserItem(i);
|
||
// SCORE lUserScore=pIServerUserItem->GetUserScore();
|
||
// if ((lUserScore < abs(GameEnd.lGameScore[i])) && (GameEnd.lGameScore[i]<0) && (lUserScore >0))
|
||
// {
|
||
// lDifference += abs(GameEnd.lGameScore[i]) - lUserScore;
|
||
// GameEnd.lGameScore[i] = -lUserScore;
|
||
// }
|
||
// }
|
||
//
|
||
// BYTE cbWinCount=0;
|
||
// //积分调整
|
||
// for (WORD i=0; i<m_wPlayerCount; i++)
|
||
// {
|
||
// if(GameEnd.lGameScore[i] > 0)
|
||
// {
|
||
// cbWinCount++;
|
||
// }
|
||
// }
|
||
// //积分调整
|
||
// for (WORD i=0; i<m_wPlayerCount; i++)
|
||
// {
|
||
// if(GameEnd.lGameScore[i] > 0&&cbWinCount>0)
|
||
// {
|
||
// GameEnd.lGameScore[i] -= lDifference/cbWinCount;
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
//历史积分
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
m_lAllTurnScore[i]+=GameEnd.lGameScore[i];
|
||
m_lLastTurnScore[i]=GameEnd.lGameScore[i];
|
||
GameEnd.lAllTurnScore[i]=m_lAllTurnScore[i];
|
||
GameEnd.lLastTurnScore[i]=m_lLastTurnScore[i];
|
||
}
|
||
|
||
|
||
//发送信息
|
||
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
|
||
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
|
||
|
||
// 游戏录像;
|
||
addGameRecordAction(SUB_S_GAME_END, &GameEnd, sizeof(GameEnd));
|
||
|
||
//修改积分
|
||
tagScoreInfo ScoreInfoArray[GAME_PLAYER];
|
||
ZeroMemory(&ScoreInfoArray,sizeof(ScoreInfoArray));
|
||
for (WORD i=0;i<GAME_PLAYER;i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
//设置积分
|
||
ScoreInfoArray[i].lScore=GameEnd.lGameScore[i];
|
||
if (GameEnd.lGameScore[i]>0L)
|
||
{
|
||
GameEnd.lGameScore[i]=ScoreInfoArray[i].lScore-GameEnd.lGameScore[i]*m_pGameServiceOption->wRevenueRatio/100L;
|
||
ScoreInfoArray[i].lRevenue = GameEnd.lGameScore[i] * m_pGameServiceOption->wRevenueRatio / 100L;
|
||
}
|
||
|
||
ScoreInfoArray[i].cbType = SCORE_TYPE_DRAW;
|
||
if (GameEnd.lGameScore[i] != 0)
|
||
ScoreInfoArray[i].cbType = (ScoreInfoArray[i].lScore > 0L) ? SCORE_TYPE_WIN : SCORE_TYPE_LOSE;
|
||
|
||
ScoreInfoArray[i].lScore = ScoreInfoArray[i].lScore;
|
||
ScoreInfoArray[i].lRevenue = ScoreInfoArray[i].lRevenue;
|
||
}
|
||
|
||
/********************************私人场统计****************************************/
|
||
//统计是否是自摸
|
||
for (WORD i = 0; i < GAME_PLAYER; i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
// 赢家
|
||
if (m_ChiHuResult[i].wChiHuKind!=CHK_NULL)
|
||
{
|
||
// 自摸
|
||
if (i == m_wProvideUser)
|
||
{
|
||
m_PrivateEndInfo.cbZiMoCout[i]++;
|
||
}
|
||
}
|
||
else // 输家
|
||
{
|
||
// 点炮
|
||
if (i == m_wProvideUser)
|
||
{
|
||
m_PrivateEndInfo.cbDianPaoCout[i]++;
|
||
}
|
||
}
|
||
|
||
//杠的次数;
|
||
memcpy(m_PrivateEndInfo.cbAllGangCounts, m_cbAllGangCounts, sizeof(m_cbAllGangCounts));
|
||
|
||
// 最高得分
|
||
if (m_PrivateEndInfo.lMaxScore[i] <= GameEnd.lGameScore[i])
|
||
{
|
||
m_PrivateEndInfo.lMaxScore[i] = GameEnd.lGameScore[i];
|
||
}
|
||
}
|
||
/********************************私人场统计****************************************/
|
||
|
||
// 局数统计必须在写数据库之前;
|
||
m_pITableFrame->addPrivatePlayCout(1);
|
||
|
||
//牌局结束后,每8局增加一点经验值;
|
||
if ( IsPrivateEnd() )
|
||
{
|
||
//tagPrivateFrameRecordInfo* pPrivateRecord = m_pITableFrame->GetPrivateFrameRecord();
|
||
//SCORE lGrade = pPrivateRecord->cbFinishCout / 8;
|
||
tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
||
SCORE lGrade = pPrivateFrame->dwPlayCost;
|
||
|
||
ScoreInfoArray[0].lGrade = 2 * lGrade; //房主2倍;
|
||
for (WORD i = 1; i<GAME_PLAYER; i++)
|
||
{
|
||
ScoreInfoArray[i].lGrade = lGrade;
|
||
}
|
||
}
|
||
|
||
//写入积分
|
||
DataStream kDataStream;
|
||
m_kGameRecord.StreamValue(kDataStream, true);
|
||
m_pITableFrame->WriteTableScore(ScoreInfoArray, CountArray(ScoreInfoArray), kDataStream);
|
||
|
||
//结束游戏
|
||
m_pITableFrame->ConcludeGame(GAME_STATUS_FREE);
|
||
return true;
|
||
}
|
||
case GER_DISMISS: //游戏解散
|
||
{
|
||
//变量定义
|
||
CMD_S_GameEnd GameEnd;
|
||
ZeroMemory(&GameEnd,sizeof(GameEnd));
|
||
|
||
//设置变量
|
||
GameEnd.wProvideUser=INVALID_CHAIR;
|
||
CopyMemory(GameEnd.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
||
|
||
//拷贝扑克
|
||
for (WORD i=0;i<GAME_PLAYER;i++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
GameEnd.cbCardCount[i]=m_GameLogic.SwitchToCardData(m_cbCardIndex[i],GameEnd.cbCardData[i],MAX_COUNT);
|
||
|
||
GameEnd.cbWeaveItemCount[i] = m_cbWeaveItemCount[i];
|
||
CopyMemory(GameEnd.WeaveItemArray[i], m_WeaveItemArray[i], sizeof(tagWeaveItem)*MAX_WEAVE);
|
||
}
|
||
|
||
//发送信息
|
||
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
|
||
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GAME_END,&GameEnd,sizeof(GameEnd));
|
||
|
||
// 游戏录像;
|
||
addGameRecordAction(SUB_S_GAME_END, &GameEnd, sizeof(GameEnd));
|
||
|
||
tagScoreInfo ScoreInfo[GAME_PLAYER];
|
||
ZeroMemory(ScoreInfo, sizeof(ScoreInfo));
|
||
|
||
for (WORD i = 0; i < GAME_PLAYER; i++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
ScoreInfo[i].lScore = GameEnd.lGameScore[i];
|
||
ScoreInfo[i].cbType = SCORE_TYPE_DRAW;
|
||
}
|
||
|
||
//写入积分
|
||
DataStream kDataStream;
|
||
m_kGameRecord.StreamValue(kDataStream, true);
|
||
m_pITableFrame->WriteTableScore(ScoreInfo, CountArray(ScoreInfo), kDataStream);
|
||
|
||
//结束游戏
|
||
m_pITableFrame->ConcludeGame(GAME_STATUS_FREE, GER_DISMISS);
|
||
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//发送场景
|
||
bool CTableFrameSink::OnEventSendGameScene(WORD wChiarID, IServerUserItem * pIServerUserItem, BYTE cbGameStatus, bool bSendSecret)
|
||
{
|
||
switch (cbGameStatus)
|
||
{
|
||
case GS_MJ_FREE: //空闲状态
|
||
{
|
||
//变量定义
|
||
CMD_S_StatusFree StatusFree;
|
||
memset(&StatusFree,0,sizeof(StatusFree));
|
||
|
||
//构造数据
|
||
StatusFree.wBankerUser=m_wBankerUser;
|
||
StatusFree.lCellScore=m_pGameServiceOption->lCellScore*m_BankContinueCount;
|
||
CopyMemory(StatusFree.bTrustee,m_bTrustee,sizeof(m_bTrustee));
|
||
CopyMemory(StatusFree.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
||
|
||
//发送场景
|
||
return m_pITableFrame->SendGameScene(pIServerUserItem,&StatusFree,sizeof(StatusFree));
|
||
}
|
||
case GS_MJ_BATCH: //游戏顶底
|
||
{
|
||
//变量定义
|
||
CMD_S_StatusBatch StatusChip;
|
||
ZeroMemory(&StatusChip,sizeof(StatusChip));
|
||
|
||
//构造数据
|
||
StatusChip.bComplete=(m_bCallCard[wChiarID]==true)?TRUE:FALSE;
|
||
StatusChip.lCellScore=m_pGameServiceOption->lCellScore*m_BankContinueCount;
|
||
CopyMemory(StatusChip.bTrustee,m_bTrustee,sizeof(m_bTrustee));
|
||
//历史积分
|
||
CopyMemory(StatusChip.lAllTurnScore,m_lAllTurnScore,sizeof(m_lAllTurnScore));
|
||
CopyMemory(StatusChip.lLastTurnScore,m_lLastTurnScore,sizeof(m_lLastTurnScore));
|
||
CopyMemory(StatusChip.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
||
|
||
//发送场景
|
||
return m_pITableFrame->SendGameScene(pIServerUserItem,&StatusChip,sizeof(StatusChip));
|
||
|
||
|
||
}
|
||
case GS_MJ_PLAY: //游戏状态
|
||
{
|
||
//变量定义
|
||
CMD_S_StatusPlay StatusPlay;
|
||
memset(&StatusPlay,0,sizeof(StatusPlay));
|
||
|
||
//游戏变量
|
||
StatusPlay.wBankerUser=m_wBankerUser;
|
||
StatusPlay.wCurrentUser=m_wCurrentUser;
|
||
StatusPlay.lCellScore=m_pGameServiceOption->lCellScore;
|
||
StatusPlay.wSiceCount=m_wSiceCount;
|
||
StatusPlay.wSiceCount2=m_wSiceCount2;
|
||
StatusPlay.wSiceCount3=m_wSiceCount3;
|
||
|
||
CopyMemory(StatusPlay.bTrustee,m_bTrustee,sizeof(m_bTrustee));
|
||
CopyMemory(StatusPlay.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
||
|
||
//状态变量
|
||
StatusPlay.cbActionCard=m_cbProvideCard;
|
||
StatusPlay.cbLeftCardCount=m_cbLeftCardCount;
|
||
StatusPlay.dwActionMask=(m_bResponse[wChiarID]==false)?m_wUserAction[wChiarID]:WIK_NULL;
|
||
CopyMemory(&StatusPlay.GangPaiResult, &m_GangPaiResult[wChiarID], sizeof(StatusPlay.GangPaiResult));
|
||
|
||
//历史记录
|
||
StatusPlay.wOutCardUser=m_wOutCardUser;
|
||
StatusPlay.cbOutCardData=m_cbOutCardData;
|
||
CopyMemory(StatusPlay.cbDiscardCard,m_cbDiscardCard,sizeof(StatusPlay.cbDiscardCard));
|
||
CopyMemory(StatusPlay.cbDiscardCount,m_cbDiscardCount,sizeof(StatusPlay.cbDiscardCount));
|
||
|
||
//历史积分
|
||
CopyMemory(StatusPlay.lAllTurnScore,m_lAllTurnScore,sizeof(m_lAllTurnScore));
|
||
CopyMemory(StatusPlay.lLastTurnScore,m_lLastTurnScore,sizeof(m_lLastTurnScore));
|
||
|
||
//组合扑克
|
||
CopyMemory(StatusPlay.WeaveItemArray,m_WeaveItemArray,sizeof(m_WeaveItemArray));
|
||
CopyMemory(StatusPlay.cbWeaveCount,m_cbWeaveItemCount,sizeof(m_cbWeaveItemCount));
|
||
|
||
StatusPlay.cbCardCount = m_GameLogic.SwitchToCardData(m_cbCardIndex[wChiarID], StatusPlay.cbCardData, MAX_COUNT);
|
||
//StatusPlay.cbSendCardData = ((m_cbSendCardData != 0) && (m_wProvideUser == wChiarID)) ? m_cbSendCardData : 0x00;
|
||
StatusPlay.cbSendCardData = ((m_cbSendCardData != 0) && (m_wCurrentUser == wChiarID)) ? m_cbSendCardData : 0xff;
|
||
|
||
//发送场景
|
||
return m_pITableFrame->SendGameScene(pIServerUserItem,&StatusPlay,sizeof(StatusPlay));
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
//定时器事件
|
||
bool CTableFrameSink::OnTimerMessage(DWORD wTimerID, WPARAM wBindParam)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
//游戏消息处理
|
||
bool CTableFrameSink::OnGameMessage(WORD wSubCmdID, VOID * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem)
|
||
{
|
||
switch (wSubCmdID)
|
||
{
|
||
case SUB_C_OUT_CARD: //出牌消息
|
||
{
|
||
//效验消息
|
||
ASSERT(wDataSize==sizeof(CMD_C_OutCard));
|
||
if (wDataSize!=sizeof(CMD_C_OutCard)) return false;
|
||
|
||
//用户效验
|
||
tagUserInfo * pUserData = pIServerUserItem->GetUserInfo();
|
||
if (pUserData->cbUserStatus != US_PLAYING) return true;
|
||
|
||
//消息处理
|
||
CMD_C_OutCard * pOutCard=(CMD_C_OutCard *)pDataBuffer;
|
||
return OnUserOutCard(pUserData->wChairID,pOutCard->cbCardData);
|
||
}
|
||
case SUB_C_OPERATE_CARD: //操作消息
|
||
{
|
||
//效验消息
|
||
ASSERT(wDataSize==sizeof(CMD_C_OperateCard));
|
||
if (wDataSize!=sizeof(CMD_C_OperateCard)) return false;
|
||
|
||
//用户效验
|
||
tagUserInfo * pUserData = pIServerUserItem->GetUserInfo();
|
||
if (pUserData->cbUserStatus != US_PLAYING) return true;
|
||
|
||
//消息处理
|
||
CMD_C_OperateCard * pOperateCard=(CMD_C_OperateCard *)pDataBuffer;
|
||
return OnUserOperateCard(pUserData->wChairID,pOperateCard->dwOperateCode,pOperateCard->cbOperateCard);
|
||
}
|
||
//case SUB_C_BATCH: //洗澡操作
|
||
// {
|
||
// //效验消息
|
||
// ASSERT(wDataSize==sizeof(CMD_C_BATCH));
|
||
// if (wDataSize!=sizeof(CMD_C_BATCH)) return false;
|
||
|
||
// //用户效验
|
||
// tagUserInfo * pUserData = pIServerUserItem->GetUserInfo();
|
||
// if (pUserData->cbUserStatus != US_PLAYING) return true;
|
||
|
||
// //消息处理
|
||
// CMD_C_BATCH * pChip=(CMD_C_BATCH *)pDataBuffer;
|
||
// return OnUserCallFinish(pUserData->wChairID,pChip->cbChipTimes);
|
||
// }
|
||
//case SUB_C_TRUSTEE:
|
||
// {
|
||
// CMD_C_Trustee *pTrustee =(CMD_C_Trustee *)pDataBuffer;
|
||
// if(wDataSize != sizeof(CMD_C_Trustee)) return false;
|
||
|
||
// //用户效验
|
||
// tagUserInfo * pUserData = pIServerUserItem->GetUserInfo();
|
||
|
||
// m_bTrustee[pUserData->wChairID]=pTrustee->bTrustee;
|
||
// CMD_S_Trustee Trustee;
|
||
// Trustee.bTrustee=pTrustee->bTrustee;
|
||
// Trustee.wChairID = pUserData->wChairID;
|
||
// m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_TRUSTEE,&Trustee,sizeof(Trustee));
|
||
// m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_TRUSTEE,&Trustee,sizeof(Trustee));
|
||
|
||
// return true;
|
||
// }
|
||
//case SUB_C_BATCH_END: //洗澡结束
|
||
// {
|
||
// //效验消息
|
||
// ASSERT(wDataSize==0);
|
||
// if (wDataSize!=0) return false;
|
||
|
||
// //用户效验
|
||
// tagServerUserData * pUserData=pIServerUserItem->GetUserData();
|
||
// if (pUserData->cbUserStatus!=US_PLAY) return true;
|
||
|
||
// //消息处理
|
||
// return OnUserBatchEnd(pUserData->wChairID);
|
||
// }
|
||
//case SUB_C_PASS_KING: //经过王牌
|
||
// {
|
||
// //用户效验
|
||
// tagUserInfo * pUserData = pIServerUserItem->GetUserInfo();
|
||
// if (pUserData->cbUserStatus != US_PLAYING) return true;
|
||
|
||
// m_cbLeftCardCount--;
|
||
// if(m_cbLeftCardCount<=m_cbMustLeft-1)
|
||
// {
|
||
// m_cbChiHuCard=0;
|
||
// m_wProvideUser=INVALID_CHAIR;
|
||
// OnEventGameConclude(INVALID_CHAIR,NULL,GER_NORMAL);
|
||
// return true;
|
||
// }
|
||
|
||
// return true;
|
||
// }
|
||
//#ifdef DEBUG
|
||
case SUB_C_MASTER_CHEAKCARD:
|
||
{
|
||
if (CUserRight::CanGetCard(pIServerUserItem->GetUserRight()))
|
||
{
|
||
CMD_C_MaterCheckCard *pMaterCheckCard = (CMD_C_MaterCheckCard *)pDataBuffer;
|
||
if (wDataSize != sizeof(CMD_C_MaterCheckCard)) return false;
|
||
|
||
WORD wChairID = pIServerUserItem->GetChairID();
|
||
m_cbMasterCheckCard[wChairID] = pMaterCheckCard->cbCheakCard;
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
case SUB_C_MASTER_LEFTCARD:
|
||
{
|
||
if (CUserRight::CanGetCard(pIServerUserItem->GetUserRight()))
|
||
{
|
||
WORD wChairID = pIServerUserItem->GetChairID();
|
||
sendMasterLeftCard(wChairID);
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
//#endif // DEBUG
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
//框架消息处理
|
||
bool CTableFrameSink::OnFrameMessage(WORD wSubCmdID, VOID * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
//用户坐下
|
||
bool CTableFrameSink::OnActionUserSitDown(WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)
|
||
{
|
||
//庄家设置
|
||
if ((bLookonUser==false)&&(m_wBankerUser==INVALID_CHAIR))
|
||
{
|
||
m_wBankerUser=pIServerUserItem->GetChairID();
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
//用户起来
|
||
bool CTableFrameSink::OnActionUserStandUp(WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser)
|
||
{
|
||
if(bLookonUser==false)
|
||
{
|
||
m_BankContinueCount=1;
|
||
}
|
||
ZeroMemory(m_lAllTurnScore,sizeof(m_lAllTurnScore));
|
||
ZeroMemory(m_lLastTurnScore,sizeof(m_lLastTurnScore));
|
||
memset(m_cbAllGangCounts, 0, sizeof(m_cbAllGangCounts));
|
||
//庄家设置
|
||
if ((bLookonUser==false)&&(wChairID==m_wBankerUser))
|
||
{
|
||
m_wBankerUser=INVALID_CHAIR;
|
||
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if ((i!=wChairID)&&(m_pITableFrame->GetTableUserItem(i)!=NULL))
|
||
{
|
||
m_wBankerUser=i;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
//用户出牌
|
||
bool CTableFrameSink::OnUserOutCard(WORD wChairID, BYTE cbCardData)
|
||
{
|
||
//效验状态
|
||
ASSERT(m_pITableFrame->GetGameStatus()==GS_MJ_PLAY);
|
||
if (m_pITableFrame->GetGameStatus()!=GS_MJ_PLAY) return true;
|
||
|
||
//错误断言
|
||
ASSERT(wChairID==m_wCurrentUser);
|
||
ASSERT(m_GameLogic.IsValidCard(cbCardData)==true);
|
||
|
||
//效验参数
|
||
if (wChairID != m_wCurrentUser)
|
||
{
|
||
CTraceService::TraceFormat(TraceLevel_Exception, TEXT("CTableFrameSink::OnUserOutCard, TableID:%u, 操作用户:%u, 当前用户:%u."), m_pITableFrame->GetTableID(), wChairID, m_wCurrentUser);
|
||
return true;
|
||
}
|
||
|
||
if (m_GameLogic.IsValidCard(cbCardData) == false)
|
||
{
|
||
CTraceService::TraceFormat(TraceLevel_Exception, TEXT("CTableFrameSink::OnUserOutCard, TableID:%u, 操作用户:%u, 当前用户:%u, 用户出牌:%d."), m_pITableFrame->GetTableID(), wChairID, m_wCurrentUser, cbCardData);
|
||
return false;
|
||
}
|
||
|
||
//删除扑克
|
||
if (m_GameLogic.RemoveCard(m_cbCardIndex[wChairID],cbCardData)==false)
|
||
{
|
||
CTraceService::TraceFormat(TraceLevel_Exception, TEXT("CTableFrameSink::OnUserOutCard, TableID:%u, 操作用户:%u, 当前用户:%u, 用户删除扑克出牌:%d出错."), m_pITableFrame->GetTableID(), wChairID, m_wCurrentUser, cbCardData);
|
||
ASSERT(FALSE);
|
||
return false;
|
||
}
|
||
|
||
BYTE cbDelCardIndex = m_GameLogic.SwitchToCardIndex(cbCardData);
|
||
m_cbDelCardIndex[wChairID][cbDelCardIndex]++;
|
||
|
||
//设置变量
|
||
m_bSendStatus=true;
|
||
|
||
m_wUserAction[wChairID]=WIK_NULL;
|
||
m_wPerformAction[wChairID]=WIK_NULL;
|
||
m_bGangStatus=false;
|
||
|
||
ZeroMemory(m_genHuCards[wChairID], sizeof(BYTE)*4);
|
||
ZeroMemory(m_genPengCards[wChairID], sizeof(BYTE)*4);
|
||
m_genDaLiHuCards[wChairID] = cbCardData;
|
||
|
||
ZeroMemory(m_cbContinueGangs, sizeof(m_cbContinueGangs));
|
||
ZeroMemory(m_GangPaiResult, sizeof(m_GangPaiResult));
|
||
ZeroMemory(m_cbContinueGangTypes, sizeof(m_cbContinueGangTypes));
|
||
m_wProvideMingGangUser = INVALID_CHAIR;
|
||
|
||
//出牌记录
|
||
m_cbOutCardCount++;
|
||
m_wOutCardUser=wChairID;
|
||
m_cbOutCardData=cbCardData;
|
||
|
||
//构造数据
|
||
CMD_S_OutCard OutCard;
|
||
OutCard.wOutCardUser=wChairID;
|
||
OutCard.cbOutCardData=cbCardData;
|
||
|
||
//发送消息
|
||
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_OUT_CARD,&OutCard,sizeof(OutCard));
|
||
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_OUT_CARD,&OutCard,sizeof(OutCard));
|
||
|
||
// 游戏录像;
|
||
addGameRecordAction(SUB_S_OUT_CARD, &OutCard, sizeof(OutCard));
|
||
|
||
//用户切换
|
||
m_wProvideUser=wChairID;
|
||
m_cbProvideCard=cbCardData;
|
||
//m_wCurrentUser=(wChairID+m_wPlayerCount-1)%m_wPlayerCount;
|
||
m_wCurrentUser = getNextChairID(wChairID);
|
||
|
||
//响应判断
|
||
bool bAroseAction=EstimateUserRespond(wChairID,cbCardData,EstimatKind_OutCard);
|
||
|
||
//派发扑克
|
||
if (bAroseAction==false) DispatchCardData(m_wCurrentUser);
|
||
|
||
return true;
|
||
}
|
||
|
||
//用户操作
|
||
bool CTableFrameSink::OnUserOperateCard(WORD wChairID, WORD wOperateCode, BYTE cbOperateCard)
|
||
{
|
||
//效验状态
|
||
ASSERT(m_pITableFrame->GetGameStatus()==GS_MJ_PLAY);
|
||
if (m_pITableFrame->GetGameStatus()!=GS_MJ_PLAY) return false;
|
||
|
||
//效验用户
|
||
ASSERT((wChairID==m_wCurrentUser)||(m_wCurrentUser==INVALID_CHAIR));
|
||
if ((wChairID!=m_wCurrentUser)&&(m_wCurrentUser!=INVALID_CHAIR)) return true;
|
||
|
||
//被动动作
|
||
if (m_wCurrentUser==INVALID_CHAIR)
|
||
{
|
||
//效验状态
|
||
ASSERT(m_bResponse[wChairID]==false);
|
||
ASSERT((wOperateCode==WIK_NULL)||((m_wUserAction[wChairID]&wOperateCode)!=0));
|
||
|
||
//效验状态
|
||
if (m_bResponse[wChairID]==true) return true;
|
||
if ((wOperateCode!=WIK_NULL)&&((m_wUserAction[wChairID]&wOperateCode)==0)) return true;
|
||
|
||
//变量定义
|
||
WORD wTargetUser=wChairID;
|
||
WORD wTargetAction=wOperateCode;
|
||
|
||
//设置变量
|
||
m_bResponse[wChairID]=true;
|
||
m_wPerformAction[wChairID]=wOperateCode;
|
||
m_cbOperateCard[wChairID]=(cbOperateCard==0)?m_cbProvideCard:cbOperateCard;
|
||
|
||
//执行判断
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
//获取动作
|
||
WORD wUserAction=(m_bResponse[i]==false)?m_wUserAction[i]:m_wPerformAction[i];
|
||
|
||
//优先级别
|
||
BYTE cbUserActionRank=m_GameLogic.GetUserActionRank(wUserAction);
|
||
BYTE cbTargetActionRank=m_GameLogic.GetUserActionRank(wTargetAction);
|
||
|
||
//动作判断
|
||
if (cbUserActionRank>cbTargetActionRank)
|
||
{
|
||
wTargetUser=i;
|
||
wTargetAction=wUserAction;
|
||
}
|
||
}
|
||
|
||
if (m_bResponse[wTargetUser] == false)
|
||
{
|
||
if (m_wUserAction[wChairID] & WIK_CHI_HU)
|
||
{
|
||
InsertGenHuCards(wChairID, m_cbOperateCard[wChairID]);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
//吃胡等待
|
||
if (wTargetAction==WIK_CHI_HU)
|
||
{
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
if ((m_bResponse[i]==false)&&(m_wUserAction[i]&WIK_CHI_HU))
|
||
return true;
|
||
}
|
||
}
|
||
//吃胡执行判断
|
||
if (wTargetAction==WIK_CHI_HU)
|
||
{
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
//吃牌判断
|
||
WORD wFirstUser=(m_wProvideUser+m_wPlayerCount-1-i)%m_wPlayerCount;
|
||
if (!m_bActiveUser[wFirstUser]) continue;
|
||
|
||
if(m_wPerformAction[wFirstUser]&WIK_CHI_HU)
|
||
{
|
||
//数据校验
|
||
ASSERT(m_bResponse[wFirstUser] == true);
|
||
if((m_bResponse[wFirstUser] == false)) return false;
|
||
//找到首家用户 就退出循环
|
||
wTargetUser = wFirstUser;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//放弃操作
|
||
if (wTargetAction==WIK_NULL)
|
||
{
|
||
if (m_wUserAction[wChairID] & WIK_CHI_HU)
|
||
{
|
||
InsertGenHuCards(wChairID, m_cbOperateCard[wChairID]);
|
||
}
|
||
else if (m_wUserAction[wChairID] & WIK_PENG)
|
||
{
|
||
InsertGenPengCards(wChairID, m_cbOperateCard[wChairID]);
|
||
}
|
||
|
||
//用户状态
|
||
ZeroMemory(m_bResponse,sizeof(m_bResponse));
|
||
ZeroMemory(m_wUserAction,sizeof(m_wUserAction));
|
||
ZeroMemory(m_cbOperateCard,sizeof(m_cbOperateCard));
|
||
ZeroMemory(m_wPerformAction,sizeof(m_wPerformAction));
|
||
ZeroMemory(m_GangPaiResult, sizeof(m_GangPaiResult));
|
||
|
||
//发送扑克
|
||
DispatchCardData(m_wResumeUser);
|
||
|
||
return true;
|
||
}
|
||
|
||
//变量定义
|
||
BYTE cbTargetCard=m_cbOperateCard[wTargetUser];
|
||
|
||
//出牌变量
|
||
m_cbOutCardData=0;
|
||
m_bSendStatus=true;
|
||
m_wOutCardUser=INVALID_CHAIR;
|
||
|
||
|
||
//胡牌操作
|
||
if (wTargetAction==WIK_CHI_HU)
|
||
{
|
||
//结束信息
|
||
m_cbChiHuCard=cbTargetCard;
|
||
m_wProvideUser=m_wProvideUser;
|
||
|
||
//吃牌权位
|
||
WORD wChiHuRight=0;
|
||
if (m_bGangStatus==true) wChiHuRight|=CHR_QIANG_GANG;
|
||
if ((m_cbSendCardCount==1)&&(m_cbOutCardCount==1)) wChiHuRight|=CHR_DI;
|
||
|
||
//胡牌判断
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
//过虑判断
|
||
if ((i==m_wProvideUser)||((m_wPerformAction[i]&WIK_CHI_HU)==0))
|
||
continue;
|
||
|
||
if(i!=wTargetUser) continue;
|
||
|
||
//普通胡牌
|
||
if (m_cbChiHuCard!=0)
|
||
{
|
||
BYTE cbRule = GetHURuleType();
|
||
|
||
//胡牌判断
|
||
BYTE cbWeaveItemCount=m_cbWeaveItemCount[i];
|
||
tagWeaveItem * pWeaveItem=m_WeaveItemArray[i];
|
||
WORD wAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[i], pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, m_ChiHuResult[i], cbRule, false, (((wChiHuRight & CHR_DI) == CHR_DI)? false : true));
|
||
if (wAction == WIK_NULL && ((wChiHuRight & CHR_DI) == CHR_DI))
|
||
{
|
||
bool bTingCard = m_GameLogic.IsTingCard(m_cbCardIndex[i], pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, m_ChiHuResult[i], cbRule, false, false);
|
||
if (WIK_CHI_HU == m_GameLogic.AnalyseTingCard(m_cbCardIndex[i], pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, m_ChiHuResult[i], cbRule, false, true, bTingCard))
|
||
{
|
||
m_ChiHuResult[i].wChiHuRight |= CHR_HAS_KING;
|
||
}
|
||
}
|
||
|
||
//插入扑克
|
||
if (m_ChiHuResult[i].wChiHuKind!=CHK_NULL)
|
||
m_cbCardIndex[i][m_GameLogic.SwitchToCardIndex(m_cbChiHuCard)]++;
|
||
}
|
||
}
|
||
|
||
//结束游戏
|
||
ASSERT(m_ChiHuResult[wTargetUser].wChiHuKind!=CHK_NULL);
|
||
OnEventGameConclude(wTargetUser,NULL,GER_NORMAL);
|
||
|
||
return true;
|
||
}
|
||
|
||
//用户状态
|
||
ZeroMemory(m_bResponse,sizeof(m_bResponse));
|
||
ZeroMemory(m_wUserAction,sizeof(m_wUserAction));
|
||
ZeroMemory(m_cbOperateCard,sizeof(m_cbOperateCard));
|
||
ZeroMemory(m_wPerformAction,sizeof(m_wPerformAction));
|
||
|
||
//有人碰或者杠之后,算过了一圈(客户需求);
|
||
if (WIK_PENG == wTargetAction)
|
||
{
|
||
ZeroMemory(m_genHuCards, sizeof(m_genHuCards));
|
||
ZeroMemory(m_genPengCards, sizeof(m_genPengCards));
|
||
ZeroMemory(m_GangPaiResult, sizeof(m_GangPaiResult));
|
||
}
|
||
|
||
//有人碰或者杠之后,算过了一圈(客户需求20190107);
|
||
if (WIK_PENG == wTargetAction || WIK_GANG == wTargetAction)
|
||
{
|
||
ZeroMemory(m_genDaLiHuCards, sizeof(m_genDaLiHuCards));
|
||
}
|
||
|
||
//组合扑克
|
||
ASSERT(m_cbWeaveItemCount[wTargetUser]<MAX_WEAVE);
|
||
WORD wIndex=m_cbWeaveItemCount[wTargetUser]++;
|
||
m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard=TRUE;
|
||
m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard=cbTargetCard;
|
||
m_WeaveItemArray[wTargetUser][wIndex].wWeaveKind=wTargetAction;
|
||
m_WeaveItemArray[wTargetUser][wIndex].wProvideUser=(m_wProvideUser==INVALID_CHAIR)?wTargetUser:m_wProvideUser;
|
||
|
||
InsertIntoDelCardIndex(wTargetUser, m_WeaveItemArray[wTargetUser][wIndex]);
|
||
|
||
//CMD_S_GangScore gangScoreMsg;
|
||
//ZeroMemory(&gangScoreMsg, sizeof(gangScoreMsg));
|
||
//gangScoreMsg.wChairId = wTargetUser;
|
||
|
||
//删除扑克
|
||
switch (wTargetAction)
|
||
{
|
||
case WIK_DNBL: //东南北左
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard+1,cbTargetCard+3};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
}
|
||
case WIK_DNBC: //东南北中
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard-1,cbTargetCard+2};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
|
||
}
|
||
case WIK_DNBR: //东南北右
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard-3,cbTargetCard-2};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
|
||
}
|
||
case WIK_DXBL: //东西北左
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard+2,cbTargetCard+3};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
|
||
}
|
||
case WIK_DXBC: //东西北中
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard-2,cbTargetCard+1};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
|
||
}
|
||
case WIK_DXBR: //东西北右
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard-3,cbTargetCard-1};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
|
||
}
|
||
case WIK_LEFT: //上牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard+1,cbTargetCard+2};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_RIGHT: //上牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard-2,cbTargetCard-1};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
}
|
||
case WIK_CENTER: //上牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard-1,cbTargetCard+1};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
|
||
break;
|
||
}
|
||
case WIK_PENG: //碰牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard,cbTargetCard};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_GANG: //杠牌操作
|
||
{
|
||
//杠牌设置
|
||
if ((m_cbSendCardCount==1)&&(m_cbOutCardData==0))
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard,cbTargetCard,cbTargetCard};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
}
|
||
else
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[]={cbTargetCard,cbTargetCard,cbTargetCard};
|
||
m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser],cbRemoveCard,CountArray(cbRemoveCard));
|
||
}
|
||
m_cbGangCount++;
|
||
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (m_wProvideUser != INVALID_CHAIR && (m_wProvideUser < GAME_PLAYER))
|
||
{
|
||
BYTE cbDelCardIndex = m_GameLogic.SwitchToCardIndex(cbTargetCard);
|
||
m_cbDelCardIndex[m_wProvideUser][cbDelCardIndex]--;
|
||
}
|
||
|
||
//构造结果
|
||
CMD_S_OperateResult OperateResult;
|
||
OperateResult.wOperateUser=wTargetUser;
|
||
OperateResult.cbOperateCard=cbTargetCard;
|
||
OperateResult.dwOperateCode=wTargetAction;
|
||
OperateResult.wProvideUser=(m_wProvideUser==INVALID_CHAIR)?wTargetUser:m_wProvideUser;
|
||
|
||
//设置状态
|
||
if (wTargetAction==WIK_GANG) m_bGangStatus=true;
|
||
|
||
//发送消息
|
||
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_OPERATE_RESULT,&OperateResult,sizeof(OperateResult));
|
||
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_OPERATE_RESULT,&OperateResult,sizeof(OperateResult));
|
||
|
||
// 游戏录像;
|
||
addGameRecordAction(SUB_S_OPERATE_RESULT, &OperateResult, sizeof(OperateResult));
|
||
|
||
//设置用户
|
||
m_wCurrentUser=wTargetUser;
|
||
|
||
//杠牌处理
|
||
if (wTargetAction==WIK_GANG)
|
||
{
|
||
//m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GANG_SCORE, &gangScoreMsg, sizeof(gangScoreMsg));
|
||
//m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GANG_SCORE, &gangScoreMsg, sizeof(gangScoreMsg));
|
||
|
||
//// 游戏录像;
|
||
//addGameRecordAction(SUB_S_GANG_SCORE, &gangScoreMsg, sizeof(gangScoreMsg));
|
||
|
||
////效验动作
|
||
//bool bAroseAction=EstimateUserRespond(wTargetUser,cbTargetCard,EstimatKind_GangCard);
|
||
|
||
////发送扑克
|
||
//if (bAroseAction==false)
|
||
//{
|
||
m_wProvideMingGangUser = m_wProvideUser; //设置提供杠玩家;
|
||
|
||
ZeroMemory(m_genHuCards, sizeof(m_genHuCards));
|
||
ZeroMemory(m_genPengCards, sizeof(m_genPengCards));
|
||
ZeroMemory(m_GangPaiResult, sizeof(m_GangPaiResult));
|
||
|
||
DispatchCardData(wTargetUser,false);
|
||
//}
|
||
|
||
m_cbContinueGangTypes[wTargetUser][m_cbContinueGangs[wTargetUser]] = eGangType_MingGang;
|
||
|
||
++m_cbContinueGangs[wTargetUser];
|
||
|
||
++m_cbAllGangCounts[wTargetUser];
|
||
|
||
return true;
|
||
}
|
||
|
||
//动作判断
|
||
if (m_cbLeftCardCount>m_cbMustLeft-1)
|
||
{
|
||
//杠牌判断
|
||
tagGangCardResult GangCardResult;
|
||
ZeroMemory(&GangCardResult, sizeof(GangCardResult));
|
||
m_wUserAction[m_wCurrentUser]|=m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wCurrentUser],
|
||
m_WeaveItemArray[m_wCurrentUser],m_cbWeaveItemCount[m_wCurrentUser],GangCardResult);
|
||
|
||
//结果处理
|
||
if (GangCardResult.cbCardCount>0)
|
||
{
|
||
//设置变量
|
||
m_wUserAction[m_wCurrentUser]|=WIK_GANG;
|
||
|
||
m_wProvideUser = m_wCurrentUser;
|
||
|
||
//发送动作
|
||
SendOperateNotify(GangCardResult);
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
//主动动作
|
||
if (m_wCurrentUser==wChairID)
|
||
{
|
||
//效验操作
|
||
ASSERT((wOperateCode!=WIK_NULL)&&((m_wUserAction[wChairID]&wOperateCode)!=0));
|
||
if ((wOperateCode==WIK_NULL)||((m_wUserAction[wChairID]&wOperateCode)==0)) return true;
|
||
|
||
//扑克效验
|
||
ASSERT((wOperateCode==WIK_NULL)||(wOperateCode==WIK_CHI_HU)||(m_GameLogic.IsValidCard(cbOperateCard)==true));
|
||
if ((wOperateCode!=WIK_NULL)&&(wOperateCode!=WIK_CHI_HU)&&(m_GameLogic.IsValidCard(cbOperateCard)==false)) return false;
|
||
|
||
//设置变量
|
||
m_bSendStatus=true;
|
||
m_wUserAction[m_wCurrentUser]=WIK_NULL;
|
||
m_wPerformAction[m_wCurrentUser]=WIK_NULL;
|
||
|
||
bool bPublic=false;
|
||
|
||
//执行动作
|
||
switch (wOperateCode)
|
||
{
|
||
case WIK_GANG: //杠牌操作
|
||
{
|
||
//变量定义
|
||
BYTE cbWeaveIndex=0xFF;
|
||
BYTE cbCardIndex=m_GameLogic.SwitchToCardIndex(cbOperateCard);
|
||
|
||
//杠牌处理
|
||
if (m_cbCardIndex[wChairID][cbCardIndex]==1)
|
||
{
|
||
//寻找组合
|
||
for (BYTE i=0;i<m_cbWeaveItemCount[wChairID];i++)
|
||
{
|
||
WORD wWeaveKind=m_WeaveItemArray[wChairID][i].wWeaveKind;
|
||
BYTE cbCenterCard=m_WeaveItemArray[wChairID][i].cbCenterCard;
|
||
if ((cbCenterCard==cbOperateCard)&&(wWeaveKind==WIK_PENG))
|
||
{
|
||
bPublic=true;
|
||
cbWeaveIndex=i;
|
||
break;
|
||
}
|
||
}
|
||
|
||
//效验动作
|
||
ASSERT(cbWeaveIndex!=0xFF);
|
||
if (cbWeaveIndex==0xFF) return false;
|
||
|
||
|
||
//组合扑克
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard=TRUE;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser=wChairID;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].wWeaveKind=wOperateCode;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard=cbOperateCard;
|
||
|
||
}
|
||
else
|
||
{
|
||
//扑克效验
|
||
ASSERT(m_cbCardIndex[wChairID][cbCardIndex]==4);
|
||
if (m_cbCardIndex[wChairID][cbCardIndex]!=4) return false;
|
||
|
||
//设置变量
|
||
bPublic=false;
|
||
cbWeaveIndex=m_cbWeaveItemCount[wChairID]++;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard=FALSE;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser=wChairID;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].wWeaveKind=wOperateCode;
|
||
m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard=cbOperateCard;
|
||
|
||
}
|
||
|
||
//杠牌数目
|
||
m_cbGangCount++;
|
||
|
||
//删除扑克
|
||
m_cbCardIndex[wChairID][cbCardIndex]=0;
|
||
|
||
//设置状态
|
||
if (wOperateCode==WIK_GANG) m_bGangStatus=true;
|
||
|
||
//构造结果
|
||
CMD_S_OperateResult OperateResult;
|
||
OperateResult.wOperateUser=wChairID;
|
||
OperateResult.wProvideUser=wChairID;
|
||
OperateResult.dwOperateCode=wOperateCode;
|
||
OperateResult.cbOperateCard=cbOperateCard;
|
||
|
||
//发送消息
|
||
m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_OPERATE_RESULT,&OperateResult,sizeof(OperateResult));
|
||
m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_OPERATE_RESULT,&OperateResult,sizeof(OperateResult));
|
||
|
||
// 游戏录像;
|
||
addGameRecordAction(SUB_S_OPERATE_RESULT, &OperateResult, sizeof(OperateResult));
|
||
|
||
//效验动作
|
||
bool bAroseAction=false;
|
||
if (bPublic==true) bAroseAction=EstimateUserRespond(wChairID,cbOperateCard,EstimatKind_GangCard);
|
||
|
||
//发送扑克
|
||
if (bAroseAction==false)
|
||
{
|
||
DispatchCardData(wChairID,false);
|
||
}
|
||
|
||
if ( bPublic )
|
||
{
|
||
m_cbContinueGangTypes[wChairID][m_cbContinueGangs[wChairID]] = eGangType_BuGang;
|
||
}
|
||
else
|
||
{
|
||
m_cbContinueGangTypes[wChairID][m_cbContinueGangs[wChairID]] = eGangType_AnGang;
|
||
}
|
||
|
||
++m_cbContinueGangs[wChairID];
|
||
|
||
++m_cbAllGangCounts[wChairID];
|
||
|
||
return true;
|
||
}
|
||
case WIK_CHI_HU: //吃胡操作
|
||
{
|
||
//吃牌权位
|
||
WORD wChiHuRight=0;
|
||
if (m_bGangStatus==true) wChiHuRight|=CHR_QIANG_GANG;
|
||
if ((m_cbSendCardCount==1)&&(m_cbOutCardCount==1)) wChiHuRight|=CHR_DI;
|
||
if ((m_cbSendCardCount==1)&&(m_cbOutCardCount==0))
|
||
{
|
||
wChiHuRight|=CHR_TIAN;
|
||
m_wProvideUser = m_wCurrentUser;
|
||
}
|
||
|
||
//结束信息
|
||
m_cbChiHuCard=m_cbProvideCard;
|
||
|
||
//普通胡牌
|
||
BYTE cbWeaveItemCount=m_cbWeaveItemCount[wChairID];
|
||
tagWeaveItem * pWeaveItem=m_WeaveItemArray[wChairID];
|
||
BYTE cbTempCardIndex[MAX_INDEX];
|
||
CopyMemory(cbTempCardIndex,m_cbCardIndex[wChairID],sizeof(cbTempCardIndex));
|
||
if(m_GameLogic.RemoveCard(cbTempCardIndex,m_cbChiHuCard)==false)
|
||
{
|
||
ASSERT(FALSE);
|
||
}
|
||
|
||
BYTE cbRule = GetHURuleType();
|
||
|
||
bool bRealHu = true;
|
||
if (m_bGangStatus || ((wChiHuRight & CHR_TIAN) == CHR_TIAN))
|
||
{ //开杠或者天胡的情况下,可以胡5以下;
|
||
bRealHu = false;
|
||
}
|
||
|
||
WORD wAction = m_GameLogic.AnalyseChiHuCard(cbTempCardIndex, pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, m_ChiHuResult[wChairID], cbRule, true, bRealHu);
|
||
if ( wAction == WIK_CHI_HU )
|
||
{
|
||
m_GameLogic.IsCheckZhongSe(cbTempCardIndex, pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, m_ChiHuResult[wChairID], cbRule, true);
|
||
}
|
||
|
||
if (wAction == WIK_NULL && (m_bGangStatus == true || ((wChiHuRight & CHR_TIAN) == CHR_TIAN)))
|
||
{
|
||
bool bTingCard = m_GameLogic.IsTingCard(cbTempCardIndex, pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, m_ChiHuResult[wChairID], cbRule, true, true);
|
||
if ( !bTingCard )
|
||
{
|
||
if (WIK_CHI_HU == m_GameLogic.AnalyseTingCard(cbTempCardIndex, pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, m_ChiHuResult[wChairID], cbRule, true, true, bTingCard))
|
||
{
|
||
m_ChiHuResult[wChairID].wChiHuRight |= CHR_HAS_KING;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_ChiHuResult[wChairID].wChiHuRight |= CHR_HAS_KING;
|
||
|
||
//找最大和牌;
|
||
tagChiHuResult tempChiHuResult;
|
||
ZeroMemory(&tempChiHuResult, sizeof(tempChiHuResult));
|
||
if (WIK_CHI_HU == m_GameLogic.AnalyseTingCard(cbTempCardIndex, pWeaveItem, cbWeaveItemCount, m_cbChiHuCard, wChiHuRight, tempChiHuResult, cbRule, true, true, bTingCard))
|
||
{
|
||
tempChiHuResult.wChiHuRight |= CHR_HAS_KING;
|
||
|
||
m_GameLogic.CompareChiHuResult(m_ChiHuResult[wChairID], tempChiHuResult);
|
||
}
|
||
}
|
||
}
|
||
|
||
//结束游戏
|
||
OnEventGameConclude(m_wProvideUser,NULL,GER_NORMAL);
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
//发送操作
|
||
bool CTableFrameSink::SendOperateNotify(const tagGangCardResult& GangCardResult)
|
||
{
|
||
//发送提示
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (m_wUserAction[i]!=WIK_NULL)
|
||
{
|
||
//构造数据
|
||
CMD_S_OperateNotify OperateNotify;
|
||
ZeroMemory(&OperateNotify, sizeof(OperateNotify));
|
||
|
||
OperateNotify.wResumeUser=m_wResumeUser;
|
||
OperateNotify.cbActionCard=m_cbProvideCard;
|
||
OperateNotify.dwActionMask=m_wUserAction[i];
|
||
CopyMemory(&OperateNotify.GangPaiResult, &GangCardResult, sizeof(GangCardResult));
|
||
|
||
//发送数据(只发给自己)
|
||
m_pITableFrame->SendTableData(i,SUB_S_OPERATE_NOTIFY,&OperateNotify,sizeof(OperateNotify));
|
||
m_pITableFrame->SendLookonData(i,SUB_S_OPERATE_NOTIFY,&OperateNotify,sizeof(OperateNotify));
|
||
|
||
// 保存场景恢复使用;
|
||
if ((m_wUserAction[i] & WIK_GANG) != 0)
|
||
{
|
||
CopyMemory(&m_GangPaiResult[i], &GangCardResult, sizeof(GangCardResult));
|
||
}
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
//派发扑克
|
||
bool CTableFrameSink::DispatchCardData(WORD wCurrentUser,bool bNotGang)
|
||
{
|
||
//状态效验
|
||
ASSERT(wCurrentUser!=INVALID_CHAIR);
|
||
if (wCurrentUser==INVALID_CHAIR) return false;
|
||
|
||
//丢弃扑克
|
||
if ((m_wOutCardUser!=INVALID_CHAIR)&&(m_cbOutCardData!=0))
|
||
{
|
||
m_cbDiscardCount[m_wOutCardUser]++;
|
||
m_cbDiscardCard[m_wOutCardUser][m_cbDiscardCount[m_wOutCardUser]-1]=m_cbOutCardData;
|
||
}
|
||
|
||
//设置变量
|
||
m_cbOutCardData=0;
|
||
m_wCurrentUser=wCurrentUser;
|
||
m_wOutCardUser=INVALID_CHAIR;
|
||
|
||
tagGangCardResult GangCardResult;
|
||
ZeroMemory(&GangCardResult, sizeof(GangCardResult));
|
||
|
||
if (m_cbLeftCardCount<=m_cbMustLeft-1)
|
||
{
|
||
m_cbChiHuCard=0;
|
||
m_wProvideUser=INVALID_CHAIR;
|
||
OnEventGameConclude(m_wProvideUser,NULL,GER_NORMAL);
|
||
return true;
|
||
|
||
}
|
||
//发牌处理
|
||
if (m_bSendStatus==true)
|
||
{
|
||
//发送扑克
|
||
m_cbSendCardCount++;
|
||
//m_cbSendCardData=m_cbRepertoryCard[--m_cbLeftCardCount];
|
||
//#ifdef DEBUG
|
||
m_cbSendCardData = getSendCardData(wCurrentUser);
|
||
//#else
|
||
// m_cbSendCardData = m_cbRepertoryCard[--m_cbLeftCardCount];
|
||
//#endif // DEBUG
|
||
|
||
//插入数据
|
||
m_cbCardIndex[wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++;
|
||
|
||
//设置变量
|
||
m_wProvideUser=wCurrentUser;
|
||
m_cbProvideCard=m_cbSendCardData;
|
||
|
||
//杠牌判断
|
||
if (m_cbLeftCardCount>m_cbMustLeft-1)
|
||
{
|
||
m_wUserAction[wCurrentUser]|=m_GameLogic.AnalyseGangCard(m_cbCardIndex[wCurrentUser],
|
||
m_WeaveItemArray[wCurrentUser],m_cbWeaveItemCount[wCurrentUser],GangCardResult);
|
||
}
|
||
|
||
//牌型权位
|
||
WORD wChiHuRight=0;
|
||
if (m_bGangStatus==true) wChiHuRight|=CHR_QIANG_GANG;
|
||
|
||
//胡牌判断
|
||
BYTE cbTempCardIndex[MAX_INDEX];
|
||
CopyMemory(cbTempCardIndex,m_cbCardIndex[m_wCurrentUser],sizeof(cbTempCardIndex));
|
||
if(m_GameLogic.RemoveCard(cbTempCardIndex,m_cbSendCardData)==false)
|
||
{
|
||
ASSERT(FALSE);
|
||
}
|
||
|
||
BYTE cbRule = GetHURuleType();
|
||
|
||
tagChiHuResult ChiHuResult;
|
||
m_wUserAction[wCurrentUser]|=m_GameLogic.AnalyseChiHuCard(cbTempCardIndex,
|
||
m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, wChiHuRight, ChiHuResult, cbRule, true, (m_bGangStatus ? false : true));
|
||
|
||
if (m_bGangStatus && ((m_wUserAction[wCurrentUser] & WIK_CHI_HU) != WIK_CHI_HU ))
|
||
{
|
||
bool bTingCard = m_GameLogic.IsTingCard(cbTempCardIndex, m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, wChiHuRight, ChiHuResult, cbRule);
|
||
if (!bTingCard)
|
||
{
|
||
m_wUserAction[wCurrentUser] |= m_GameLogic.AnalyseTingCard(cbTempCardIndex, m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, wChiHuRight, ChiHuResult, cbRule, true, false, bTingCard);
|
||
}
|
||
else
|
||
{
|
||
m_wUserAction[wCurrentUser] |= WIK_CHI_HU;
|
||
}
|
||
}
|
||
}
|
||
|
||
//构造数据
|
||
CMD_S_SendCard SendCard;
|
||
SendCard.wCurrentUser = wCurrentUser;
|
||
SendCard.wActionMask = m_wUserAction[wCurrentUser];
|
||
SendCard.cbCardData = 0x00;
|
||
SendCard.cbIsNotGang = bNotGang;
|
||
|
||
for (WORD i = 0; i < GAME_PLAYER; i++)
|
||
{
|
||
if (i == wCurrentUser) continue;
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
//发送数据
|
||
m_pITableFrame->SendTableData(i, SUB_S_SEND_CARD, &SendCard, sizeof(SendCard));
|
||
}
|
||
m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_SEND_CARD, &SendCard, sizeof(SendCard));
|
||
|
||
// 是否有杠操作;
|
||
if ((m_wUserAction[wCurrentUser] & WIK_GANG) != 0)
|
||
{
|
||
CopyMemory(&m_GangPaiResult[wCurrentUser], &GangCardResult, sizeof(GangCardResult));
|
||
CopyMemory(&SendCard.GangPaiResult, &GangCardResult, sizeof(GangCardResult));
|
||
}
|
||
SendCard.cbCardData = ( (m_bSendStatus == true) ? m_cbSendCardData : 0x00 );
|
||
|
||
m_pITableFrame->SendTableData(wCurrentUser, SUB_S_SEND_CARD, &SendCard, sizeof(SendCard));
|
||
|
||
// 游戏录像;
|
||
addGameRecordAction(SUB_S_SEND_CARD, &SendCard, sizeof(SendCard));
|
||
|
||
return true;
|
||
}
|
||
|
||
//响应判断
|
||
bool CTableFrameSink::EstimateUserRespond(WORD wCenterUser, BYTE cbCenterCard, enEstimatKind EstimatKind)
|
||
{
|
||
//变量定义
|
||
bool bAroseAction=false;
|
||
|
||
//用户状态
|
||
ZeroMemory(m_bResponse,sizeof(m_bResponse));
|
||
ZeroMemory(m_wUserAction,sizeof(m_wUserAction));
|
||
ZeroMemory(m_wPerformAction,sizeof(m_wPerformAction));
|
||
|
||
tagGangCardResult GangCardResult;
|
||
ZeroMemory(&GangCardResult, sizeof(GangCardResult));
|
||
|
||
BYTE cbCenterCardIndex = m_GameLogic.SwitchToCardIndex(cbCenterCard);
|
||
|
||
//动作判断
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
//用户过滤
|
||
if (wCenterUser==i) continue;
|
||
|
||
// 杠牌提供者不参与胡牌检测;
|
||
if (EstimatKind == EstimatKind_GangCard && m_wProvideUser == i) continue;
|
||
|
||
//出牌类型
|
||
if (EstimatKind==EstimatKind_OutCard)
|
||
{
|
||
//吃碰判断
|
||
|
||
//碰牌判断
|
||
if ( !IsInInsertGenPengCards(i, cbCenterCard ) )
|
||
{
|
||
m_wUserAction[i] |= m_GameLogic.EstimatePengCard(m_cbCardIndex[i], cbCenterCard);
|
||
}
|
||
|
||
//杠牌判断
|
||
if (m_cbLeftCardCount>m_cbMustLeft-1)
|
||
{
|
||
m_wUserAction[i]|=m_GameLogic.EstimateGangCard(m_cbCardIndex[i],cbCenterCard);
|
||
if ((m_wUserAction[i]&WIK_GANG)!= 0)
|
||
{
|
||
GangCardResult.cbCardCount = 1;
|
||
GangCardResult.cbCardData[0] = cbCenterCard;
|
||
}
|
||
}
|
||
}
|
||
|
||
//胡牌判断
|
||
//if (!IsInInsertGenHuCards(i, cbCenterCard))
|
||
if (m_genDaLiHuCards[i] != cbCenterCard)
|
||
{
|
||
//牌型权位
|
||
WORD wChiHuRight=0;
|
||
if (m_bGangStatus==true)
|
||
wChiHuRight|=CHR_QIANG_GANG;
|
||
if ((m_cbSendCardCount==1)&&(m_cbOutCardCount==1))
|
||
wChiHuRight|=CHR_DI;
|
||
if ((m_cbSendCardCount==1)&&(m_cbOutCardCount==0))
|
||
wChiHuRight|=CHR_TIAN;
|
||
|
||
BYTE cbRule = GetHURuleType();
|
||
|
||
//吃胡判断
|
||
tagChiHuResult ChiHuResult;
|
||
BYTE cbWeaveCount=m_cbWeaveItemCount[i];
|
||
m_wUserAction[i] |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[i], m_WeaveItemArray[i], cbWeaveCount, cbCenterCard, wChiHuRight, ChiHuResult, cbRule);
|
||
|
||
if (((wChiHuRight & CHR_DI) == CHR_DI) && ((m_wUserAction[i] & WIK_CHI_HU) != WIK_CHI_HU))
|
||
{
|
||
bool bTingCard = m_GameLogic.IsTingCard(m_cbCardIndex[i], m_WeaveItemArray[i], cbWeaveCount, cbCenterCard, wChiHuRight, ChiHuResult, cbRule, false);
|
||
m_wUserAction[i] |= m_GameLogic.AnalyseTingCard(m_cbCardIndex[i], m_WeaveItemArray[i], cbWeaveCount, cbCenterCard, wChiHuRight, ChiHuResult, cbRule, false, false, bTingCard);
|
||
}
|
||
|
||
if (((m_wUserAction[i] & WIK_CHI_HU) == WIK_CHI_HU) && (EstimatKind != EstimatKind_GangCard) && HasGenHuCards(i) && ((ChiHuResult.wChiHuKind&CHK_SERVEN) != CHK_SERVEN))
|
||
{
|
||
//所有跟牌都不能胡,不胡点过,则整圈都不能胡,除非遇到七星;
|
||
m_wUserAction[i] &= (~WIK_CHI_HU);
|
||
}
|
||
|
||
if ((wChiHuRight&CHR_DI) == CHR_DI && (ChiHuResult.wChiHuRight&CHR_HAS_KING) == CHR_HAS_KING && (ChiHuResult.wChiHuKind&CHK_QI_DUI) == CHK_QI_DUI)
|
||
{
|
||
//地胡并且是软胡时;
|
||
if (m_cbCardIndex[i][cbCenterCardIndex] == 0)
|
||
{
|
||
//没有套到牌时,不能胡;
|
||
m_wUserAction[i] &= (~WIK_CHI_HU);
|
||
}
|
||
}
|
||
}
|
||
|
||
//结果判断
|
||
if (m_wUserAction[i]!=WIK_NULL)
|
||
bAroseAction=true;
|
||
}
|
||
|
||
//结果处理
|
||
if (bAroseAction==true)
|
||
{
|
||
//设置变量
|
||
m_wProvideUser=wCenterUser;
|
||
m_cbProvideCard=cbCenterCard;
|
||
m_wResumeUser=m_wCurrentUser;
|
||
m_wCurrentUser=INVALID_CHAIR;
|
||
|
||
//发送提示
|
||
SendOperateNotify(GangCardResult);
|
||
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
//游戏开始
|
||
bool CTableFrameSink::OnEventGameStart()
|
||
{
|
||
#if DROPPED_DEFAULT
|
||
/************************ 使用时间限制 ************************************************/
|
||
std::string strExpirationTime = "2017-05-15";
|
||
std::string strMinTime = "2017-03-01";
|
||
|
||
COleDateTime odt;
|
||
COleDateTime odtMin;
|
||
odt.ParseDateTime(strExpirationTime.c_str());
|
||
odtMin.ParseDateTime(strMinTime.c_str());
|
||
|
||
SYSTEMTIME st;
|
||
SYSTEMTIME stMin;
|
||
odt.GetAsSystemTime(st);
|
||
odtMin.GetAsSystemTime(stMin);
|
||
|
||
CTime tCreate(st);
|
||
CTime tMin(stMin);
|
||
|
||
CTime cCurTime = CTime::GetCurrentTime();
|
||
|
||
// 验证当前时间是否合法;
|
||
if (cCurTime.GetTime() < tMin.GetTime())
|
||
{
|
||
m_wDropped = 80;
|
||
}
|
||
else
|
||
{
|
||
if (tCreate.GetTime() <= cCurTime.GetTime())
|
||
{
|
||
CTimeSpan span = cCurTime - tCreate;
|
||
m_wDropped = 10 * span.GetDays();
|
||
|
||
if (m_wDropped > 80)
|
||
{
|
||
m_wDropped = 80;
|
||
}
|
||
}
|
||
}
|
||
|
||
/************************************************************************/
|
||
#endif
|
||
|
||
//设置状态
|
||
m_pITableFrame->SetGameStatus(GS_MJ_PLAY);
|
||
|
||
// 统计在线玩家;
|
||
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;
|
||
}
|
||
}
|
||
|
||
// 结束统计;
|
||
for (WORD i = 0; i < GAME_PLAYER; ++i)
|
||
{
|
||
m_PrivateEndInfo.aryActiveStatus[i] = m_bActiveUser[i];
|
||
}
|
||
|
||
//预留牌数
|
||
m_cbMustLeft =MUST_LEFT_COUNT;
|
||
|
||
//混乱扑克
|
||
m_GameLogic.RandCardData(m_cbRepertoryCard,CountArray(m_cbRepertoryCard));
|
||
|
||
m_wSiceCount=MAKEWORD(rand()%6+1,rand()%6+1);
|
||
|
||
m_cbLeftCardCount=CountArray(m_cbRepertoryCard);
|
||
|
||
BYTE cbAllUserCardData[GAME_PLAYER][MAX_COUNT];
|
||
memset(cbAllUserCardData, 0x0, sizeof(cbAllUserCardData));
|
||
|
||
#ifdef DEBUG
|
||
UseCardLibrary();
|
||
#endif
|
||
|
||
// 每个玩家的牌分别分配
|
||
for (WORD i = 0; i < m_wPlayerCount; i++)
|
||
{
|
||
if (m_bActiveUser[i])
|
||
{
|
||
m_cbLeftCardCount -= (MAX_COUNT - 1);
|
||
CopyMemory(&cbAllUserCardData[i][0], &m_cbRepertoryCard[m_cbLeftCardCount], sizeof(BYTE)*(MAX_COUNT - 1));
|
||
m_GameLogic.SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount], MAX_COUNT - 1, m_cbCardIndex[i]);
|
||
}
|
||
}
|
||
|
||
//发送扑克
|
||
m_cbSendCardCount++;
|
||
m_cbSendCardData=m_cbRepertoryCard[--m_cbLeftCardCount];
|
||
m_cbCardIndex[m_wBankerUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++;
|
||
|
||
//设置变量
|
||
m_cbProvideCard=m_cbSendCardData;
|
||
m_wProvideUser=INVALID_CHAIR;
|
||
m_wCurrentUser=m_wBankerUser;
|
||
|
||
// 分析庄家起手是否天胡;
|
||
BYTE cbTempCardIndex[MAX_INDEX];
|
||
CopyMemory(cbTempCardIndex, m_cbCardIndex[m_wBankerUser], sizeof(cbTempCardIndex));
|
||
if(m_GameLogic.RemoveCard(cbTempCardIndex,m_cbSendCardData)==false)
|
||
{
|
||
ASSERT(FALSE);
|
||
}
|
||
|
||
BYTE cbRule = GetHURuleType();
|
||
//胡牌判断;
|
||
tagChiHuResult ChiHuResult;
|
||
m_wUserAction[m_wBankerUser] |= m_GameLogic.AnalyseChiHuCard(cbTempCardIndex, NULL, 0, m_cbSendCardData, 0, ChiHuResult, cbRule, true);
|
||
if (m_wUserAction[m_wBankerUser] == WIK_NULL)
|
||
{
|
||
bool bTingCard = m_GameLogic.IsTingCard(cbTempCardIndex, NULL, 0, m_cbSendCardData, 0, ChiHuResult, cbRule);
|
||
if ( !bTingCard )
|
||
{
|
||
m_wUserAction[m_wBankerUser] |= m_GameLogic.AnalyseTingCard(cbTempCardIndex, NULL, 0, m_cbSendCardData, 0, ChiHuResult, cbRule, true);
|
||
}
|
||
else
|
||
{
|
||
m_wUserAction[m_wBankerUser] |= WIK_CHI_HU;
|
||
}
|
||
}
|
||
|
||
//杠牌判断
|
||
if (m_cbLeftCardCount > m_cbMustLeft - 1)
|
||
{
|
||
m_wUserAction[m_wBankerUser] |= m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wBankerUser],
|
||
m_WeaveItemArray[m_wBankerUser], m_cbWeaveItemCount[m_wBankerUser], m_GangPaiResult[m_wBankerUser]);
|
||
}
|
||
|
||
//构造数据
|
||
CMD_S_GameStart GameStart;
|
||
ZeroMemory(&GameStart, sizeof(CMD_S_GameStart));
|
||
|
||
GameStart.wSiceCount=m_wSiceCount;
|
||
GameStart.wBankerUser=m_wBankerUser;
|
||
GameStart.wCurrentUser=m_wCurrentUser;
|
||
CopyMemory(&GameStart.GangPaiResult, &m_GangPaiResult[m_wBankerUser], sizeof(GameStart.GangPaiResult));
|
||
CopyMemory(GameStart.bActiveStatus, m_bActiveUser, sizeof(bool)*GAME_PLAYER);
|
||
CopyMemory(GameStart.bTrustee,m_bTrustee,sizeof(m_bTrustee));
|
||
|
||
for (WORD i=0;i<m_wPlayerCount;i++)
|
||
{
|
||
if (m_bActiveUser[i] == false) continue;
|
||
|
||
//设置变量
|
||
GameStart.wUserAction=m_wUserAction[i];
|
||
CopyMemory(GameStart.cbCardData, &cbAllUserCardData[i][0], sizeof(BYTE)*MAX_COUNT);
|
||
|
||
// 庄家有第十四张牌
|
||
if (i == m_wCurrentUser)
|
||
{
|
||
GameStart.cbCardData[MAX_COUNT - 1] = m_cbSendCardData;
|
||
}
|
||
|
||
//发送数据
|
||
m_pITableFrame->SendTableData(i, SUB_S_GAME_START, &GameStart, sizeof(GameStart));
|
||
m_pITableFrame->SendLookonData(i, SUB_S_GAME_START, &GameStart, sizeof(GameStart));
|
||
}
|
||
|
||
// 录像开始
|
||
starGameRecord();
|
||
|
||
GameStart.wUserAction = m_wUserAction[m_wBankerUser];
|
||
ZeroMemory(GameStart.cbCardData, sizeof(GameStart.cbCardData));
|
||
addGameRecordAction(SUB_S_GAME_START, &GameStart, sizeof(GameStart));
|
||
|
||
return true;
|
||
|
||
}
|
||
|
||
//数据事件
|
||
bool CTableFrameSink::OnGameDataBase(WORD wRequestID, VOID * pData, WORD wDataSize)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
//使用牌库
|
||
void CTableFrameSink::UseCardLibrary()
|
||
{
|
||
WORD wChairID = INVALID_CHAIR;
|
||
|
||
//找到作弊玩家的位置
|
||
for (BYTE i = 0; i < GAME_PLAYER; i++)
|
||
{
|
||
//获取玩家信息
|
||
IServerUserItem *pServerUserItem = m_pITableFrame->GetTableUserItem(i);
|
||
if (pServerUserItem != NULL && pServerUserItem->canUseCardLib())
|
||
//if (pServerUserItem != NULL && pServerUserItem->GetGameID() == 131243)
|
||
{
|
||
CString strDebugInfo;
|
||
strDebugInfo.Format(_T("UserID[%d] ChairID[%d] NickName[%s] Is Cheat User\n"), pServerUserItem->GetUserID(), i, pServerUserItem->GetNickName());
|
||
::OutputDebugString(strDebugInfo);
|
||
|
||
wChairID = i;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (wChairID == INVALID_CHAIR)
|
||
{
|
||
return;
|
||
}
|
||
|
||
//获取玩家信息
|
||
IServerUserItem *pServerUserItem = m_pITableFrame->GetTableUserItem(wChairID);
|
||
DWORD dwCardLibIndex = pServerUserItem->getCardLibIndex();
|
||
|
||
pServerUserItem->addCardLibIndex();
|
||
|
||
//获取牌库
|
||
tagGameCardLibrary* pCardLib = m_pITableFrame->GetGameCardLibrary(1);
|
||
if (pCardLib == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_wCheatChairID = wChairID;
|
||
|
||
//牌库内所有牌
|
||
BYTE cbCardCount = pCardLib->cbCount;
|
||
BYTE aryCardData[LEN_CARD_LIB] = { 0 };
|
||
CopyMemory(aryCardData, pCardLib->cbData, cbCardCount);
|
||
|
||
//先把牌库中的牌删除
|
||
BYTE cbMoveCount = (MAX_COUNT - 1);
|
||
bool bRemoveSuccess = RemoveCards(m_cbRepertoryCard, CountArray(m_cbRepertoryCard), pCardLib->cbData, pCardLib->cbCount);
|
||
if (bRemoveSuccess)
|
||
{
|
||
//发牌从后面开始,作弊玩家为0时正好是最后13张牌,这时直接把作弊牌拷贝过去即可,如果不为0先把对应位置牌移动到最后,再把作弊牌拷贝过去
|
||
WORD wDesPos = CountArray(m_cbRepertoryCard) - ((wChairID + 1)*cbMoveCount);
|
||
if (wChairID > 0)
|
||
{
|
||
CopyMemory(&m_cbRepertoryCard[CountArray(m_cbRepertoryCard) - cbMoveCount], &m_cbRepertoryCard[wDesPos], cbMoveCount);
|
||
}
|
||
CopyMemory(&m_cbRepertoryCard[wDesPos], aryCardData, cbMoveCount);
|
||
}
|
||
}
|
||
|
||
//验证删除
|
||
bool CTableFrameSink::RemoveCards(BYTE cbCardData[], BYTE cbCardCount, BYTE cbRemoveCard[], BYTE cbRemoveCount)
|
||
{
|
||
//检验数据
|
||
ASSERT(cbRemoveCount <= cbCardCount);
|
||
|
||
BYTE cbDeleteCount = 0;
|
||
BYTE cbTempCardData[MAX_REPERTORY] = { 0 };
|
||
|
||
CopyMemory(cbTempCardData, cbCardData, cbCardCount*sizeof(cbCardData[0]));
|
||
//置零扑克
|
||
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)
|
||
{
|
||
ASSERT(FALSE);
|
||
return false;
|
||
}
|
||
//清理扑克
|
||
BYTE cbCardPos = 0;
|
||
for (BYTE i = 0; i < cbCardCount; i++)
|
||
{
|
||
if (cbTempCardData[i] != 0)
|
||
cbCardData[cbCardPos++] = cbTempCardData[i];
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
////////////////////////////// 私人场 ////////////////////////////////////////////
|
||
|
||
void CTableFrameSink::SetPrivateInfo(BYTE bGameTypeIdex, DWORD bGameRuleIdex)
|
||
{
|
||
|
||
}
|
||
|
||
// 重置统计数字
|
||
void CTableFrameSink::ResetPrivateEndInfo()
|
||
{
|
||
ZeroMemory(&m_PrivateEndInfo, sizeof(CMD_S_Private_End_Info));
|
||
m_BankContinueCount = 1;
|
||
}
|
||
|
||
// 获得私人场结束信息流
|
||
void CTableFrameSink::GetPrivateEndInfo(DataStream &kDataStream, bool bSend)
|
||
{
|
||
for (WORD i = 0; i < GAME_PLAYER; i++)
|
||
{
|
||
// 总积分
|
||
IServerUserItem* pServerUserItem = m_pITableFrame->GetTableUserItem(i);
|
||
if (pServerUserItem)
|
||
{
|
||
m_PrivateEndInfo.lAllScore[i] = pServerUserItem->GetUserScore();
|
||
}
|
||
}
|
||
|
||
m_PrivateEndInfo.StreamValue(kDataStream, bSend);
|
||
}
|
||
|
||
//判断私人场是否结束
|
||
bool CTableFrameSink::IsPrivateEnd()
|
||
{
|
||
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;
|
||
}
|
||
|
||
// 真实椅子数量
|
||
WORD CTableFrameSink::GetRealChairCount()
|
||
{
|
||
if (IsHasGameRule(eWNMJRuleEnum_PlayCount2))
|
||
{
|
||
return 2;
|
||
}
|
||
else if (IsHasGameRule(eWNMJRuleEnum_PlayCount3))
|
||
{
|
||
return 3;
|
||
}
|
||
|
||
return GAME_PLAYER;
|
||
}
|
||
|
||
// 获取下家椅子号;(wChairID+m_wPlayerCount-1)%m_wPlayerCount;
|
||
WORD CTableFrameSink::getNextChairID(WORD wChairID)
|
||
{
|
||
WORD wNextChairID = INVALID_CHAIR;
|
||
|
||
// 自由人数场;
|
||
if (IsHasGameRule(eWNMJRuleEnum_PlayCount_auto))
|
||
{
|
||
// 找到下一个存在的玩家;
|
||
for (int i = 1; i < GAME_PLAYER; i++)
|
||
{
|
||
wNextChairID = (wChairID + GAME_PLAYER - i) % GAME_PLAYER;
|
||
if (m_bActiveUser[wNextChairID])
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
WORD wRealChairCount = GetRealChairCount();
|
||
wNextChairID = (wChairID + wRealChairCount - 1) % wRealChairCount;
|
||
}
|
||
|
||
ASSERT(m_bActiveUser[wNextChairID]);
|
||
|
||
////下家剩余一张牌的情况下,出单牌必须是手牌最大的一张;
|
||
//WORD wNextChairID = (wChairID + 1) % wRealChairCount;
|
||
|
||
//// 如果当前玩家为空,继续下一个玩家(一共3个位置,最少2个人打牌,不可能存在连续两个为空,只判断一次就好了);
|
||
//if (!m_bActiveUser[wNextChairID])
|
||
//{
|
||
// wNextChairID = (wNextChairID + 1) % wRealChairCount;
|
||
//}
|
||
|
||
return wNextChairID;
|
||
}
|
||
|
||
// 获取要牌
|
||
BYTE CTableFrameSink::getSendCardData(WORD dwSendUser)
|
||
{
|
||
#define swapCard(a,b)\
|
||
BYTE nTemp = a;\
|
||
a = b;\
|
||
b = nTemp;\
|
||
|
||
BYTE MasterCard = m_cbMasterCheckCard[dwSendUser];
|
||
if (MasterCard == 0)
|
||
{
|
||
return m_cbRepertoryCard[--m_cbLeftCardCount];
|
||
}
|
||
|
||
bool bValue = false;
|
||
for (int i = m_cbLeftCardCount - 1; i >= 0; i--)
|
||
{
|
||
if (m_cbRepertoryCard[i] == MasterCard)
|
||
{
|
||
bValue = true;
|
||
swapCard(m_cbRepertoryCard[i], m_cbRepertoryCard[m_cbLeftCardCount - 1]);
|
||
break;
|
||
}
|
||
}
|
||
|
||
m_cbMasterCheckCard[dwSendUser] = 0;
|
||
BYTE nCard = m_cbRepertoryCard[--m_cbLeftCardCount];
|
||
if (!bValue)
|
||
{
|
||
//MyLog(_T("玩家ID: %d, 选择的牌已经不存在!"), dwSendUser);
|
||
m_pITableFrame->SendGameMessage(m_pITableFrame->GetTableUserItem(dwSendUser), "你选择的牌已经不存在!", SMT_CHAT);
|
||
}
|
||
|
||
return nCard;
|
||
}
|
||
|
||
void CTableFrameSink::sendMasterLeftCard(int nChairdID)
|
||
{
|
||
MasterLeftCard kMasterLeftCard;
|
||
ZeroMemory(&kMasterLeftCard, sizeof(kMasterLeftCard));
|
||
kMasterLeftCard.kMasterCheakCard = m_cbMasterCheckCard[nChairdID];
|
||
|
||
for (int i = 0; i < m_cbLeftCardCount; i++)
|
||
{
|
||
BYTE __ind = m_GameLogic.SwitchToCardIndex(m_cbRepertoryCard[i]);
|
||
kMasterLeftCard.kMasterLeftIndex[__ind]++;
|
||
}
|
||
|
||
m_pITableFrame->SendTableData(nChairdID, SUB_S_MASTER_LEFTCARD, &kMasterLeftCard, sizeof(kMasterLeftCard));
|
||
}
|
||
|
||
bool CTableFrameSink::IsHasGameRule(eWNMJRuleEnum eType)
|
||
{
|
||
if (m_pITableFrame == NULL) return false;
|
||
|
||
const tagPrivateFrameParameter* pPrivateFrame = m_pITableFrame->GetPrivateFrameInfo();
|
||
if (NULL == pPrivateFrame) return false;
|
||
return ((pPrivateFrame->dwGameRule & eType)!= 0);
|
||
}
|
||
|
||
void CTableFrameSink::InsertIntoDelCardIndex(WORD wChairID, BYTE cbRemoveCard[], BYTE cbRemoveCount)
|
||
{
|
||
for (BYTE i = 0; i < cbRemoveCount; ++i)
|
||
{
|
||
BYTE cbDelCardIndex = m_GameLogic.SwitchToCardIndex(cbRemoveCard[i]);
|
||
m_cbDelCardIndex[wChairID][cbDelCardIndex]++;
|
||
}
|
||
}
|
||
|
||
void CTableFrameSink::InsertIntoDelCardIndex(WORD wChairID, tagWeaveItem &reftagWeaveItem)
|
||
{
|
||
WORD wTargetAction = reftagWeaveItem.wWeaveKind;
|
||
BYTE cbTargetCard = reftagWeaveItem.cbCenterCard;
|
||
//删除扑克
|
||
switch (wTargetAction)
|
||
{
|
||
case WIK_DNBL: //东南北左
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard + 1, cbTargetCard + 3 };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_DNBC: //东南北中
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard - 1, cbTargetCard, cbTargetCard + 2 };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
|
||
}
|
||
case WIK_DNBR: //东南北右
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard - 3, cbTargetCard - 2, cbTargetCard };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
|
||
}
|
||
case WIK_DXBL: //东西北左
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard + 2, cbTargetCard + 3 };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
|
||
}
|
||
case WIK_DXBC: //东西北中
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard - 2, cbTargetCard, cbTargetCard + 1 };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
|
||
}
|
||
case WIK_DXBR: //东西北右
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard - 3, cbTargetCard - 1, cbTargetCard };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
|
||
}
|
||
case WIK_LEFT: //上牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard + 1, cbTargetCard + 2 };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_RIGHT: //上牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard - 2, cbTargetCard - 1, cbTargetCard };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_CENTER: //上牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard - 1, cbTargetCard, cbTargetCard + 1 };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_PENG: //碰牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard, cbTargetCard };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
case WIK_GANG: //杠牌操作
|
||
{
|
||
//删除扑克
|
||
BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard, cbTargetCard, cbTargetCard };
|
||
InsertIntoDelCardIndex(wChairID, cbRemoveCard, CountArray(cbRemoveCard));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
/////////////////////////////// 游戏录像 ///////////////////////////////////////////
|
||
|
||
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++)
|
||
{
|
||
if (!m_bActiveUser[i]) continue;
|
||
|
||
IServerUserItem* pUserItem = m_pITableFrame->GetTableUserItem(i);
|
||
if (pUserItem == NULL) 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();
|
||
|
||
BYTE cbCardData[MAX_COUNT] = { 0 };
|
||
m_GameLogic.SwitchToCardData(m_cbCardIndex[i], cbCardData, MAX_INDEX);
|
||
for (int i = 0; i < MAX_COUNT; i++)
|
||
{
|
||
kReocrdPlayer.cbCardData.push_back(cbCardData[i]);
|
||
}
|
||
m_kGameRecord.playersVec.push_back(kReocrdPlayer);
|
||
}
|
||
|
||
// 获取房间基本信息;
|
||
|
||
}
|
||
|
||
BYTE CTableFrameSink::GetFanShuType()
|
||
{
|
||
return (IsHasGameRule(eWNMJRuleEnum_OneTwoFAN) ? eWNMJRuleEnum_OneTwoFAN : eWNMJRuleEnum_TwoThreeFAN);
|
||
}
|
||
|
||
void CTableFrameSink::InsertGenHuCards(WORD wChairID, BYTE cbHuCardData)
|
||
{
|
||
if (wChairID < 0 || wChairID >= GAME_PLAYER)
|
||
{
|
||
return;
|
||
}
|
||
|
||
for (int i = 0; i < 4; ++i)
|
||
{
|
||
if (m_genHuCards[wChairID][i] == 0)
|
||
{
|
||
m_genHuCards[wChairID][i] = cbHuCardData;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
bool CTableFrameSink::IsInInsertGenHuCards(WORD wChairID, BYTE cbCardData)
|
||
{
|
||
if (wChairID < 0 || wChairID >= GAME_PLAYER)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
for (int i = 0; i < 4; ++i)
|
||
{
|
||
BYTE cbGenHuCard = m_genHuCards[wChairID][i];
|
||
if (cbGenHuCard == 0)
|
||
{
|
||
break;
|
||
}
|
||
if (cbGenHuCard == cbCardData)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
BYTE CTableFrameSink::GetHURuleType()
|
||
{
|
||
if (IsHasGameRule(eWNMJRuleEnum_YingHU))
|
||
{
|
||
return eWNMJHURuleEnum_YingHU;
|
||
}
|
||
|
||
if (IsHasGameRule(eWNMJRuleEnum_YiBianDaoHU))
|
||
{
|
||
return eWNMJHURuleEnum_YiBianDaoHU;
|
||
}
|
||
|
||
if (IsHasGameRule(eWNMJRuleEnum_HunHU))
|
||
{
|
||
return eWNMJHURuleEnum_HunHU;
|
||
}
|
||
return eWNMJHURuleEnum_Invalid;
|
||
}
|
||
|
||
void CTableFrameSink::InsertGenPengCards(WORD wChairID, BYTE cbPengCardData)
|
||
{
|
||
if (wChairID < 0 || wChairID >= GAME_PLAYER)
|
||
{
|
||
return;
|
||
}
|
||
|
||
for (int i = 0; i < 4; ++i)
|
||
{
|
||
if (m_genPengCards[wChairID][i] == 0)
|
||
{
|
||
m_genPengCards[wChairID][i] = cbPengCardData;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
bool CTableFrameSink::IsInInsertGenPengCards(WORD wChairID, BYTE cbCardData)
|
||
{
|
||
if (wChairID < 0 || wChairID >= GAME_PLAYER)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
for (int i = 0; i < 4; ++i)
|
||
{
|
||
BYTE cbGenPengCard = m_genPengCards[wChairID][i];
|
||
if (cbGenPengCard == 0)
|
||
{
|
||
break;
|
||
}
|
||
if (cbGenPengCard == cbCardData)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
bool CTableFrameSink::HasGenHuCards(WORD wChairID)
|
||
{
|
||
if (wChairID < 0 || wChairID >= GAME_PLAYER)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
for (int i = 0; i < 4; ++i)
|
||
{
|
||
BYTE cbGenHuCard = m_genHuCards[wChairID][i];
|
||
if (cbGenHuCard != 0)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////////////////
|