#include "StdAfx.h" #include "TableFrameSink.h" #include #include "../俱乐部/Source/MessageDef/Pb_SparrowMaJiang.pb.h" #include "../俱乐部/Source/GlobalDef/Util.h" //构造函数 CTableFrameSink::CTableFrameSink():m_GameLogic(this) { //游戏变量 m_startTime = 0; mPlayGameUserCount = 4; m_lSiceCount=0; m_wBankerUser=INVALID_CHAIR; ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex)); ZeroMemory(m_bTrustee,sizeof(m_bTrustee)); ZeroMemory( m_bPlayStatus,sizeof(m_bPlayStatus) ); ZeroMemory(m_lGameScore, sizeof(m_lGameScore)); ZeroMemory(m_lGameTatolScore, sizeof(m_lGameTatolScore)); ZeroMemory(m_HuPai, sizeof(m_HuPai)); ZeroMemory(m_PaiQuan, sizeof(m_PaiQuan)); ZeroMemory(m_TabbOutCardCout, sizeof(m_TabbOutCardCout)); //可以打出的牌就听牌的个数 ZeroMemory(m_TabbOutCardData, sizeof(m_TabbOutCardData)); //具体打哪几张牌 ZeroMemory(m_TabbTingCardCount, sizeof(m_TabbTingCardCount)); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 ZeroMemory(m_TabbTingCardData, sizeof(m_TabbTingCardData)); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 //出牌信息 m_cbOutCardData=0; m_cbOutCardCount=0; m_wOutCardUser=INVALID_CHAIR; ZeroMemory(m_cbDiscardCard,sizeof(m_cbDiscardCard)); ZeroMemory(m_cbDiscardCount,sizeof(m_cbDiscardCount)); ZeroMemory(m_cbLastDisCardData, sizeof(m_cbLastDisCardData)); ZeroMemory(m_cbLastDisCount, sizeof(m_cbLastDisCount)); ZeroMemory(LianXuHuPai, sizeof(LianXuHuPai)); //发牌信息 m_cbSendCardData=0; m_cbSendCardCount=0; m_cbLeftCardCount=0; m_cbShiJiLeftCardCount = 0; ZeroMemory(m_cbRepertoryCard,sizeof(m_cbRepertoryCard)); m_cbGangCount = 0;//打了几个杠 //运行变量 m_cbProvideCard=0; m_wResumeUser=INVALID_CHAIR; m_wCurrentUser=INVALID_CHAIR; m_wProvideUser=INVALID_CHAIR; //状态变量 //m_bSendStatus=false; // m_bGangStatus = false; m_GangPrivedUserID = -1; m_bGangOption = 0; //m_OutLastLaiZiData = 0; //最后杠牌数据,断线重连用的着 m_bQiangGang = false; //用户状态 ZeroMemory(m_bResponse,sizeof(m_bResponse)); ZeroMemory(m_cbUserAction,sizeof(m_cbUserAction)); ZeroMemory(m_cbOperateCard,sizeof(m_cbOperateCard)); ZeroMemory(m_cbPerformAction,sizeof(m_cbPerformAction)); ZeroMemory(m_cbOperateCaiCard, sizeof(m_cbOperateCaiCard)); //组合扑克 ZeroMemory(m_WeaveItemArray,sizeof(m_WeaveItemArray)); ZeroMemory(m_cbWeaveItemCount,sizeof(m_cbWeaveItemCount)); //结束信息 ZeroMemory(m_HuPai, sizeof(m_HuPai)); ZeroMemory(m_HuPaiLiuShui, sizeof(m_HuPaiLiuShui)); //组件变量 m_pITableFrame=NULL; m_pGameServiceOption=NULL; bIsHuang = false; mMaxTaiNum=5; mbaoMjUserID=0; ZeroMemory(mBaoTaiNum, sizeof(mBaoTaiNum)); nCountOptBao = 0; for (int i = 0; i < mPlayGameUserCount; i++) { mUserOptBaoTai[i] = -1; } mbStartBaoTai = 0; mBaoCacleDZFB = 0; ZeroMemory(mZFBBianScore, sizeof(mZFBBianScore)); mBLastBaoStart = false; ////////////////////////////////////////////////////////////////////////// CString strCfgFile; GetModuleFileName(NULL, strCfgFile.GetBufferSetLength(MAX_PATH), MAX_PATH); strCfgFile.ReleaseBuffer(); WCHAR* pTmp = wcsrchr(strCfgFile.GetBuffer(), L'\\'); if (pTmp) { *pTmp = 0; } PathAppend(strCfgFile.GetBufferSetLength(MAX_PATH), _T("cfg.ini")); strCfgFile.ReleaseBuffer(); GetPrivateProfileString(_T("datpath"), _T("value"), _T(""), mTableDatastrPath.GetBufferSetLength(MAX_PATH), MAX_PATH, strCfgFile.GetBuffer()); mTableDatastrPath.ReleaseBuffer(); mBWriteTableData = GetPrivateProfileInt(_T("writedata"),_T("value"),0,strCfgFile.GetBuffer()); ////////////////////////////////////////////////////////////////////////// mBZaHu = FALSE; ZeroMemory(m_bUsersGangStatus, GAME_PLAYER); m_bTwoPlayerFlag = FALSE; return; } //析构函数 CTableFrameSink::~CTableFrameSink(void) { } //接口查询 void * CTableFrameSink::QueryInterface(const IID & Guid, DWORD dwQueryVer) { QUERYINTERFACE(ITableFrameSink,Guid,dwQueryVer); QUERYINTERFACE(ITableUserAction,Guid,dwQueryVer); 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); //开始模式 m_pITableFrame->SetStartMode(START_MODE_FULL_READY); return true; } //复位桌子 VOID CTableFrameSink::RepositionSink() { //游戏变量 m_startTime = 0; m_lSiceCount=0; ZeroMemory(m_cbCardIndex,sizeof(m_cbCardIndex)); ZeroMemory(m_bTrustee,sizeof(m_bTrustee)); //ZeroMemory( m_cbGenCount,sizeof(m_cbGenCount) ); ZeroMemory( m_bPlayStatus,sizeof(m_bPlayStatus) ); //m_cbWinCount = 0; //memset( m_wWinOrder,INVALID_CHAIR,sizeof(m_wWinOrder) ); //ZeroMemory( m_lGameTax,sizeof(m_lGameTax) ); ZeroMemory(m_PaiQuan, sizeof(m_PaiQuan)); ZeroMemory(m_TabbOutCardCout, sizeof(m_TabbOutCardCout)); //可以打出的牌就听牌的个数 ZeroMemory(m_TabbOutCardData, sizeof(m_TabbOutCardData)); //具体打哪几张牌 ZeroMemory(m_TabbTingCardCount, sizeof(m_TabbTingCardCount)); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 ZeroMemory(m_TabbTingCardData, sizeof(m_TabbTingCardData)); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 //出牌信息 m_cbOutCardData=0; m_cbOutCardCount=0; m_wOutCardUser=INVALID_CHAIR; ZeroMemory(m_cbDiscardCard,sizeof(m_cbDiscardCard)); ZeroMemory(m_cbDiscardCount,sizeof(m_cbDiscardCount)); ZeroMemory(m_cbLastDisCardData, sizeof(m_cbLastDisCardData)); ZeroMemory(m_cbLastDisCount, sizeof(m_cbLastDisCount)); //发牌信息 m_cbSendCardData=0; m_cbSendCardCount=0; m_cbLeftCardCount=0; m_cbShiJiLeftCardCount = 0; ZeroMemory(m_cbRepertoryCard,sizeof(m_cbRepertoryCard)); m_cbGangCount = 0;//打了几个杠 //运行变量 m_cbProvideCard=0; m_wResumeUser=INVALID_CHAIR; m_wCurrentUser=INVALID_CHAIR; m_wProvideUser=INVALID_CHAIR; m_wBankerUser = INVALID_CHAIR; //状态变量 //m_bSendStatus=false; // m_bGangStatus = false; m_GangPrivedUserID = -1; m_bGangOption = 0; //m_OutLastLaiZiData = 0; //最后杠牌数据,断线重连用的着 m_bQiangGang = false; //用户状态 ZeroMemory(m_bResponse,sizeof(m_bResponse)); ZeroMemory(m_cbUserAction,sizeof(m_cbUserAction)); ZeroMemory(m_cbOperateCard,sizeof(m_cbOperateCard)); ZeroMemory(m_cbPerformAction,sizeof(m_cbPerformAction)); ZeroMemory(m_cbOperateCaiCard, sizeof(m_cbOperateCaiCard)); //组合扑克 ZeroMemory(m_WeaveItemArray,sizeof(m_WeaveItemArray)); ZeroMemory(m_cbWeaveItemCount,sizeof(m_cbWeaveItemCount)); //结束信息 m_cbMagicFirstData = 0; m_cbMagicSecondData = 0; bIsHuang = false; mbaoMjUserID = 0; ZeroMemory(mBaoTaiNum, sizeof(mBaoTaiNum)); mMaxBaoNum = SHUANG_LIANG_TAI; nCountOptBao = 0; for (int i = 0; i < mPlayGameUserCount; i++) { mUserOptBaoTai[i] = -1; } mbStartBaoTai = 0; ZeroMemory(mZFBBianScore, sizeof(mZFBBianScore)); mBLastBaoStart = false; mBZaHu = FALSE; ZeroMemory(m_bUsersGangStatus, GAME_PLAYER); return; } bool CTableFrameSink::RepayRecordStart() { m_bReplayRecordStart = true; m_UserReplayRecord.clear(); return true; } bool CTableFrameSink::RepayRecordEnd() { if (!m_bReplayRecordStart) return false; m_bReplayRecordStart = false; CMD_GR_ReplayRecordResp urr; ZeroMemory(&urr, sizeof(CMD_GR_ReplayRecordResp)); urr.m_UUID = 0; urr.m_UserId = 0; urr.m_startTime = m_startTime; urr.m_endTime = time(0); urr.m_gameconfig = m_gameConfig; //urr.m_UserId = pIServerUserItem->GetUserID(); for (int j = 0; j < mPlayGameUserCount; ++j) { IServerUserItem * pIServerUserItem = m_pITableFrame->GetTableUserItem(j); if ((pIServerUserItem == NULL) /*|| (pIServerUserItem->IsClientReady() == false)*/) continue; if (m_bTwoPlayerFlag&&j == TowMjNullseat) { continue; } auto& chairInfo = urr.m_chairList[j]; chairInfo.dwUserId = pIServerUserItem->GetUserID(); chairInfo.wChairId = pIServerUserItem->GetChairID(); lstrcpy(chairInfo.userName, pIServerUserItem->GetNickName()); lstrcpy(chairInfo.headUrl, pIServerUserItem->GetUserInfo ()->szHeadUrl); } urr.m_recordCount = m_UserReplayRecord.size(); RecordPacket::PB_CS_S_ReplayRecordResp RecordResp; RecordResp.set_m_uuid(urr.m_UUID); RecordResp.set_m_userid(urr.m_UserId); RecordResp.set_m_starttime(urr.m_startTime); RecordResp.set_m_endtime(urr.m_endTime); RecordResp.mutable_m_gameconfig()->set_bduolai(m_gameConfig.bDuoLai); RecordResp.mutable_m_gameconfig()->set_isowner(m_gameConfig.IsOwner); RecordResp.mutable_m_gameconfig()->set_roomid(m_gameConfig.RoomId); std::string sPrivateTableID = CW2AEX<1024>(m_gameConfig.sPrivateTableID, CP_UTF8).m_psz; RecordResp.mutable_m_gameconfig()->set_sprivatetableid(sPrivateTableID); RecordResp.mutable_m_gameconfig()->set_tmp1(m_gameConfig.tmp1); RecordResp.mutable_m_gameconfig()->set_tmp2(m_gameConfig.tmp2); RecordResp.mutable_m_gameconfig()->set_wdiscore(m_gameConfig.wDiScore); RecordResp.mutable_m_gameconfig()->set_wfanfei(m_gameConfig.wFanFei); RecordResp.mutable_m_gameconfig()->set_wfengding(m_gameConfig.wFengDing); RecordResp.mutable_m_gameconfig()->set_whadplaycount(m_gameConfig.wHadPlayCount); RecordResp.mutable_m_gameconfig()->set_wiplimit(m_gameConfig.wIpLimit); RecordResp.mutable_m_gameconfig()->set_wplaycountrule(m_gameConfig.wPlayCountRule); RecordResp.mutable_m_gameconfig()->set_wsubgameid(m_gameConfig.wSubGameID); for (WORD i = 0; i < mPlayGameUserCount; i++) { RecordPacket::pb_ChairRecord* Record = RecordResp.add_m_chairlist(); Record->set_wchairid(urr.m_chairList[i].wChairId); Record->set_dwuserid(urr.m_chairList[i].dwUserId); std::string userName = CW2AEX<1024>(urr.m_chairList[i].userName, CP_UTF8).m_psz; std::string headUrl = CW2AEX<1024>(urr.m_chairList[i].headUrl, CP_UTF8).m_psz; Record->set_username(userName); Record->set_headurl(headUrl); } for (auto& grp : m_UserReplayRecord) { RecordPacket::pb_GameRecordPacket* Packet = RecordResp.add_precordpacket(); Packet->set_wchairid(grp.wchairid()); Packet->set_wsubcmdid(grp.wsubcmdid()); Packet->set_wmaincmdid(grp.wmaincmdid()); Packet->set_pdata(grp.pdata()); } std::string pbresp = RecordResp.SerializePartialAsString(); m_pITableFrame->SaveReplayRecord((void*)pbresp.c_str(), pbresp.length()); m_UserReplayRecord.clear(); //delete replyRecordData;不能删除,已托管给SaveReplayRecord函数 return true; } bool CTableFrameSink::RepayRecord(WORD wChairID, WORD wSubCmdId, void* pData, WORD wSize) { RecordPacket::pb_GameRecordPacket pRecordPacket; pRecordPacket.set_wchairid(wChairID); pRecordPacket.set_wsubcmdid(wSubCmdId); pRecordPacket.set_wmaincmdid(MDM_GF_GAME); pRecordPacket.set_pdata((char*)pData,wSize); m_UserReplayRecord.push_back(pRecordPacket); return true; } //游戏开始 bool CTableFrameSink::OnEventGameStart() { m_startTime = time(0); ZeroMemory(m_lGameScore, sizeof(m_lGameScore)); srand((unsigned)time(NULL)*mGameTableId); m_cbMagicFirstData = 0; m_cbMagicSecondData = 0; //椅子数量 WORD wChairCount = m_pITableFrame->GetChairCount(); //开始记录回放数据 RepayRecordStart(); //重置发牌状态 m_isCanOutCard = false; //重置掉线玩家列表 m_offlineUsers.clear(); //设置状态 m_pITableFrame->SetGameStatus(GS_MJ_PLAY); //打印时间 DWORD timet = GetTickCount(); m_gameConfig.wHadPlayCount++; //混乱扑克,洗牌 m_lSiceCount = MAKELONG(MAKEWORD(rand() % 6 + 1, rand() % 6 + 1), MAKEWORD(rand() % 6 + 1, rand() % 6 + 1)); if (m_bTwoPlayerFlag) { m_cbLeftCardCount = m_GameLogic.RandCardData_Two(m_cbRepertoryCard); } else { m_cbLeftCardCount = m_GameLogic.RandCardData(m_cbRepertoryCard); } WritePaiCardData(m_gameConfig.sPrivateTableID, m_gameConfig.wHadPlayCount); if (1 == m_gameConfig.wHadPlayCount || m_wNextBankerUser == INVALID_CHAIR) { m_wBankerUser = 0; mbaoMjUserID = 0; } else { m_wBankerUser = m_wNextBankerUser; mbaoMjUserID = m_wNextBankerUser&0xff; } m_wNextBankerUser = INVALID_CHAIR; //BYTE byTest[] = { // 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 // 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 // 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 // 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 // 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 // 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 // 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 // 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 // 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 // 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 // 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 // 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 // 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //风东南西北 // 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //风东南西北 // 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //风东南西北 // 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //风东南西北 中发白 //}; //if (m_GameLogic.PeiPai(byTest)) // CopyMemory(m_cbRepertoryCard, byTest, sizeof(byTest)); ////////////////////////////////////////////////////////////////////////// ReadGameData(); /*m_wBankerUser = 2;*/ ////////////////////////////////////////////////////////////////////////// //分发扑克 for (WORD i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } m_bPlayStatus[i] = true; m_cbLeftCardCount -= (MAX_COUNT - 1);//每一个玩家都发出去13张牌,还剩多少 m_cbSendCardCount += (MAX_COUNT - 1);//每个玩家加13张牌 m_GameLogic.SwitchToCardIndex(&m_cbRepertoryCard[m_cbLeftCardCount], MAX_COUNT - 1, m_cbCardIndex[i]); } if (mMjType==0) { // m_cbSendCardCount++; //取一张财神牌 m_cbMagicFirstData = m_cbRepertoryCard[--m_cbLeftCardCount]; //获取下一张财神 m_cbMagicSecondData = GetNextMagicCardData(m_cbMagicFirstData); } //发送扑克,庄家摸牌 m_cbSendCardCount++;//第十四张牌 m_cbSendCardData = m_cbRepertoryCard[--m_cbLeftCardCount]; //设置变量 m_cbProvideCard = 0; m_wProvideUser = m_wBankerUser & 0x000F; m_wCurrentUser = m_wBankerUser & 0x000F; WORD ActionCard[6] = { 0 }; if (mMjType == 0) { m_GameLogic.SetMagicIndex(m_GameLogic.SwitchToCardIndex(m_cbMagicFirstData), m_GameLogic.SwitchToCardIndex(m_cbMagicSecondData)); // 胡牌判断 CChiHuRight chr; BYTE TaiShu = 0; m_cbUserAction[m_wCurrentUser] |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[m_wCurrentUser], NULL, 0, m_cbSendCardData, chr, TaiShu); m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++; if (m_cbUserAction[m_wCurrentUser] & WIK_ZI_MO) { m_cbUserAction[m_wCurrentUser] = WIK_TIAN_ZI_MO; } //杠牌判断 tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult, sizeof(GangCardResult)); m_cbUserAction[m_wCurrentUser] |= m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wCurrentUser], NULL, 0, GangCardResult); for (BYTE i = 0; i < GangCardResult.cbCardCount; i++) { ActionCard[i] = GangCardResult.cbCardData[i]; } } m_cbProvideCard = m_cbSendCardData; m_wResumeUser = m_wCurrentUser; //保存实际剩余的牌 m_cbShiJiLeftCardCount = m_cbLeftCardCount; //牌位第十三顿 截止 倒数第十四牌打完 没人胡牌 流局 //根据这个规则 删除26张牌 剩余的牌出完 没人胡牌 就是 流局 m_cbLeftCardCount -= 26;// //构造数据 CMD_S_GameStart GameStart; GameStart.wBankerUser = m_wBankerUser; GameStart.cbLeftCardCount = m_cbLeftCardCount; // [9/22/2017 Zoro] 翻财神和包麻将 不需要这个2个值,但发送时必须给0 GameStart.cbSliceCheckBankUser[0] = 0; GameStart.cbSliceCheckBankUser[1] = 0; ////////////////////////////////////////////////////////////////////////// WORD wSice = WORD(m_lSiceCount & 0xffff); GameStart.cbSiceLaiZi[0] = HIBYTE(wSice);//骰子 GameStart.cbSiceLaiZi[1] = LOBYTE(wSice);//骰子 if (mMjType==0) { GameStart.cbSiceLaiZi[2] = m_cbMagicFirstData;//财神 GameStart.cbSiceLaiZi[3] = m_cbMagicSecondData;//财神 } else { GameStart.cbSiceLaiZi[2] = 0;//财神 GameStart.cbSiceLaiZi[3] = 0;//财神 } if (m_bTwoPlayerFlag) { GameStart.cbTotalCardCount = MAX_REPERTORY_ZJ_Two; //麻将总数 } else { GameStart.cbTotalCardCount = MAX_REPERTORY_ZJ; //麻将总数 } GameStart.cbCurrPlay = m_gameConfig.wHadPlayCount;//当前局数 GameStart.cbOptTime = GAME_TIMEOUT;//出牌超时时间 ZeroMemory(GameStart.ActionCard, sizeof(GameStart.ActionCard)); CopyMemory(GameStart.ActionCard, ActionCard, sizeof(ActionCard)); if (mMjType==0) { TingCard(m_wCurrentUser); } //打印时间 //DWORD t2 = GetTickCount(); //DWORD hh = t2 - timet; //CString csTemp; //csTemp.Format(L"时间:%d \r\n", hh); //OutputDebugString(csTemp); //发送数据 SparrowMaJiang::PB_CS_S_GameStart GameStarts; GameStarts.set_wbankeruser(GameStart.wBankerUser); GameStarts.set_cbleftcardcount(GameStart.cbLeftCardCount); GameStarts.set_cbtotalcardcount(GameStart.cbTotalCardCount); GameStarts.set_cbopttime(GameStart.cbOptTime); GameStarts.set_cbcurrplay(GameStart.cbCurrPlay); for (WORD j = 0; j < 4; j++) { GameStarts.add_cbsicelaizi(GameStart.cbSiceLaiZi[j]); } for (WORD j = 0; j < 6; j++) { GameStarts.add_actioncard(GameStart.ActionCard[j]); } for (WORD j = 0; j < 2; j++) { GameStarts.add_cbslicecheckbankuser(GameStart.cbSliceCheckBankUser[j]); } if (mMjType==0) { //发送数据 for (WORD i = 0; i 0 && m_wCurrentUser == i) { m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]--;//从手上去掉抓的牌 } else { return false; } } ZeroMemory(GameStart.cbCardData, sizeof(GameStart.cbCardData)); m_GameLogic.SwitchToCardData(m_cbCardIndex[i], &GameStart.cbCardData[MAX_COUNT*i]); if (i == m_wCurrentUser) { GameStart.cbCardData[i * 14 + 13] = m_cbSendCardData;//把去掉的牌加到数组末尾, m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++;//把去掉的加进来 } GameStarts.set_wcurrentuser(GameStart.wCurrentUser); GameStarts.set_cbuseraction(GameStart.cbUserAction); for (WORD j = 0; j < MAX_COUNT * GAME_PLAYER; j++) { if (i == 0) { GameStarts.add_cbcarddata(GameStart.cbCardData[j]); } else { GameStarts.set_cbcarddata(j, GameStart.cbCardData[j]); } } //发送数据 std::string pbdata = GameStarts.SerializePartialAsString(); //发送数据 m_pITableFrame->SendTableData(i, SUB_S_GAME_START, (void*)pbdata.c_str(), pbdata.length()); } } else { for (WORD i = 0; i < wChairCount; i++) { //设置变量 GameStart.wCurrentUser = i; GameStart.cbUserAction = m_cbUserAction[i]; ZeroMemory(GameStart.cbCardData, sizeof(GameStart.cbCardData)); m_GameLogic.SwitchToCardData(m_cbCardIndex[i], &GameStart.cbCardData[MAX_COUNT*i]); if (i == m_wCurrentUser) { GameStart.cbCardData[i * 14 + 13] = m_cbSendCardData;//把去掉的牌加到数组末尾, m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++;//把去掉的加进来 } GameStarts.set_wcurrentuser(GameStart.wCurrentUser); GameStarts.set_cbuseraction(GameStart.cbUserAction); for (WORD j = 0; j < MAX_COUNT * GAME_PLAYER; j++) { if (i == 0) { GameStarts.add_cbcarddata(GameStart.cbCardData[j]); } else { GameStarts.set_cbcarddata(j, GameStart.cbCardData[j]); } } std::string pbdata = GameStarts.SerializePartialAsString(); //发送数据 m_pITableFrame->SendTableData(i, SUB_S_GAME_START, (void*)pbdata.c_str(), pbdata.length()); } } ZeroMemory(GameStart.cbCardData, sizeof(GameStart.cbCardData)); for (WORD i = 0; i < MAX_COUNT * GAME_PLAYER; i++) { GameStarts.set_cbcarddata(i, GameStart.cbCardData[i]); } //清手牌 旁观只能发一次 std::string pbdata = GameStarts.SerializePartialAsString(); //发送数据 m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GAME_START, (void*)pbdata.c_str(), pbdata.length()); //用户回放 for (WORD i = 0; i < wChairCount; i++) m_GameLogic.SwitchToCardData(m_cbCardIndex[i], &GameStart.cbCardData[MAX_COUNT*i]); for (WORD i = 0; i < MAX_COUNT * GAME_PLAYER; i++) { GameStarts.set_cbcarddata(i,GameStart.cbCardData[i]); } std::string pbrecord = GameStarts.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_GAME_START, (void*)pbrecord.c_str(), pbrecord.length()); if (mMjType==0) { if (m_TabbOutCardCout[m_wCurrentUser] > 0) HttpTingCard(m_wCurrentUser); return true; } mMaxBaoNum = BaoEnum::SHUANG_LIANG_TAI; mbaoMjUserID = m_wCurrentUser; mBaoTaiNum[m_wCurrentUser] = (mMaxBaoNum / 3) + 2; mbStartBaoTai = 1; mCurrentBaoUser = m_wBankerUser; mCurrentMinBaoTai = BaoEnum::SHUANG_LIANG_TAI; return true; } void CTableFrameSink::DeletePrivateTable(bool bSendState) { tagScoreInfo ScoreInfoArray[GAME_PLAYER]; ZeroMemory(&ScoreInfoArray, sizeof(ScoreInfoArray)); WORD wChairCount = m_pITableFrame->GetChairCount(); for (int i = 0; i < wChairCount; ++i) { IServerUserItem *pIUserItem = m_pITableFrame->GetTableUserItem(i); if (pIUserItem == NULL) continue; ScoreInfoArray[i].cbType = SCORE_TYPE_END; ScoreInfoArray[i].lScore = 0;// m_lUserTmpScore[i] - TEMP_MAX_SCORE; //记录临时分 } m_pITableFrame->WriteTableScore(ScoreInfoArray, CountArray(ScoreInfoArray)); ConcludeGame(GAME_STATUS_DELETE, bSendState); m_pITableFrame->DeletePrivateTableNow(); } //游戏结束 bool CTableFrameSink::OnEventGameConclude(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason, bool bSendState) { bool bFinish = (m_gameConfig.wHadPlayCount >= m_gameConfig.wPlayCountRule) ? 1 : 0; switch (cbReason) { case GER_DELETE_PRIVATE: // bFinish = 1; // bDelete = true; // if (!m_pITableFrame->IsGameStarted()) // { // DeletePrivateTable(bSendState); // return true; // } ConcludeGame(GS_MJ_FREE); DeletePrivateTable(bSendState); return true; case GER_NORMAL: //常规结束 { //变量定义 CMD_S_GameEnd GameEnd; ZeroMemory(&GameEnd, sizeof(GameEnd)); GameEnd.bFinish = bFinish;//1…… if (m_cbLeftCardCount <= 0 && bIsHuang)//荒庄了 { { GameEnd.bOptType = 2; //黄装了 if (m_gameConfig.wHadPlayCount>1) { m_wNextBankerUser = m_wBankerUser; m_wNextBankerUser = m_wNextBankerUser | 0x0100; int userID; if (m_wBankerUser>4) { userID = m_wBankerUser & 0x00ff; } else { userID = m_wBankerUser; } LianXuHuPai[userID]++; } else { /* m_wNextBankerUser = m_wBankerUser; m_wNextBankerUser = m_wNextBankerUser | 0x0100;*/ LianXuHuPai[m_wBankerUser & 0x00ff]++; } //黄庄了 //统计玩家积分,牌值 for (WORD i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } GameEnd.cbWanJiaScore[i] = m_lGameTatolScore[i];//各玩家积分4………… m_GameLogic.SwitchToCardData(m_cbCardIndex[i], GameEnd.cbCardData[i]); } } } else { if (mBZaHu) { GameEnd.bOptType = 4; } else { GameEnd.bOptType = 1; } GameEnd.HuPaiCard = m_cbProvideCard; GameEnd.wDianpao = m_wProvideUser; BYTE TempWanJiaCardCount = 0; m_wNextBankerUser = wChairID; //得到下一个坐庄的玩家 if (LianXuHuPai[wChairID] > 1) m_wNextBankerUser = m_wNextBankerUser | 0x0100; //统计积分,胡牌得分,玩家牌值 //保存本局所有用户的积分变动 除了胡牌玩家的 for (WORD i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } //m_lGameTatolScore[i] += m_lGameScore[i]; GameEnd.cbWanJiaScore[i] = m_lGameTatolScore[i];//各玩家积分3………… if (i == wChairID && m_wProvideUser == wChairID)continue; m_GameLogic.SwitchToCardData(m_cbCardIndex[i], GameEnd.cbCardData[i]); } //自摸 if (m_wProvideUser == wChairID) { //先减去 胡的这张牌 m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)]--; //把剩下的手牌保存到cbCardData m_GameLogic.SwitchToCardData(m_cbCardIndex[wChairID], GameEnd.cbCardData[wChairID]); //保存手牌数目 TempWanJiaCardCount = m_GameLogic.GetCardCount(m_cbCardIndex[wChairID]); //最后一张牌 加上刚刚减去的牌 GameEnd.cbCardData[wChairID][TempWanJiaCardCount] = m_cbProvideCard;//手牌数据4…… //还原减去的牌 m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)]++; } } GameEnd.bWanJiaId = wChairID;//玩家座位号 5…… //保存实际桌子剩下多少能够抓的牌 GameEnd.bLeftCardCount = m_cbShiJiLeftCardCount;//m_cbLeftCardCount + 26 + m_cbGangCount * 6;//剩余牌输量6………… CopyMemory(GameEnd.bLeftCardDada, m_cbRepertoryCard, GameEnd.bLeftCardCount);//剩余牌值7……………… //保存每个玩家的胡牌次数 CopyMemory(GameEnd.bZimo, m_HuPai, sizeof(m_HuPai));//玩家胡牌次数8………… //本次胡牌玩家的id GameEnd.dwOwnerID = m_pITableFrame->GetPrivateTableOwnerID();//获取房间ID,9……//胡牌玩家id GameEnd.playGameNum = m_gameConfig.wHadPlayCount;//得到第几局了,10………… for (BYTE i = 0; i < mPlayGameUserCount;i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } //保存16局 胡牌积分流水 m_HuPaiLiuShui[(m_gameConfig.wHadPlayCount-1)*4+i] = m_lGameScore[i]; } CopyMemory(GameEnd.lGameScoreDetail, m_HuPaiLiuShui, sizeof(m_HuPaiLiuShui));//游戏流水,10………… for (int i = 0; i < m_gameConfig.wHadPlayCount;i++) { /*CString strTmp; strTmp.Format(_T("胡牌流水->第%d局 %d,%d,%d,%d"), i,m_HuPaiLiuShui[i*4 + 0], m_HuPaiLiuShui[i*4 + 1], m_HuPaiLiuShui[i*4 + 2] , m_HuPaiLiuShui[i*4 + 3]);*/ //OutputDebugString(strTmp); } SparrowMaJiang::PB_CS_S_GameEnd pGameEnd; pGameEnd.set_bopttype(GameEnd.bOptType); pGameEnd.set_bwanjiaid(GameEnd.bWanJiaId); pGameEnd.set_wdianpao(GameEnd.wDianpao); pGameEnd.set_hupaicard(GameEnd.HuPaiCard); for (BYTE i = 0; i < mPlayGameUserCount; i++) { pGameEnd.add_cbwanjiascore(GameEnd.cbWanJiaScore[i]); pGameEnd.add_bzimo(GameEnd.bZimo[i]); } pGameEnd.set_bfinish(GameEnd.bFinish); pGameEnd.set_dwownerid(GameEnd.dwOwnerID); pGameEnd.set_bleftcardcount(GameEnd.bLeftCardCount); for (BYTE i = 0; i < GameEnd.bLeftCardCount; i++) { pGameEnd.add_bleftcarddada(GameEnd.bLeftCardDada[i]); } pGameEnd.set_playgamenum(GameEnd.playGameNum); for (BYTE i = 0; i < mPlayGameUserCount * 16; i++) { pGameEnd.add_lgamescoredetail(GameEnd.lGameScoreDetail[i]); } for (BYTE i = 0; i < mPlayGameUserCount; i++) { SparrowMaJiang::pb_cbCardData* CardData = pGameEnd.add_cbcarddata(); for (BYTE j = 0; j < 14; j++) { CardData->add_cbcarddatas(GameEnd.cbCardData[i][j]); } } std::string pbdata = pGameEnd.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_GAME_END, (void*)pbdata.c_str(), pbdata.length()); //发送结束信息 m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GAME_END, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GAME_END, (void*)pbdata.c_str(), pbdata.length()); tagScoreInfo ScoreInfoArray[GAME_PLAYER]; ZeroMemory(&ScoreInfoArray, sizeof(ScoreInfoArray)); for (WORD i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } IServerUserItem *pUserItem = m_pITableFrame->GetTableUserItem(i); if (NULL == pUserItem) continue; BYTE ScoreKind; if (m_lGameScore[i] > 0L) ScoreKind = SCORE_TYPE_WIN; else if (m_lGameScore[i] < 0L) ScoreKind = SCORE_TYPE_LOSE; else ScoreKind = SCORE_TYPE_DRAW; ScoreInfoArray[i].lScore = m_lGameScore[i]; ScoreInfoArray[i].cbType = ScoreKind; //if (i == wChairID)continue; //m_GameLogic.SwitchToCardData(m_cbCardIndex[i], GameEnd.cbCardData[i]); } m_pITableFrame->WriteTableScore(ScoreInfoArray, CountArray(ScoreInfoArray)); ConcludeGame(GS_MJ_FREE); if (bFinish) { DeletePrivateTable(true); } return true; } case GER_DISMISS: //游戏解散 { //变量定义 CMD_S_GameEnd GameEnd; ZeroMemory(&GameEnd, sizeof(GameEnd)); GameEnd.bFinish = 1; GameEnd.bOptType = 3; GameEnd.bWanJiaId = wChairID;//玩家座位号 5…… //保存实际桌子剩下多少能够抓的牌 GameEnd.bLeftCardCount = m_cbShiJiLeftCardCount;//m_cbLeftCardCount + 26 + m_cbGangCount * 6;//剩余牌输量6………… CopyMemory(GameEnd.bLeftCardDada, m_cbRepertoryCard, GameEnd.bLeftCardCount);//剩余牌值7……………… //保存每个玩家的胡牌次数 CopyMemory(GameEnd.bZimo, m_HuPai, sizeof(m_HuPai));//玩家胡牌次数8………… //本次胡牌玩家的id GameEnd.dwOwnerID = m_pITableFrame->GetPrivateTableOwnerID();//获取房间ID,9……//胡牌玩家id GameEnd.playGameNum = m_gameConfig.wHadPlayCount;//得到第几局了,10………… for (BYTE i = 0; i < GAME_PLAYER; i++) { m_GameLogic.SwitchToCardData(m_cbCardIndex[i], GameEnd.cbCardData[i]); m_HuPaiLiuShui[(m_gameConfig.wHadPlayCount - 1) * 4 + i] = m_lGameScore[i]; } CopyMemory(GameEnd.lGameScoreDetail, m_HuPaiLiuShui, sizeof(m_HuPaiLiuShui));//游戏流水,10………… //统计积分,胡牌得分,玩家牌值 //保存本局所有用户的积分变动 除了胡牌玩家的 for (WORD i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } GameEnd.cbWanJiaScore[i] = m_lGameTatolScore[i];//各玩家积分3………… } SparrowMaJiang::PB_CS_S_GameEnd pGameEnd; pGameEnd.set_bopttype(GameEnd.bOptType); pGameEnd.set_bwanjiaid(GameEnd.bWanJiaId); pGameEnd.set_wdianpao(GameEnd.wDianpao); pGameEnd.set_hupaicard(GameEnd.HuPaiCard); for (BYTE i = 0; i < mPlayGameUserCount; i++) { pGameEnd.add_cbwanjiascore(GameEnd.cbWanJiaScore[i]); pGameEnd.add_bzimo(GameEnd.bZimo[i]); } pGameEnd.set_bfinish(GameEnd.bFinish); pGameEnd.set_dwownerid(GameEnd.dwOwnerID); pGameEnd.set_bleftcardcount(GameEnd.bLeftCardCount); for (BYTE i = 0; i < GameEnd.bLeftCardCount; i++) { pGameEnd.add_bleftcarddada(GameEnd.bLeftCardDada[i]); } pGameEnd.set_playgamenum(GameEnd.playGameNum); for (BYTE i = 0; i < mPlayGameUserCount * 16; i++) { pGameEnd.add_lgamescoredetail(GameEnd.lGameScoreDetail[i]); } for (BYTE i = 0; i < mPlayGameUserCount; i++) { SparrowMaJiang::pb_cbCardData* CardData = pGameEnd.add_cbcarddata(); for (BYTE j = 0; j < 14; j++) { CardData->add_cbcarddatas(GameEnd.cbCardData[i][j]); } } std::string pbdata = pGameEnd.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_GAME_END, (void*)pbdata.c_str(), pbdata.length()); //发送结束信息 m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GAME_END, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GAME_END, (void*)pbdata.c_str(), pbdata.length()); if (m_pITableFrame->GetGameStatus() == GS_MJ_FREE) { DeletePrivateTable(true); return true; } tagScoreInfo ScoreInfoArray[GAME_PLAYER]; ZeroMemory(&ScoreInfoArray, sizeof(ScoreInfoArray)); for (WORD i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } IServerUserItem *pUserItem = m_pITableFrame->GetTableUserItem(i); if (NULL == pUserItem) continue; BYTE ScoreKind; if (m_lGameScore[i] > 0L) ScoreKind = SCORE_TYPE_WIN; else if (m_lGameScore[i] < 0L) ScoreKind = SCORE_TYPE_LOSE; else ScoreKind = SCORE_TYPE_DRAW; ScoreInfoArray[i].lScore = m_lGameScore[i]; ScoreInfoArray[i].cbType = ScoreKind; //if (i == wChairID)continue; //m_GameLogic.SwitchToCardData(m_cbCardIndex[i], GameEnd.cbCardData[i]); } m_pITableFrame->WriteTableScore(ScoreInfoArray, CountArray(ScoreInfoArray)); ConcludeGame(GS_MJ_FREE); DeletePrivateTable(bSendState); return true; } case GER_NETWORK_ERROR: //网络错误 case GER_USER_LEAVE: //用户强退 { if (pIServerUserItem != NULL){ DWORD dwUserID = pIServerUserItem->GetUserID(); m_offlineUsers.push_back(dwUserID); } // CString cstr = L""; // cstr.Format(L"异常游戏id:%d", dwUserID); //CTraceService::TraceString(cstr, TraceLevel_Warning); return true; } } //错误断言 ASSERT(FALSE); return false; } //发送场景duanxian用户断线重连 bool CTableFrameSink::OnEventSendGameScene(WORD wChiarID, IServerUserItem * pIServerUserItem, BYTE cbGameStatus, bool bSendSecret) { try { switch (cbGameStatus) { case GS_MJ_FREE: //空闲状态 { //变量定义 CMD_S_StatusFree StatusFree; memset(&StatusFree, 0, sizeof(StatusFree)); //游戏房主基础配置 CopyMemory(&StatusFree.gameConfig, &m_gameConfig, sizeof(CMD_S_GameConfig)); for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } StatusFree.lUserTmpScore[i] = (INT)m_lGameTatolScore[i]; } StatusFree.gameConfig.IsOwner = m_pITableFrame->GetPrivateTableOwnerID() == pIServerUserItem->GetUserID() ? 1 : 0; //构造数据 StatusFree.UserStat = pIServerUserItem->GetUserInfo()->cbUserStatus; //发送场景 return m_pITableFrame->SendGameScene(pIServerUserItem, &StatusFree, sizeof(StatusFree)); } case GS_MJ_PLAY: //游戏状态 { //变量定义 CMD_S_StatusPlay StatusPlay; memset(&StatusPlay, 0, sizeof(StatusPlay)); //游戏房主基础配置 CopyMemory(&StatusPlay.gameConfig, &m_gameConfig, sizeof(CMD_S_GameConfig)); CopyMemory(StatusPlay.lUserTmpScore, m_lGameTatolScore, sizeof(m_lGameTatolScore)); if (m_bTwoPlayerFlag) { StatusPlay.cbTotalCardCount = MAX_REPERTORY_ZJ_Two; } else { StatusPlay.cbTotalCardCount = MAX_REPERTORY_ZJ; } StatusPlay.cbLeftCardCount = m_cbLeftCardCount; StatusPlay.gameConfig.IsOwner = m_pITableFrame->GetPrivateTableOwnerID() == pIServerUserItem->GetUserID() ? 1 : 0; //游戏变量 StatusPlay.wBankerUser = m_wBankerUser; WORD wSice = WORD(m_lSiceCount & 0xffff); StatusPlay.lSiZi[0] = HIBYTE(wSice); StatusPlay.lSiZi[1] = LOBYTE(wSice); StatusPlay.lSiZi[2] = m_cbMagicFirstData; StatusPlay.lSiZi[3] = m_cbMagicSecondData; if (mMjType != 1) { StatusPlay.dwOwnerID = m_pITableFrame->GetPrivateTableOwnerID(); } CopyMemory(StatusPlay.cbDiscardCard, m_cbDiscardCard, sizeof(StatusPlay.cbDiscardCard)); CopyMemory(StatusPlay.cbDiscardCount, m_cbDiscardCount, sizeof(StatusPlay.cbDiscardCount)); StatusPlay.totalOptTime = 10; StatusPlay.leftOptTime = 0; //组合扑克 CopyMemory(StatusPlay.WeaveItemArray, m_WeaveItemArray, sizeof(m_WeaveItemArray)); CopyMemory(StatusPlay.cbWeaveCount, m_cbWeaveItemCount, sizeof(m_cbWeaveItemCount)); for (BYTE i = 0; i < mPlayGameUserCount; i++) { //StatusPlay.bWanLaiZi[i] = m_OutLaiZi[i]; //StatusPlay.bWanLaiZi[i] |= (m_OutHongZhongGang[i] << 4); //StatusPlay.bWanLaiZi[i] |= (m_OutFaCaiGang[i] << 8); if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } StatusPlay.cbCardCount[i] = m_GameLogic.GetCardCount(m_cbCardIndex[i]); } m_GameLogic.SwitchToCardData(m_cbCardIndex[wChiarID], StatusPlay.cbCardData);//手牌数据 StatusPlay.cbActionMask = m_cbUserAction[wChiarID]; //需要用到操作码 if (m_cbUserAction[wChiarID] & (WIK_AN_GANG | WIK_BU_GANG | WIK_DAN_BU_GANG | WIK_DAN_AN_GANG | WIK_SHUANG_AN_GANG | WIK_SAN_AN_GANG | WIK_QUANG_AN_GANG)) { tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult, sizeof(GangCardResult)); m_GameLogic.AnalyseGangCard(m_cbCardIndex[wChiarID], m_WeaveItemArray[wChiarID], m_cbWeaveItemCount[wChiarID], GangCardResult); for (BYTE i = 0; i < GangCardResult.cbCardCount; i++) { StatusPlay.gangCards[i] = GangCardResult.cbCardData[i]; } } ASSERT(m_wProvideUser >= 0 && m_wProvideUser <= 3); //当前到谁家 StatusPlay.wCurrentUser = (m_wCurrentUser == INVALID_CHAIR ? m_wProvideUser : m_wCurrentUser); BYTE OldUser = 0;//定义一个最后出牌用户 if ((m_wProvideUser == m_wCurrentUser&&m_wOutCardUser == INVALID_CHAIR) || (m_wProvideUser == m_wCurrentUser&&m_wResumeUser == m_wCurrentUser && m_cbProvideCard == 0))//牌权是摸牌得且没出牌 { //if (m_bGangStatus) //{ // StatusPlay.bPutCardData[m_wProvideUser] = m_OutLastLaiZiData; //} //else //{ if (m_bTwoPlayerFlag) { OldUser = (m_wProvideUser - 2 + GAME_PLAYER) % GAME_PLAYER; } else { OldUser = (m_wProvideUser - 1 + mPlayGameUserCount) % mPlayGameUserCount; } /* if (m_wProvideUser == 0) { OldUser = 3; } else OldUser = m_wProvideUser - 1;*/ BYTE TempIndex = 0; BYTE bDiscardCount = (m_cbDiscardCount[OldUser] - 1) >= 0 ? (m_cbDiscardCount[OldUser] - 1) : 0; for (BYTE i = bDiscardCount; i < 40; i++) { if (m_cbDiscardCard[OldUser][i] == 0) { TempIndex = i - 1; break; } } TempIndex = (TempIndex == 255) ? 0 : TempIndex; StatusPlay.bPutCardData[OldUser] = m_cbDiscardCard[OldUser][TempIndex]; //} } if (m_wProvideUser == m_wOutCardUser && m_wCurrentUser == INVALID_CHAIR)//当有人可以碰且没有碰时候 { StatusPlay.bPutCardData[m_wProvideUser] = m_cbProvideCard; StatusPlay.cbDiscardCard[m_wProvideUser][StatusPlay.cbDiscardCount[m_wProvideUser]++] = m_cbProvideCard; } if (wChiarID == StatusPlay.wCurrentUser&&m_wCurrentUser != INVALID_CHAIR&&m_wCurrentUser != m_wProvideUser)//表示当前牌权就在断线玩家手里,且是轮到他出牌(牌权碰来得) { ZeroMemory(StatusPlay.cbCardData, sizeof(StatusPlay.cbCardData)); BYTE TempCardData[MAX_INDEX]; CopyMemory(TempCardData, m_cbCardIndex[wChiarID], sizeof(TempCardData)); BYTE TempEndCardData = m_GameLogic.GetEndCard(TempCardData); BYTE TempCardIndex = m_GameLogic.SwitchToCardIndex(TempEndCardData); if (TempCardData[TempCardIndex] == 0){ ASSERT(false); return false; } TempCardData[TempCardIndex]--; BYTE cardNum = m_GameLogic.SwitchToCardData(TempCardData, StatusPlay.cbCardData); StatusPlay.cbCardData[cardNum] = TempEndCardData; } if (wChiarID == StatusPlay.wCurrentUser && m_wCurrentUser != INVALID_CHAIR && m_wCurrentUser == m_wProvideUser)//牌权是轮到他抓牌,未打出 { ZeroMemory(StatusPlay.cbCardData, sizeof(StatusPlay.cbCardData)); BYTE TempCardData[MAX_INDEX]; CopyMemory(TempCardData, m_cbCardIndex[wChiarID], sizeof(TempCardData)); BYTE TempCardIndex = m_GameLogic.SwitchToCardIndex(m_cbProvideCard); if (m_cbCardIndex[wChiarID][TempCardIndex] == 0)ASSERT(false); TempCardData[TempCardIndex]--; BYTE cardNum = m_GameLogic.SwitchToCardData(TempCardData, StatusPlay.cbCardData); StatusPlay.cbCardData[cardNum] = m_GameLogic.SwitchToCardData(TempCardIndex);//处理得到最后一张牌数据放最后 } ////////////////////////////////////////////////////////////////////////// if (mMjType == 1) { BYTE baojiauser; //台数 获取断线玩家 选取的台数。0-18 已选台数 255 过 254 未选 BYTE taishu; if (mbStartBaoTai == 1) { StatusPlay.wCurrentUser = mCurrentBaoUser; baojiauser = 4;//未确定包家 taishu = mCurrentMinBaoTai; } else if ((mbStartBaoTai == 2 || mbStartBaoTai == 3) && m_cbOutCardCount == 0) { StatusPlay.wCurrentUser = (m_wBankerUser & 0xff); baojiauser = mbaoMjUserID;//已经确定包家 taishu = mUserOptBaoTai[mbaoMjUserID]; } else { baojiauser = mbaoMjUserID;//已经确定包家 taishu = mUserOptBaoTai[mbaoMjUserID]; } //20不包 21表示未选择 BYTE cbTaiInfo[4] = { 0 }; for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (mUserOptBaoTai[i] == 255) { cbTaiInfo[i] = 20; } else if (mUserOptBaoTai[i] == -1) { cbTaiInfo[i] = 21; } else { cbTaiInfo[i] = mUserOptBaoTai[i]; } } //包家ID 6位 包家台数6位 每5位一个玩家台数 StatusPlay.dwOwnerID = 0; StatusPlay.dwOwnerID |= baojiauser; StatusPlay.dwOwnerID |= taishu << 6; StatusPlay.dwOwnerID |= cbTaiInfo[0] << 12; StatusPlay.dwOwnerID |= cbTaiInfo[1] << 17; StatusPlay.dwOwnerID |= cbTaiInfo[2] << 22; StatusPlay.dwOwnerID |= cbTaiInfo[3] << 27; /* CString str; str.Format(_T("包家=%d 包家台数=%d 东=%d 南=%d 西=%d 北=%d"), baojiauser, taishu, cbTaiInfo[0], cbTaiInfo[1], cbTaiInfo[2], cbTaiInfo[3]);*/ //OutputDebugString(str); } ////////////////////////////////////////////////////////////////////////// //发送场景 return m_pITableFrame->SendGameScene(pIServerUserItem, &StatusPlay, sizeof(StatusPlay)); } } return false; } catch (...) { OutputDebugString(_T("CTableFrameSink::OnEventSendGameScene... 触发异常\r\n")); return false; } } //定时器事件 bool CTableFrameSink::OnTimerMessage(DWORD wTimerID, WPARAM wBindParam) { return false; } //游戏消息处理 void CTableFrameSink::SetGameConfig(VOID * pDataBuffer, WORD wDataSize, std::wstring sPrivateRoomId) { tagGameConfig* ppConfig = (tagGameConfig*)pDataBuffer; m_gameConfig.wSubGameID = ppConfig->wSubGameID; m_gameConfig.wDiScore = ppConfig->wPlayRule; m_gameConfig.wFanFei = ppConfig->wMaxFanRule; m_gameConfig.wIpLimit = ppConfig->wMaxScore; m_gameConfig.wPlayCountRule = ppConfig->wPlayCountRule; m_gameConfig.RoomId = ppConfig->wHadPlayCount; m_gameConfig.wHadPlayCount = 0; m_gameConfig.bDuoLai = 1; m_gameConfig.wFengDing = ppConfig->wFengDing; m_gameConfig.tmp1 = ppConfig->tmp1; if (m_gameConfig.wFengDing ==0||m_gameConfig.wFengDing==5) { mMaxTaiNum = 5; }else if (m_gameConfig.wFengDing ==6 || m_gameConfig.wFengDing == 7) { mMaxTaiNum = m_gameConfig.wFengDing; } else { mMaxTaiNum = 20; } lstrcpy(m_gameConfig.sPrivateTableID, sPrivateRoomId.c_str()); //bGameType = m_gameConfig.wSubGameID; //bGameZuiDiFen = m_gameConfig.wDiScore*(bGameType == HongZhong ? 10 : 16); //协议修改,值变成 4 3 2 if (m_gameConfig.tmp1==0) { mPlayGameUserCount = 4; } else { if (m_gameConfig.tmp1==2) { m_bTwoPlayerFlag = TRUE; mPlayGameUserCount = 3; m_pITableFrame->SetStartMode(START_MODE_ALL_READY); } else { mPlayGameUserCount = m_gameConfig.tmp1; } } //switch (Value) //{ //case 0: // mPlayGameUserCount = 4; // break; //case 1: // mPlayGameUserCount = 3; // break; //case 2: // mPlayGameUserCount = 2; // break; //default: // break; //} m_pITableFrame->SetChairCount(mPlayGameUserCount); ASSERT(m_gameConfig.wSubGameID >= 0 && m_gameConfig.wSubGameID < MahJongType::count); if (m_gameConfig.wSubGameID==30) { mMjType = 0;//翻财神 } else { mMjType = 1;//包麻将 m_gameConfig.bDuoLai = ppConfig->bDuoLai;//包麻将 用来控制 是否计算 大牌分数 0计算 1不计算 mBaoCacleDZFB = !m_gameConfig.bDuoLai; } m_GameLogic.SetGameLogicMjType(mMjType); if (!sPrivateRoomId.empty()) { mGameTableId = _wtoi(sPrivateRoomId.c_str()); } else { mGameTableId = 1; } } //游戏消息处理 bool CTableFrameSink::OnGameMessage(WORD wSubCmdID, VOID* pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem) { switch (wSubCmdID) { case SUB_C_OUT_CARD: //出牌消息 { //定义变量 SparrowMaJiang::PB_CS_C_OutCard OutCard; OutCard.ParseFromArray(pDataBuffer, wDataSize); //用户效验 if (pIServerUserItem->GetUserStatus() != US_PLAYING) return true; return OnUserOutCard(pIServerUserItem->GetChairID(), OutCard.cbcarddata()); } case SUB_C_OPERATE_CARD: //操作消息 { SparrowMaJiang::PB_CS_C_OperateCard OperateCard; OperateCard.ParseFromArray(pDataBuffer, wDataSize); //用户效验 if (pIServerUserItem->GetUserStatus() != US_PLAYING) return true; //消息处理 CMD_C_OperateCard pOperateCard; for (WORD i = 0; i < 4; i++) { pOperateCard.cbCaiShenCard[i] = OperateCard.cbcaishencard(i); } pOperateCard.cbOperateCard = OperateCard.cboperatecard(); pOperateCard.cbOperateCode = OperateCard.cboperatecode(); return OnUserOperateCard(pIServerUserItem->GetChairID(), pOperateCard.cbOperateCode, pOperateCard.cbOperateCard, pOperateCard.cbCaiShenCard); } case SUB_C_TRUSTEE: //托管 { SparrowMaJiang::PB_CS_C_Trustee pTrustee; pTrustee.ParseFromArray(pDataBuffer, wDataSize); m_bTrustee[pIServerUserItem->GetChairID()] = pTrustee.btrustee(); CMD_S_Trustee Trustee; Trustee.bTrustee = pTrustee.btrustee(); Trustee.wChairID = pIServerUserItem->GetChairID(); SparrowMaJiang::PB_CS_S_Trustee Trustees; Trustees.set_btrustee(Trustee.bTrustee); Trustees.set_wchairid(Trustee.wChairID); std::string pbdata = Trustees.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_TRUSTEE, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_TRUSTEE, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_TRUSTEE, (void*)pbdata.c_str(), pbdata.length()); return true; } case SUB_C_SELECT_BAO:{ SparrowMaJiang::PB_CS_C_BAO pBaoTai; pBaoTai.ParseFromArray(pDataBuffer, wDataSize); SelectBaoTaiNum(pIServerUserItem->GetChairID(), pBaoTai.cbtainum()); return true; } case SUB_C_SELECT_CAI:{ SparrowMaJiang::PB_CS_C_Magic pMagic; pMagic.ParseFromArray(pDataBuffer, wDataSize); SelectBaoMagic(pIServerUserItem->GetChairID(), pMagic.cbmagicfirst(), pMagic.cbmagicsenced()); return true; } default: return false; } return false; } //框架消息处理 bool CTableFrameSink::OnFrameMessage(WORD wSubCmdID, VOID * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem) { return false; } //用户断线重连 bool CTableFrameSink::OnActionUserConnect(WORD wChairID, IServerUserItem * pIServerUserItem) { auto dwUserID = pIServerUserItem->GetUserID(); auto iter = std::find(m_offlineUsers.begin(), m_offlineUsers.end(), dwUserID); if (m_TabbOutCardCout[wChairID] > 0) HttpTingCard(wChairID); if (iter != end(m_offlineUsers)) { m_offlineUsers.erase(iter); //玩家重新上线 return true; } return true; } //用户坐下 bool CTableFrameSink::OnActionUserSitDown(WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser) { return true; } //游戏中途旁观进入 bool CTableFrameSink::PerformLookonLogin(IServerUserItem * pIServerUserItem) { CMD_S_PangGuan StatusPlay; memset(&StatusPlay, 0, sizeof(StatusPlay)); //游戏房主基础配置 CopyMemory(&StatusPlay.gameConfig, &m_gameConfig, sizeof(CMD_S_GameConfig)); CopyMemory(StatusPlay.lUserTmpScore, m_lGameTatolScore, sizeof(m_lGameTatolScore)); if (m_bTwoPlayerFlag) { StatusPlay.cbTotalCardCount = MAX_REPERTORY_ZJ_Two; } else { StatusPlay.cbTotalCardCount = MAX_REPERTORY_ZJ; } StatusPlay.cbLeftCardCount = m_cbLeftCardCount; StatusPlay.gameConfig.IsOwner = m_pITableFrame->GetPrivateTableOwnerID() == pIServerUserItem->GetUserID() ? 1 : 0; StatusPlay.GameStatus = m_pITableFrame->IsDrawStarted(); if (StatusPlay.GameStatus) { //游戏变量 StatusPlay.wBankerUser = m_wBankerUser; WORD wSice = WORD(m_lSiceCount & 0xffff); StatusPlay.lSiZi[0] = HIBYTE(wSice); StatusPlay.lSiZi[1] = LOBYTE(wSice); StatusPlay.lSiZi[2] = m_cbMagicFirstData; StatusPlay.lSiZi[3] = m_cbMagicSecondData; if (mMjType!=1) { StatusPlay.dwOwnerID = m_pITableFrame->GetPrivateTableOwnerID(); } CopyMemory(StatusPlay.cbDiscardCard, m_cbDiscardCard, sizeof(StatusPlay.cbDiscardCard)); CopyMemory(StatusPlay.cbDiscardCount, m_cbDiscardCount, sizeof(StatusPlay.cbDiscardCount)); for (BYTE i = 0; i < mPlayGameUserCount; i++) { //StatusPlay.bWanLaiZi[i] = m_OutLaiZi[i]; //StatusPlay.bWanLaiZi[i] |= (m_OutHongZhongGang[i] << 4); //StatusPlay.bWanLaiZi[i] |= (m_OutFaCaiGang[i] << 8); if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } StatusPlay.cbCardCount[i] = m_GameLogic.GetCardCount(m_cbCardIndex[i]); } StatusPlay.totalOptTime = 10; StatusPlay.leftOptTime = 0; ASSERT(m_wProvideUser >= 0 && m_wProvideUser <= 3); //当前到谁家 StatusPlay.wCurrentUser = (m_wCurrentUser == INVALID_CHAIR ? m_wProvideUser : m_wCurrentUser); WORD OldUser = 0;//定义一个最后出牌用户` if (m_wProvideUser == m_wCurrentUser&&m_wOutCardUser == INVALID_CHAIR)//牌权是摸牌得且没出牌 { //if (m_bGangStatus) //{ // StatusPlay.bPutCardData[m_wProvideUser] = m_OutLastLaiZiData; //} //else //{ if (m_bTwoPlayerFlag) { OldUser = (m_wProvideUser - 2 + GAME_PLAYER) % GAME_PLAYER; } else { OldUser = (m_wProvideUser - 1 + mPlayGameUserCount) % mPlayGameUserCount; } BYTE TempIndex = 0; BYTE bDiscardCount = (m_cbDiscardCount[OldUser] - 1) >= 0 ? (m_cbDiscardCount[OldUser] - 1) : 0; for (BYTE i = bDiscardCount; i < 40; i++) { if (m_cbDiscardCard[OldUser][i] == 0) { TempIndex = i - 1; break; } } TempIndex = (TempIndex == 255) ? 0 : TempIndex; StatusPlay.bPutCardData[OldUser] = m_cbDiscardCard[OldUser][TempIndex]; //} } if (m_wProvideUser == m_wOutCardUser&& m_wCurrentUser == INVALID_CHAIR)//当有人可以碰且没有碰时候 { StatusPlay.bPutCardData[m_wProvideUser] = m_cbProvideCard; StatusPlay.cbDiscardCard[m_wProvideUser][StatusPlay.cbDiscardCount[m_wProvideUser]++] = m_cbProvideCard; } //组合扑克 CopyMemory(StatusPlay.WeaveItemArray, m_WeaveItemArray, sizeof(m_WeaveItemArray)); CopyMemory(StatusPlay.cbWeaveCount, m_cbWeaveItemCount, sizeof(m_cbWeaveItemCount)); if (mMjType == 1) { BYTE baojiauser; //台数 获取断线玩家 选取的台数。0-18 已选台数 255 过 254 未选 BYTE taishu; if (IsCanReturnResult()) { baojiauser = mbaoMjUserID; taishu = mUserOptBaoTai[mbaoMjUserID]; } else { baojiauser = 4; taishu = mCurrentMinBaoTai; } StatusPlay.wCurrentUser = mCurrentBaoUser; BYTE cbTaiInfo[4] = { 0 }; for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (mUserOptBaoTai[i] == 255) { cbTaiInfo[i] = 20; } else if (mUserOptBaoTai[i] == -1) { cbTaiInfo[i] = 21; } else { cbTaiInfo[i] = mUserOptBaoTai[i]; } } StatusPlay.dwOwnerID = 0; StatusPlay.dwOwnerID |= baojiauser; StatusPlay.dwOwnerID |= taishu << 6; StatusPlay.dwOwnerID |= cbTaiInfo[0] << 12; //东 StatusPlay.dwOwnerID |= cbTaiInfo[1] << 17; //南 StatusPlay.dwOwnerID |= cbTaiInfo[2] << 22; //西 StatusPlay.dwOwnerID |= cbTaiInfo[3] << 27; //北 CString str; str.Format(_T("旁观进入 包家=%d 包家台数=%d 东=%d 南=%d 西=%d 北=%d"), baojiauser, taishu, cbTaiInfo[0], cbTaiInfo[1], cbTaiInfo[2], cbTaiInfo[3]); //OutputDebugString(str); } } SparrowMaJiang::PB_CS_S_PangGuan PangGuan; PangGuan.mutable_gameconfig()->set_bduolai(StatusPlay.gameConfig.bDuoLai); PangGuan.mutable_gameconfig()->set_isowner(StatusPlay.gameConfig.IsOwner); PangGuan.mutable_gameconfig()->set_roomid(StatusPlay.gameConfig.RoomId); std::string sPrivateTableID = CW2AEX<1024>(StatusPlay.gameConfig.sPrivateTableID, CP_UTF8).m_psz; PangGuan.mutable_gameconfig()->set_sprivatetableid(sPrivateTableID); PangGuan.mutable_gameconfig()->set_tmp1(StatusPlay.gameConfig.tmp1); PangGuan.mutable_gameconfig()->set_tmp2(StatusPlay.gameConfig.tmp2); PangGuan.mutable_gameconfig()->set_wdiscore(StatusPlay.gameConfig.wDiScore); PangGuan.mutable_gameconfig()->set_wfanfei(StatusPlay.gameConfig.wFanFei); PangGuan.mutable_gameconfig()->set_wfengding(StatusPlay.gameConfig.wFengDing); PangGuan.mutable_gameconfig()->set_whadplaycount(StatusPlay.gameConfig.wHadPlayCount); PangGuan.mutable_gameconfig()->set_wiplimit(StatusPlay.gameConfig.wIpLimit); PangGuan.mutable_gameconfig()->set_wplaycountrule(StatusPlay.gameConfig.wPlayCountRule); PangGuan.mutable_gameconfig()->set_wsubgameid(StatusPlay.gameConfig.wSubGameID); for (BYTE j = 0; j < mPlayGameUserCount; j++) { PangGuan.add_lusertmpscore(StatusPlay.lUserTmpScore[j]); PangGuan.add_bputcarddata(StatusPlay.bPutCardData[j]); PangGuan.add_cbcardcount(StatusPlay.cbCardCount[j]); PangGuan.add_cbweavecount(StatusPlay.cbWeaveCount[j]); PangGuan.add_cbdiscardcount(StatusPlay.cbDiscardCount[j]); SparrowMaJiang::pb_cbDiscardCard* DiscardCard = PangGuan.add_cbdiscardcard(); for (BYTE i = 0; i < 40; i++) { DiscardCard->add_cbdiscardcard(StatusPlay.cbDiscardCard[j][i]); } SparrowMaJiang::pb_WeaveItemArray* WeaveItemArray = PangGuan.add_weaveitemarray(); for (BYTE i = 0; i < 4; i++) { SparrowMaJiang::pb_WeaveItem* WeaveItem = WeaveItemArray->add_weaveitem(); WeaveItem->set_cbcentercard(StatusPlay.WeaveItemArray[j][i].cbCenterCard); WeaveItem->set_cbpubliccard(StatusPlay.WeaveItemArray[j][i].cbPublicCard); WeaveItem->set_cbweavekind(StatusPlay.WeaveItemArray[j][i].cbWeaveKind); WeaveItem->set_wprovideuser(StatusPlay.WeaveItemArray[j][i].wProvideUser); for (BYTE k = 0; k < 4; k++) { WeaveItem->add_cbmargicoffset(StatusPlay.WeaveItemArray[j][i].cbMargicOffset[k]); } } } PangGuan.set_gamestatus(StatusPlay.GameStatus); PangGuan.set_cbtotalcardcount(StatusPlay.cbTotalCardCount); PangGuan.set_cbleftcardcount(StatusPlay.cbLeftCardCount); PangGuan.set_wbankeruser(StatusPlay.wBankerUser); for (BYTE j = 0; j < 4; j++) { PangGuan.add_lsizi(StatusPlay.lSiZi[j]); } PangGuan.set_dwownerid(StatusPlay.dwOwnerID); PangGuan.set_wcurrentuser(StatusPlay.wCurrentUser); PangGuan.set_totalopttime(StatusPlay.totalOptTime); PangGuan.set_leftopttime(StatusPlay.leftOptTime); std::string pbdata = PangGuan.SerializePartialAsString(); return m_pITableFrame->SendUserItemData(pIServerUserItem, SUB_S_PANGGUAN, (void*)pbdata.c_str(), pbdata.length()); } //用户起来 bool CTableFrameSink::OnActionUserStandUp(WORD wChairID, IServerUserItem * pIServerUserItem, bool bLookonUser) { //庄家设置 if (bLookonUser == false && !QueryUseTemporaryScore()) { m_bTrustee[wChairID]=false; CMD_S_Trustee Trustee; Trustee.bTrustee=false; Trustee.wChairID = wChairID; SparrowMaJiang::PB_CS_S_Trustee Trustees; Trustees.set_btrustee(Trustee.bTrustee); Trustees.set_wchairid(Trustee.wChairID); std::string pbdata = Trustees.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_TRUSTEE, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_TRUSTEE, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_TRUSTEE, (void*)pbdata.c_str(), pbdata.length()); } return true; } //用户出牌 bool CTableFrameSink::OnUserOutCard(WORD wChairID, BYTE cbCardData) { if (mMjType == 1 && mbStartBaoTai != 3) { return false; } if (mMjType == 1 && wChairID == mbaoMjUserID&&m_cbUserAction[wChairID] & (WIK_TIAN_ZI_MO | WIK_ZI_MO)) { HandleBaoMjZaHu(wChairID, WIK_NULL, cbCardData, NULL); return true; } m_bQiangGang = false; //效验状态 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) return false; if (m_GameLogic.IsValidCard(cbCardData) == false) return false; if ((m_GameLogic.GetCardCount(m_cbCardIndex[wChairID]) - 2) % 3 != 0) { return false; } //删除扑克 if (m_GameLogic.RemoveCard(m_cbCardIndex[wChairID], cbCardData) == false) { ASSERT(FALSE); return false; } ZeroMemory(&m_cbLastDisCardData[wChairID], sizeof(m_cbLastDisCardData[wChairID])); m_cbLastDisCount[wChairID] = 0; //for (BYTE i = 0; i < GAME_PLAYER; i++) //{ // if (i == wChairID)continue; // m_cbLastDisCardData[i][m_cbLastDisCount[i]++] = cbCardData;//打出得牌,放到其他玩家得记忆库里面 //} //m_bSendStatus = true; //if (m_bGangStatus) //{ //m_OutLastLaiZiData = 0; //最后杠牌数据,断线重连用的着 // m_bGangStatus = false; ZeroMemory(m_bUsersGangStatus, GAME_PLAYER); m_bGangOption = 0; m_GangPrivedUserID = -1; //m_bGangOutStatus = true; //} m_cbUserAction[wChairID] = WIK_NULL; m_cbPerformAction[wChairID] = WIK_NULL; //出牌记录 m_cbOutCardCount++; m_wOutCardUser = wChairID; //记录出牌人 m_cbOutCardData = cbCardData; //记录出牌数据 m_TabbOutCardCout[wChairID] = 0; //可以打出的牌就听牌的个数 ZeroMemory(m_TabbOutCardData[wChairID], sizeof(m_TabbOutCardData[wChairID])); //具体打哪几张牌 ZeroMemory(m_TabbTingCardCount[wChairID], sizeof(m_TabbTingCardCount[wChairID])); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 ZeroMemory(m_TabbTingCardData[wChairID], sizeof(m_TabbTingCardData[wChairID])); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 BYTE FanHui[MAX_INDEX] = { 0 }; /*m_GameLogic.IsCanChangCardAndCount(m_cbCardIndex[wChairID], FanHui); if (m_GameLogic.IsTingCard(m_cbCardIndex[wChairID], m_WeaveItemArray[wChairID], m_cbWeaveItemCount[wChairID], FanHui)) {*/ OutTingCard(wChairID, m_GameLogic.SwitchToCardIndex(m_cbOutCardData)); //} //构造数据 CMD_S_OutCard OutCard; OutCard.wOutCardUser = wChairID; OutCard.cbOutCardData = cbCardData; OutCard.bOptType = 0; SparrowMaJiang::PB_CS_S_OutCard Card; Card.set_woutcarduser(OutCard.wOutCardUser); Card.set_cboutcarddata(OutCard.cbOutCardData); Card.set_bopttype(OutCard.bOptType); //发送数据 std::string pbdata = Card.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_OUT_CARD, (void*)pbdata.c_str(), pbdata.length()); //发送消息 m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_OUT_CARD, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_OUT_CARD, (void*)pbdata.c_str(), pbdata.length()); m_wProvideUser = wChairID; m_cbProvideCard = cbCardData; //用户切换 m_wCurrentUser = (wChairID + 1) % mPlayGameUserCount; if (m_bTwoPlayerFlag&& m_wCurrentUser==TowMjNullseat) { m_wCurrentUser++; } //响应判断 bool bAroseAction = EstimateUserRespond(wChairID, cbCardData, EstimatKind_OutCard); //派发扑克 if (bAroseAction == false) { DispatchCardData(m_wCurrentUser); } return true; } //用户操作 bool CTableFrameSink::OnUserOperateCard(WORD wChairID, int cbOperateCode, BYTE cbOperateCard, BYTE cbCaiShenCard[4]) { //效验状态 ASSERT(m_pITableFrame->GetGameStatus() == GS_MJ_PLAY); if (m_pITableFrame->GetGameStatus() != GS_MJ_PLAY) return true; //效验用户 注意:机器人有可能发生此断言 //ASSERT((wChairID==m_wCurrentUser)||(m_wCurrentUser==INVALID_CHAIR)); if ((wChairID != m_wCurrentUser) && (m_wCurrentUser != INVALID_CHAIR)) return true; tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult, sizeof(GangCardResult)); //被动动作 if (m_wCurrentUser == INVALID_CHAIR&&wChairID != m_wProvideUser)//表示有人出牌后,下一个人还未摸牌这段时间内,有人对上一张出牌有吃胡、杠、碰等操作 { //效验状态 if (m_bResponse[wChairID] == true) return true; if ((cbOperateCode != WIK_NULL) && ((m_cbUserAction[wChairID] & cbOperateCode) == 0)) return true; //变量定义 WORD wTargetUser = wChairID; int cbTargetAction = cbOperateCode; //设置变量 m_bResponse[wChairID] = true; m_cbPerformAction[wChairID] = cbOperateCode; m_cbOperateCard[wChairID] = cbOperateCard; CopyMemory(m_cbOperateCaiCard[wChairID], cbCaiShenCard, sizeof(cbCaiShenCard)); if (mMjType == 1 && wTargetUser == mbaoMjUserID&&cbOperateCode != WIK_CHI_HU&&m_cbUserAction[wChairID] & WIK_CHI_HU) { cbTargetAction = WIK_ZAHU; m_cbPerformAction[wChairID] = WIK_ZAHU; } if (mMjType == 1) { if (m_cbPerformAction[mbaoMjUserID] == WIK_ZAHU && (wTargetUser == (mbaoMjUserID + 1) % mPlayGameUserCount || wTargetUser == ((m_wProvideUser + (mPlayGameUserCount - 1)) % mPlayGameUserCount))) { HandleBaoMjZaHu(mbaoMjUserID, cbOperateCode, cbOperateCard, cbCaiShenCard); return true; } if ((wTargetUser == mbaoMjUserID&&cbTargetAction != WIK_CHI_HU&&m_cbUserAction[wChairID] & WIK_CHI_HU) || (cbTargetAction == WIK_ZAHU)) { HandleBaoMjZaHu(mbaoMjUserID, cbOperateCode, cbOperateCard, cbCaiShenCard); return true; } } //执行动作的优先级判断, WIK_CHI_HU 大于 WIK_PENG 大于 [WIK_RIGHT or WIK_CENTER or WIK_LEFT] WORD TempUser = m_wProvideUser; OperatorPriority(TempUser, wTargetUser, cbTargetAction); if (m_bResponse[wTargetUser] == false)//操作判断 { if (cbOperateCode == WIK_NULL) m_cbLastDisCardData[wChairID][m_cbLastDisCount[wChairID]++] = m_cbProvideCard; return true; } //放弃操作 if (m_bQiangGang&&cbOperateCard == 0)//此处if 主要用于解决,用户抢杠胡那一刻,断线重连。客户端不知道用户抢的那张牌。所以必须后台强制处理一下。 { m_cbOperateCard[wTargetUser] = m_cbProvideCard; } else { m_bQiangGang = false; } if (cbOperateCode == WIK_NULL &&cbTargetAction == WIK_NULL) { //用户状态 ZeroMemory(m_bResponse, sizeof(m_bResponse)); ZeroMemory(m_cbUserAction, sizeof(m_cbUserAction)); ZeroMemory(m_cbOperateCard, sizeof(m_cbOperateCard)); ZeroMemory(m_cbPerformAction, sizeof(m_cbPerformAction)); //当该用户点过时 加入该张牌 //if(wTargetUser==wChairID) //{ m_cbLastDisCardData[wTargetUser][m_cbLastDisCount[wTargetUser]++] = m_cbProvideCard; //} if (m_wCurrentUser == INVALID_CHAIR) DispatchCardData(m_wResumeUser); return true; } //变量定义 BYTE cbTargetCard = m_cbOperateCard[wTargetUser]; BYTE cbTargetCaiCard[4] = { 0 }; CopyMemory(cbTargetCaiCard, m_cbOperateCaiCard[wTargetUser], sizeof(cbTargetCaiCard)); if (cbTargetCard != m_cbProvideCard)//校验很重要 { m_bResponse[wTargetUser] = false; ASSERT(false); return false; } //出牌变量 m_cbOutCardData = 0; //m_bSendStatus = true; m_wOutCardUser = INVALID_CHAIR; //m_bEnjoinChiHu[wTargetUser] = true; //用户状态 ZeroMemory(m_bResponse, sizeof(m_bResponse)); ZeroMemory(m_cbUserAction, sizeof(m_cbUserAction)); ZeroMemory(m_cbOperateCard, sizeof(m_cbOperateCard)); ZeroMemory(m_cbPerformAction, sizeof(m_cbPerformAction)); //组合扑克 if (cbTargetAction&(WIK_LEFT | WIK_CENTER | WIK_RIGHT | WIK_PENG | WIK_MING_GANG)) { ASSERT(m_cbWeaveItemCount[wTargetUser] < 4); if (m_cbWeaveItemCount[wTargetUser] > 4)return false; WORD wIndex = m_cbWeaveItemCount[wTargetUser]++; m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard = TRUE; m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard = cbTargetCard; m_WeaveItemArray[wTargetUser][wIndex].cbWeaveKind = cbTargetAction; m_WeaveItemArray[wTargetUser][wIndex].wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; /*if (cbTargetAction& WIK_PENG) { //当任意一个玩家碰了之后,清理最后一张牌记录 //下一个牌 所有人 都可以碰 所以清零 ZeroMemory(m_cbLastDisCardData, sizeof(m_cbLastDisCardData)); ZeroMemory(m_cbLastDisCount, sizeof(m_cbLastDisCount)); }*/ } if (cbTargetAction &WIK_ZI_MO)//此动作为抢杠胡才会促发 { m_bQiangGang = true; ZeroMemory(m_bUsersGangStatus, GAME_PLAYER); m_wCurrentUser = wTargetUser; //m_wProvideUser = wTargetUser; m_cbSendCardData = m_cbProvideCard; m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++; m_cbUserAction[wTargetUser] = WIK_ZI_MO; OnUserOperateCard(wTargetUser, WIK_ZI_MO, m_cbProvideCard, NULL); return true; } if (cbTargetAction &(WIK_DI_CHIHU | WIK_CHI_HU)) { //用户状态 BYTE TempCardData = m_cbProvideCard; int TempAction = 0; CChiHuRight chr; BYTE TaiShu = 0; TempAction |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[wTargetUser], m_WeaveItemArray[wTargetUser], m_cbWeaveItemCount[wTargetUser], m_cbProvideCard, chr, TaiShu); if (TempAction == WIK_NULL) { ASSERT(false); return false; } m_HuPai[wTargetUser]++; CMD_S_OperateResult OperateResult; OperateResult.wOperateUser = wTargetUser; OperateResult.cbOperateCard = cbTargetCard; OperateResult.cbOperateCode = cbTargetAction; OperateResult.wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; WORD paitype = bHuPaiType(chr); if (cbTargetAction == WIK_DI_CHIHU){ paitype = ZJ_TAI_DiHu; TaiShu = 7; } OperateResult.cbActionMask = TaiShu | (paitype << 16); ZeroMemory(OperateResult.cbActionCard, sizeof(OperateResult.cbActionCard)); SparrowMaJiang::PB_CS_S_OperateResult Result; Result.set_woperateuser(OperateResult.wOperateUser); Result.set_cboperatecard(OperateResult.cbOperateCard); Result.set_cboperatecode(OperateResult.cbOperateCode); Result.set_wprovideuser(OperateResult.wProvideUser); for (BYTE j = 0; j < 4; j++) { Result.add_cbcaishencard(OperateResult.cbCaiShenCard[j]); } Result.set_cbactionmask(OperateResult.cbActionMask); for (BYTE j = 0; j < 6; j++) { Result.add_cbactioncard(OperateResult.cbActionCard[j]); } //发送数据 std::string pbdata = Result.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //发送消息 m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //积分变动 CMD_S_GangScore gs; ZeroMemory(&gs, sizeof(gs)); gs.cbOperateCode = cbTargetAction; gs.wChairId = wTargetUser; int TempInfoScore = 0; WORD LaoZhuang = m_wBankerUser & 0x00ff; if (LianXuHuPai[LaoZhuang] >= 2) { TaiShu = TaiShu + 1; }//老庄台数加1 if (cbTargetAction&WIK_DI_CHIHU) { CaculationScore(wTargetUser, TaiShu, win_DiHu, m_wProvideUser, chr, gs); } else { CaculationScore(wTargetUser, TaiShu, Win_FangPao, m_wProvideUser, chr, gs); } LianXuHuPai[wTargetUser]++; SparrowMaJiang::PB_CS_S_GangScore GangScore; GangScore.set_cboperatecode(gs.cbOperateCode); for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); GangScore.add_lgangscore(gs.lGangScore[j]); } GangScore.set_wchairid(gs.wChairId); std::string pbscore = GangScore.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } gs.cbWanJiaScore[i] = m_lGameScore[i]; } for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.set_cbwanjiascore(j, gs.cbWanJiaScore[j]); } std::string pbrecord = GangScore.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbrecord.c_str(), pbrecord.length()); OnEventGameConclude(wTargetUser, NULL, GER_NORMAL); return true; } DeleteCaiShenCard(wTargetUser, cbTargetCaiCard, cbTargetAction, cbTargetCard); //杠牌处理 if (cbTargetAction & (WIK_MING_GANG | WIK_DAN_MING_GANG | WIK_SHUANG_MING_GANG | WIK_SAN_MING_GANG)) { int cbActionMask = WIK_NULL; WORD cbActionCard[6] = { 0 }; HttpOperateResult(wTargetUser, cbTargetCaiCard, cbTargetAction, cbTargetCard, cbActionMask, cbActionCard); //设置用户 m_wCurrentUser = wTargetUser; m_bGangOption = cbTargetAction; m_GangPrivedUserID = m_wProvideUser; DispatchCardData(wTargetUser, true); return true; } else { WORD cbActionCard[6] = { 0 }; int cbActionMask = NULL; /*if (m_cbLeftCardCount > 6) { tagGangCardResult GangCardResult; cbActionMask = m_GameLogic.AnalyseGangCard(m_cbCardIndex[wTargetUser], m_WeaveItemArray[wTargetUser], m_cbWeaveItemCount[wTargetUser], GangCardResult); m_cbUserAction[wTargetUser] |= cbActionMask; for (BYTE i = 0; i < GangCardResult.cbCardCount; i++) { cbActionCard[i] = GangCardResult.cbCardData[i]; } }*/ // m_TabbOutCardCout[wTargetUser] = 0; //可以打出的牌就听牌的个数 // ZeroMemory(m_TabbOutCardData[wTargetUser], sizeof(m_TabbOutCardData[wTargetUser])); //具体打哪几张牌 // ZeroMemory(m_TabbTingCardCount[wTargetUser], sizeof(m_TabbTingCardCount[wTargetUser])); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 // ZeroMemory(m_TabbTingCardData[wTargetUser], sizeof(m_TabbTingCardData[wTargetUser])); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 TingCard(wTargetUser); HttpOperateResult(wTargetUser, cbTargetCaiCard, cbTargetAction, cbTargetCard, cbActionMask, cbActionCard); //设置用户 m_wCurrentUser = wTargetUser; if (m_TabbOutCardCout[wTargetUser] > 0)//有听牌就发一个听牌协议 { HttpTingCard(wTargetUser); } return true; } ASSERT(false); return false; } //主动动作 if (m_wCurrentUser == wChairID) //如果是摸牌用户的操作,比如自摸或者自杠 { if (cbOperateCode == WIK_NULL) { if (mMjType == 1 && wChairID == mbaoMjUserID&&cbOperateCode!= WIK_ZI_MO&&m_cbUserAction[wChairID] & (WIK_TIAN_ZI_MO | WIK_ZI_MO)) { HandleBaoMjZaHu(wChairID, cbOperateCode, cbOperateCard, cbCaiShenCard); return true; } //用户状态 ZeroMemory(m_bResponse, sizeof(m_bResponse)); ZeroMemory(m_cbUserAction, sizeof(m_cbUserAction)); ZeroMemory(m_cbOperateCard, sizeof(m_cbOperateCard)); ZeroMemory(m_cbPerformAction, sizeof(m_cbPerformAction)); //发送扑克 return true; } //效验操作 if ((cbOperateCode == WIK_NULL) || ((m_cbUserAction[wChairID] & cbOperateCode) == 0)) return true; //设置变量 //m_bSendStatus = true; //m_bEnjoinChiHu[m_wCurrentUser]=true; m_cbUserAction[m_wCurrentUser] = WIK_NULL; m_cbPerformAction[m_wCurrentUser] = WIK_NULL; bool bPublic = false; //执行动作 if (cbOperateCode & (WIK_TIAN_ZI_MO | WIK_ZI_MO)) { BYTE TempCardData = m_cbProvideCard; if (m_cbProvideCard != m_cbSendCardData || m_cbProvideCard != cbOperateCard) { ASSERT(false); return false; } int TempAction = 0; CChiHuRight chr; BYTE TaiShu = 0; m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]--; TempAction |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[wChairID], m_WeaveItemArray[wChairID], m_cbWeaveItemCount[wChairID], m_cbSendCardData, chr, TaiShu, m_bUsersGangStatus[wChairID], m_bQiangGang); m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++; if (TempAction == WIK_NULL) { ASSERT(false); return false; } m_HuPai[wChairID]++; CMD_S_OperateResult OperateResult; OperateResult.wOperateUser = wChairID; OperateResult.cbOperateCard = cbOperateCard; OperateResult.cbOperateCode = cbOperateCode; OperateResult.wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wChairID : m_wProvideUser; WORD paitype = bHuPaiType(chr); if (m_bUsersGangStatus[wChairID] == true) { paitype |= ZJ_TAI_GangKai; //TaiShu++; } if (m_bQiangGang == true) { paitype |= ZJ_TAI_QiangGang; OperateResult.cbOperateCode = WIK_CHI_HU; } if (WIK_TIAN_ZI_MO == cbOperateCode)//天胡台数直接到最大 { paitype = ZJ_TAI_TianHu; TaiShu = 7; } OperateResult.cbActionMask = TaiShu | (paitype << 16);//异或 然后右移 ZeroMemory(OperateResult.cbActionCard, sizeof(OperateResult.cbActionCard)); SparrowMaJiang::PB_CS_S_OperateResult Result; Result.set_woperateuser(OperateResult.wOperateUser); Result.set_cboperatecard(OperateResult.cbOperateCard); Result.set_cboperatecode(OperateResult.cbOperateCode); Result.set_wprovideuser(OperateResult.wProvideUser); for (BYTE j = 0; j < 4; j++) { Result.add_cbcaishencard(OperateResult.cbCaiShenCard[j]); } Result.set_cbactionmask(OperateResult.cbActionMask); for (BYTE j = 0; j < 6; j++) { Result.add_cbactioncard(OperateResult.cbActionCard[j]); } //发送数据 std::string pbdata = Result.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //发送消息 m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //积分变动 CMD_S_GangScore gs; ZeroMemory(&gs, sizeof(gs)); gs.wChairId = wChairID; gs.cbOperateCode = WIK_ZI_MO; if (m_bQiangGang == true){ gs.cbOperateCode = WIK_CHI_HU; } else { gs.cbOperateCode = WIK_ZI_MO; } int TempInfoScore = 0; WORD LaoZhuang = m_wBankerUser & 0x00ff; if (LianXuHuPai[LaoZhuang] >= 2) { TaiShu++; //TaiShu = TaiShu > (mMaxTaiNum - 1) ? mMaxTaiNum : ++TaiShu;//老庄台数加1 } /* if (TaiShu>FengDingTaiNum) { TaiShu = FengDingTaiNum; }*/ // [9/11/2017 Zoro] 经与苗苗确认,取消新加需求。所有杠开 都算自摸。 /* if (mMjType==1&&m_bGangStatus==true) { if (m_GangPrivedUserID!=wChairID&&m_GangPrivedUserID!=-1&&wChairID==mbaoMjUserID) { CaculationScore(wChairID, TaiShu, Win_FangPao, m_GangPrivedUserID, chr, gs); } else { CaculationScore(wChairID, TaiShu, Win_ZiMo, m_wProvideUser, chr, gs); } } else {*/ CaculationScore(wChairID, TaiShu, Win_ZiMo, m_wProvideUser, chr, gs); //} LianXuHuPai[wChairID]++; SparrowMaJiang::PB_CS_S_GangScore GangScore; GangScore.set_cboperatecode(gs.cbOperateCode); for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); GangScore.add_lgangscore(gs.lGangScore[j]); } GangScore.set_wchairid(gs.wChairId); std::string pbscore = GangScore.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } gs.cbWanJiaScore[i] = m_lGameScore[i]; } for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); } std::string pbrecord = GangScore.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbrecord.c_str(), pbrecord.length()); OnEventGameConclude(wChairID, NULL, GER_NORMAL); return true; } if (cbOperateCode & (WIK_DAN_BU_GANG | WIK_BU_GANG)) { DeleteCard(wChairID, cbCaiShenCard, cbOperateCode, cbOperateCard); int cbActionMask = WIK_NULL; WORD cbActionCard[6] = { 0 }; HttpOperateResult(wChairID, cbCaiShenCard, cbOperateCode, cbOperateCard, cbActionMask, cbActionCard); //响应判断 m_wProvideUser = wChairID; m_bQiangGang = true; m_bUsersGangStatus[wChairID] = true; bool bAroseAction = EstimateUserRespond(wChairID, cbOperateCard, EstimatKind_GangCard);//补杠,别人可以抢杠胡 // 此处包含bug,如果抢杠的用户选择了过。此时该杠上开花的用户则无法胡杠上开话,会少一台。此bug需要修复 [11/28/2017 Zoro] //派发扑克 if (bAroseAction == false) { m_bQiangGang = false; m_bGangOption = cbOperateCode; m_GangPrivedUserID = m_wCurrentUser; DispatchCardData(m_wCurrentUser,true); } else { // m_bGangStatus = false; m_bQiangGang = true; } return true; } DeleteCard(wChairID, cbCaiShenCard, cbOperateCode, cbOperateCard); int cbActionMask = WIK_NULL; WORD cbActionCard[6] = { 0 }; HttpOperateResult(wChairID, cbCaiShenCard, cbOperateCode, cbOperateCard, cbActionMask, cbActionCard); DispatchCardData(wChairID, true); return true; } return true; } //发送操作 bool CTableFrameSink::SendOperateNotify() { //发送提示 for (WORD i=0;iSendTableData(i, SUB_S_OPERATE_NOTIFY, (void*)pbdata.c_str(), pbdata.length()); ////-沙 前端需要展示提示数据 OperateNotify.wResumeUser = i; Notify.set_wresumeuser(OperateNotify.wResumeUser); std::string pbrecord = Notify.SerializePartialAsString(); RepayRecord(i, SUB_S_OPERATE_NOTIFY, (void*)pbrecord.c_str(), pbrecord.length()); } } //m_pITableFrame->SendLookonData(i, SUB_S_OPERATE_NOTIFY, &OperateNotify, sizeof(OperateNotify)); return true; } //派发扑克,wCurrentUser表示给哪个用户,bTail表示是末尾拿牌还是不是,true表示末尾,同时标示杠牌抓牌 bool CTableFrameSink::DispatchCardData(WORD wCurrentUser, bool bTail) { //状态效验 ASSERT(wCurrentUser != INVALID_CHAIR); if (wCurrentUser == INVALID_CHAIR) return false; if (wCurrentUser==TowMjNullseat&&m_bTwoPlayerFlag) { 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; } //荒庄结束 if (m_cbLeftCardCount == 0) { //m_cbChiHuCard = 0; m_wProvideUser = INVALID_CHAIR; bIsHuang = true; //包麻将 if (mMjType==1) { //包麻将 黄装 计算分数 WORD BankUserID = m_wBankerUser & 0x00ff; int FanBei = 1; if (LianXuHuPai[BankUserID] >= 2) { FanBei++; } CMD_S_GangScore gs; ZeroMemory(&gs, sizeof(gs)); gs.wChairId = 0; gs.cbOperateCode = WIK_NULL; int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } //积分 for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == mbaoMjUserID) { continue; } gs.lGangScore[i] += nTmpOneUserScore; m_lGameScore[i] += gs.lGangScore[i]; m_lGameTatolScore[i] += gs.lGangScore[i]; gs.cbWanJiaScore[i] = m_lGameTatolScore[i]; } if (m_bTwoPlayerFlag) { gs.lGangScore[mbaoMjUserID] -= nTmpOneUserScore * (mPlayGameUserCount - 2); } else { gs.lGangScore[mbaoMjUserID] -= nTmpOneUserScore * (mPlayGameUserCount - 1); } m_lGameScore[mbaoMjUserID] += gs.lGangScore[mbaoMjUserID]; m_lGameTatolScore[mbaoMjUserID] += gs.lGangScore[mbaoMjUserID]; gs.cbWanJiaScore[mbaoMjUserID] = m_lGameTatolScore[mbaoMjUserID]; SparrowMaJiang::PB_CS_S_GangScore GangScore; GangScore.set_cboperatecode(gs.cbOperateCode); for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); GangScore.add_lgangscore(gs.lGangScore[j]); } GangScore.set_wchairid(gs.wChairId); std::string pbscore = GangScore.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); } OnEventGameConclude(m_wProvideUser, NULL, GER_NORMAL); return true; } //设置变量 m_cbOutCardData = 0; m_wCurrentUser = wCurrentUser; //记录拿牌人的索引。 m_wOutCardUser = INVALID_CHAIR; //置空上次出牌用户的索引 BYTE ActionCard[3] = { 0 }; //操作牌值 BYTE AnActionCount = 0; //发送扑克 m_cbSendCardCount++; --m_cbLeftCardCount;//剩余牌减少 m_cbSendCardData = m_cbRepertoryCard[--m_cbShiJiLeftCardCount];//实际剩余牌减少 CChiHuRight chr; BYTE TaiShu = 0; // m_bGangStatus = bTail; m_bUsersGangStatus[wCurrentUser] = bTail; if (mMjType==1&&mbaoMjUserID == wCurrentUser) { // m_cbUserAction[wCurrentUser] |= int nTmpAction=m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[wCurrentUser], m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, chr, TaiShu, bTail); if (TaiShu>=mBaoTaiNum[wCurrentUser]) { m_cbUserAction[wCurrentUser] |= nTmpAction; } else { m_cbUserAction[wCurrentUser] |= WIK_NULL; } } else { m_cbUserAction[wCurrentUser] |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[wCurrentUser], m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], m_cbSendCardData, chr, TaiShu, bTail); } //加牌 m_cbCardIndex[wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbSendCardData)]++; //设置变量 m_wProvideUser = wCurrentUser; m_cbProvideCard = m_cbSendCardData; //杠牌判断 tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult, sizeof(GangCardResult)); if (m_cbLeftCardCount > 0) { bool bCanAnGang = true;//此true表示自己抓牌,false表示表人打得去检验杠, m_cbUserAction[wCurrentUser] |= m_GameLogic.AnalyseGangCard(m_cbCardIndex[wCurrentUser], m_WeaveItemArray[wCurrentUser], m_cbWeaveItemCount[wCurrentUser], GangCardResult); } //听牌计算 // m_TabbOutCardCout[wCurrentUser] = 0; //可以打出的牌就听牌的个数 // ZeroMemory(m_TabbOutCardData[wCurrentUser], sizeof(m_TabbOutCardData[wCurrentUser])); //具体打哪几张牌 // ZeroMemory(m_TabbTingCardCount[wCurrentUser], sizeof(m_TabbTingCardCount[wCurrentUser])); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 // ZeroMemory(m_TabbTingCardData[wCurrentUser], sizeof(m_TabbTingCardData[wCurrentUser])); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 if (!(m_cbUserAction[wCurrentUser] & WIK_ZI_MO)) TingCard(m_wCurrentUser); //构造数据 CMD_S_SendCard SendCard; ZeroMemory(&SendCard, sizeof(SendCard)); SendCard.wCurrentUser = wCurrentUser; SendCard.bTail = bTail; SendCard.bLeftCardCount = m_cbLeftCardCount; SendCard.cbActionMask = m_cbUserAction[wCurrentUser]; SendCard.cbCardData = m_cbSendCardData; SparrowMaJiang::PB_CS_S_SendCard Card; Card.set_wcurrentuser(SendCard.wCurrentUser); Card.set_btail(SendCard.bTail); Card.set_bleftcardcount(SendCard.bLeftCardCount); Card.set_cbactionmask(SendCard.cbActionMask); Card.set_cbcarddata(SendCard.cbCardData); std::string pbrecord = Card.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_SEND_CARD, (void*)pbrecord.c_str(), pbrecord.length()); //发送数据 for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == m_wCurrentUser) {//发送给摸牌玩家的数据,附带麻将牌面数据 for (BYTE j = 0; j < GangCardResult.cbCardCount; j++)//先暗杠后补杠牌数据 SendCard.cbActionCard[j] = GangCardResult.cbCardData[j]; SendCard.cbCardData = m_cbSendCardData; SendCard.cbActionMask = m_cbUserAction[wCurrentUser]; for (BYTE j = 0; j < GangCardResult.cbCardCount; j++) { Card.add_cbactioncard(SendCard.cbActionCard[j]); } Card.set_cbactionmask(SendCard.cbActionMask); Card.set_cbcarddata(SendCard.cbCardData); std::string pbdata = Card.SerializePartialAsString(); m_pITableFrame->SendTableData(i, SUB_S_SEND_CARD, (void*)pbdata.c_str(), pbdata.length()); } else {//发送给其他玩家的数据,没有麻将牌面数据(防止客户端作弊) ZeroMemory(SendCard.cbActionCard, sizeof(SendCard.cbActionCard)); SendCard.cbCardData = 0x00; SendCard.cbActionMask = 0x0000; for (BYTE j = 0; j < GangCardResult.cbCardCount; j++) { Card.add_cbactioncard(SendCard.cbActionCard[j]); } Card.set_cbactionmask(SendCard.cbActionMask); Card.set_cbcarddata(SendCard.cbCardData); std::string pbdata = Card.SerializePartialAsString(); m_pITableFrame->SendTableData(i, SUB_S_SEND_CARD, (void*)pbdata.c_str(), pbdata.length()); } } SendCard.cbActionMask = 0; SendCard.cbCardData = 0; Card.set_cbactionmask(SendCard.cbActionMask); Card.set_cbcarddata(SendCard.cbCardData); std::string pbdata = Card.SerializePartialAsString(); //给旁观者的抓牌动作 m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_SEND_CARD, (void*)pbdata.c_str(), pbdata.length()); if (m_TabbOutCardCout[m_wCurrentUser] > 0)//有听牌就发一个听牌协议 { HttpTingCard(m_wCurrentUser); } return true; } //响应判断 bool CTableFrameSink::EstimateUserRespond(WORD wCenterUser, BYTE cbCenterCard, enEstimatKind EstimatKind) { //财神牌不判断 if (m_GameLogic.IsMagicCard(cbCenterCard))return false; //变量定义 bool bAroseAction[GAME_PLAYER] = { false }; bool mbAroseAction = false; //吃牌判断,出牌玩家下家位置 WORD wEatUser = (wCenterUser + 1) % mPlayGameUserCount; if (m_bTwoPlayerFlag&&wEatUser==TowMjNullseat) { wEatUser++; } //用户状态 ZeroMemory(m_bResponse, sizeof(m_bResponse)); ZeroMemory(m_cbUserAction, sizeof(m_cbUserAction)); ZeroMemory(m_cbPerformAction, sizeof(m_cbPerformAction)); //动作判断 for (WORD nUserIndex = 0; nUserIndex < mPlayGameUserCount; nUserIndex++) { if (m_bTwoPlayerFlag&&nUserIndex == TowMjNullseat) { continue; } //用户过滤 if (wCenterUser == nUserIndex) continue; //出牌类型 if (EstimatKind == EstimatKind_OutCard) { CChiHuRight Chr; BYTE TaiShu = 0; int wAction = 0; if (mMjType==1&&nUserIndex==mbaoMjUserID) { int TmpAction=m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[nUserIndex], m_WeaveItemArray[nUserIndex], m_cbWeaveItemCount[nUserIndex], cbCenterCard, Chr, TaiShu); if (TaiShu>=mBaoTaiNum[mbaoMjUserID]) { wAction = TmpAction; } } else { wAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[nUserIndex], m_WeaveItemArray[nUserIndex], m_cbWeaveItemCount[nUserIndex], cbCenterCard, Chr, TaiShu); // 财吊 [9/6/2017 Zoro] //if (wAction!=WIK_NULL) //{ // //翻财神 // if (m_GameLogic.IsCanHuAllCards(m_cbCardIndex[nUserIndex], m_WeaveItemArray[nUserIndex], m_cbWeaveItemCount[nUserIndex])) // { // wAction = WIK_NULL; // } //} } if (wAction != WIK_NULL) { m_cbUserAction[nUserIndex] = WIK_CHI_HU; if (m_cbOutCardCount == 1 &&(m_wBankerUser&0xff)!=nUserIndex&&mMjType==0) { m_cbUserAction[nUserIndex] = WIK_DI_CHIHU; } } //确定只有下家才能吃牌 if (wEatUser == nUserIndex) { m_cbUserAction[nUserIndex] |= m_GameLogic.EstimateEatCard(m_cbCardIndex[nUserIndex], cbCenterCard); } //碰牌判断 m_cbUserAction[nUserIndex] |= m_GameLogic.EstimatePengCard(m_cbCardIndex[nUserIndex], cbCenterCard); /*if (m_cbUserAction[nUserIndex]& WIK_PENG || m_cbUserAction[nUserIndex] & WIK_DAN_PENG|| m_cbUserAction[nUserIndex] & WIK_PENG ) { if (m_cbLastDisCardData[nUserIndex][m_cbLastDisCount[nUserIndex]]> 0) { m_cbLastDisCardData[nUserIndex][m_cbLastDisCount[nUserIndex]--]--; } }*/ //杠牌判断 if (m_cbLeftCardCount > 0) { m_cbUserAction[nUserIndex] |= m_GameLogic.EstimateGangCard(m_cbCardIndex[nUserIndex], cbCenterCard); } } if (EstimatKind == EstimatKind_GangCard) { CChiHuRight Chr; BYTE TaiShu = 0; int wAction = 0; int GangStatus = m_bUsersGangStatus[wCenterUser]; if (mMjType == 1 && nUserIndex == mbaoMjUserID) { int TmpAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[nUserIndex], m_WeaveItemArray[nUserIndex], m_cbWeaveItemCount[nUserIndex], cbCenterCard, Chr, TaiShu, false, GangStatus); if (TaiShu >= mBaoTaiNum[mbaoMjUserID]) { wAction = TmpAction; } } else { wAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[nUserIndex], m_WeaveItemArray[nUserIndex], m_cbWeaveItemCount[nUserIndex], cbCenterCard, Chr, TaiShu, false, GangStatus); // 财吊 [9/6/2017 Zoro] //if (wAction != WIK_NULL) //{ // //翻财神 // if (m_GameLogic.IsCanHuAllCards(m_cbCardIndex[nUserIndex], m_WeaveItemArray[nUserIndex], m_cbWeaveItemCount[nUserIndex])) // { // wAction = WIK_NULL; // } //} // } if (wAction&WIK_ZI_MO) { m_cbUserAction[nUserIndex] |= WIK_ZI_MO; } } //结果判断 if (m_cbUserAction[nUserIndex] != WIK_NULL) { bAroseAction[nUserIndex] = true; if (m_cbUserAction[nUserIndex] & (WIK_PENG | WIK_CHI_HU | WIK_PENG_PENG)) { BYTE bTemp = 0; //记忆牌有多少张 for (BYTE j = 0; j < m_cbLastDisCount[nUserIndex]; j++) { //如果在一圈中 记忆1个一样的牌 则不能操作 if (m_cbLastDisCardData[nUserIndex][j] == cbCenterCard) { m_cbUserAction[nUserIndex] = m_cbUserAction[nUserIndex] & (~(WIK_PENG | WIK_CHI_HU | WIK_PENG_PENG)); if (m_cbUserAction[nUserIndex] == WIK_NULL) bAroseAction[nUserIndex] = false; } } } } } for (int nUserIndex = 0; nUserIndex < mPlayGameUserCount; nUserIndex++) { if (m_bTwoPlayerFlag&&nUserIndex == TowMjNullseat) { continue; } if (bAroseAction[nUserIndex] == true) { mbAroseAction = true; break; } } //结果处理 if (mbAroseAction == true) { //设置变量 m_wProvideUser=wCenterUser; m_cbProvideCard=cbCenterCard; m_wResumeUser=m_wCurrentUser; m_wCurrentUser=INVALID_CHAIR; //发送提示 SendOperateNotify(); return true; } return false; } //胡的这张牌 牌堆里面还有几张 //计算方式 服务器上剩余里面的牌,+其他三位位玩家手牌= 该胡牌个数 BYTE CTableFrameSink::RemainNum(WORD wChairId, const BYTE m_cbCard, BYTE cbOutCardIndex) { BYTE m_cbNum = 0; BYTE mCard[MAX_INDEX] = { 0 }; //把所有当前用户可以看到的牌 都扔到这个数组中 BYTE TempIndex = m_GameLogic.SwitchToCardIndex(m_cbCard); for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } for (BYTE j = 0; j < m_cbDiscardCount[i]; j++)//丢弃数 { mCard[m_GameLogic.SwitchToCardIndex(m_cbDiscardCard[i][j])]++; } for (BYTE k = 0; k < m_cbWeaveItemCount[i]; k++)//摆出来的牌 { if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_PENG) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] += 3; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_LEFT) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard + 1)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard + 2)]++; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_RIGHT) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard - 1)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard - 2)]++; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_CENTER) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard - 1)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard + 1)]++; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_MING_GANG || (i == wChairId&&m_WeaveItemArray[i][k].cbWeaveKind == WIK_AN_GANG)) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] += 4; } if (m_WeaveItemArray[i][k].cbWeaveKind& (WIK_SHUANG_CAICHI | WIK_SHUANG_PENG | WIK_DAN_CHI)) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[0])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[1])]++; } if (m_WeaveItemArray[i][k].cbWeaveKind== WIK_DAN_PENG) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] += 2; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[0])]++; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_DAN_MING_GANG || (i == wChairId && m_WeaveItemArray[i][k].cbWeaveKind == WIK_DAN_AN_GANG)) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] += 3; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[0])]++; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_SHUANG_MING_GANG || (i == wChairId && m_WeaveItemArray[i][k].cbWeaveKind == WIK_SHUANG_AN_GANG)) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] += 2; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[0])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[1])]++; } if (m_WeaveItemArray[i][k].cbWeaveKind == WIK_SAN_MING_GANG || (i == wChairId && m_WeaveItemArray[i][k].cbWeaveKind == WIK_SAN_AN_GANG)) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] += 1; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[0])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[1])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[2])]++; } if (i==wChairId && m_WeaveItemArray[i][k].cbWeaveKind == WIK_QUANG_AN_GANG) { mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[0])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[1])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[2])]++; mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[3])]++; } if (m_WeaveItemArray[i][k].cbWeaveKind & (WIK_BU_GANG|WIK_DAN_BU_GANG)) { for (int m = 0; m < 4; m++) { if (m_WeaveItemArray[i][k].cbMargicOffset[m] != 0) mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbMargicOffset[m])]++; else mCard[m_GameLogic.SwitchToCardIndex(m_WeaveItemArray[i][k].cbCenterCard)] ++; } } } } //8个财神变7个 在加回来一个 if (mMjType==0) { //非包麻将 需要计算翻财神的那张牌 BYTE cbMagicFirstIndex = m_GameLogic.SwitchToCardIndex(m_cbMagicFirstData); if (mCard[cbMagicFirstIndex] < 4) { mCard[cbMagicFirstIndex]++; } } //非包麻将 不需要把财神那张牌加入落地牌 //增加自己假设去掉的牌 这样才真正的标示 牌桌加手牌 mCard[cbOutCardIndex]++; for (BYTE i = 0; i < MAX_INDEX; i++) { mCard[i] += m_cbCardIndex[wChairId][i]; } m_cbNum = 4 - mCard[TempIndex]; ASSERT(m_cbNum >= 0 && m_cbNum <= 4); if (m_cbNum < 0)m_cbNum = 0; return m_cbNum; } //对手牌遍历,并把该牌减去,然后分析这13张拍能胡什么 bool CTableFrameSink::TingCard(WORD wChairID) { m_PaiQuan[wChairID] = 0; m_TabbOutCardCout[wChairID] = 0; //可以打出的牌就听牌的个数 ZeroMemory(m_TabbOutCardData[wChairID], sizeof(m_TabbOutCardData[wChairID])); //具体打哪几张牌 ZeroMemory(m_TabbTingCardCount[wChairID], sizeof(m_TabbTingCardCount[wChairID])); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 ZeroMemory(m_TabbTingCardData[wChairID], sizeof(m_TabbTingCardData[wChairID])); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 BYTE WilEnumCard[MAX_INDEX] = { 0 }; m_GameLogic.IsCanChangCardAndCount(m_cbCardIndex[wChairID], WilEnumCard); for (BYTE i = 0; i < MAX_INDEX; i++) { if (m_cbCardIndex[wChairID][i] == 0 )continue; if (--m_cbCardIndex[wChairID][i] < 0){ ASSERT(false); return false; } //if (m_GameLogic.IsTingCard(m_cbCardIndex[wChairID], m_WeaveItemArray[wChairID], m_cbWeaveItemCount[wChairID],FanHui)) //{ m_TabbOutCardData[wChairID][m_TabbOutCardCout[wChairID]] = m_GameLogic.SwitchToCardData(i); BYTE m_cbTingPai[MAX_INDEX] = { 0 };//听牌数组,听哪个牌就把哪个牌设置为1 BYTE m_cbTingParCount = 0; //听牌数据 int BaoUserID = 0; int BaoUserTaiNum=0; if (mMjType==1) { BaoUserID = mbaoMjUserID; BaoUserTaiNum = mBaoTaiNum[mbaoMjUserID]; } if (m_GameLogic.AnalyseTingCard(m_cbCardIndex[wChairID], m_WeaveItemArray[wChairID], m_cbWeaveItemCount[wChairID], m_cbTingPai, WilEnumCard, wChairID, BaoUserID, BaoUserTaiNum)) { for (BYTE j = 0; j < MAX_INDEX; j++) { if (m_cbTingPai[j] > 0) { if (m_cbTingParCount == 19) { m_cbTingParCount++; break; } m_TabbTingCardData[wChairID][m_TabbOutCardCout[wChairID]][m_cbTingParCount++] = m_GameLogic.SwitchToCardData(j); //计算所胡的这张牌 还剩余几张 BYTE num = RemainNum(wChairID, m_TabbTingCardData[wChairID][m_TabbOutCardCout[wChairID]][m_cbTingParCount - 1], i); m_TabbTingCardData[wChairID][m_TabbOutCardCout[wChairID]][m_cbTingParCount - 1] = m_GameLogic.GetValue(num, m_cbTingPai[j], m_TabbTingCardData[wChairID][m_TabbOutCardCout[wChairID]][m_cbTingParCount - 1]); } } if (m_cbTingParCount == 20) { m_TabbTingCardCount[wChairID][m_TabbOutCardCout[wChairID]] = 255; ZeroMemory(m_TabbTingCardData[wChairID][m_TabbOutCardCout[wChairID]], m_cbTingParCount); } else m_TabbTingCardCount[wChairID][m_TabbOutCardCout[wChairID]] = m_cbTingParCount; } if (m_cbTingParCount > 0) m_TabbOutCardCout[wChairID]++; else{ m_TabbOutCardData[wChairID][m_TabbOutCardCout[wChairID]] = 0; } //} m_cbCardIndex[wChairID][i]++; } return true; } bool CTableFrameSink::OutTingCard(WORD wChairID, BYTE cardIndex) { m_PaiQuan[wChairID] = 1; m_TabbOutCardCout[wChairID] = 1; //可以打出的牌就听牌的个数,当打出牌已经完成,默认255不存在 ZeroMemory(m_TabbOutCardData[wChairID], sizeof(m_TabbOutCardData[wChairID])); //具体打哪几张牌 ZeroMemory(m_TabbTingCardCount[wChairID], sizeof(m_TabbTingCardCount[wChairID])); //相对应打出牌可听牌个数,索引表示第几张,值是对应对应的听牌个数 ZeroMemory(m_TabbTingCardData[wChairID], sizeof(m_TabbTingCardData[wChairID])); //具体听牌数据,一维索引表示打出牌的第几个,二维索引表示听牌的第几个,值表示牌数据 BYTE m_cbTingPai[MAX_INDEX] = { 0 };//听牌数组,听哪个牌就把哪个牌设置为1 BYTE m_cbTingParCount = 0;//听牌数据 BYTE FanHui[MAX_INDEX] = { 0 }; m_GameLogic.IsCanChangCardAndCount(m_cbCardIndex[wChairID], FanHui); if (m_GameLogic.AnalyseTingCard(m_cbCardIndex[wChairID], m_WeaveItemArray[wChairID], m_cbWeaveItemCount[wChairID], m_cbTingPai, FanHui, wChairID, mbaoMjUserID, mBaoTaiNum[mbaoMjUserID])) { for (BYTE j = 0; j < MAX_INDEX; j++) { if (m_cbTingPai[j] > 0) { if (m_cbTingParCount == 19) { m_cbTingParCount++; break; } m_TabbTingCardData[wChairID][0][m_cbTingParCount++] = m_GameLogic.SwitchToCardData(j); //用户ID BYTE num = RemainNum(wChairID, m_TabbTingCardData[wChairID][0][m_cbTingParCount - 1], cardIndex); m_TabbTingCardData[wChairID][0][m_cbTingParCount - 1] = m_GameLogic.GetValue(num, m_cbTingPai[j], m_TabbTingCardData[wChairID][0][m_cbTingParCount - 1]); } } if (m_cbTingParCount == 20) { m_TabbTingCardCount[wChairID][0] = 255; ZeroMemory(m_TabbTingCardData[wChairID][0], m_cbTingParCount); } else { m_TabbTingCardCount[wChairID][0] = m_cbTingParCount; } return true; } return false; } void CTableFrameSink::HttpTingCard(WORD wChairID) { CMD_S_TingCard strTingCard; ZeroMemory(&strTingCard, sizeof(strTingCard)); strTingCard.bPaiQuan = m_PaiQuan[wChairID]; strTingCard.bOutCardCout = m_TabbOutCardCout[wChairID]; CopyMemory(strTingCard.bOutCardData, m_TabbOutCardData[wChairID], sizeof(m_TabbOutCardData[wChairID])); CopyMemory(strTingCard.bTingCardCount, m_TabbTingCardCount[wChairID], sizeof(m_TabbTingCardCount[wChairID])); CopyMemory(strTingCard.bTingCardData, m_TabbTingCardData[wChairID], sizeof(m_TabbTingCardData[wChairID])); SparrowMaJiang::PB_CS_S_TingCard Card; Card.set_bpaiquan(strTingCard.bPaiQuan); Card.set_boutcardcout(strTingCard.bOutCardCout); for (BYTE j = 0; j < strTingCard.bOutCardCout; j++) { Card.add_boutcarddata(strTingCard.bOutCardData[j]); } for (BYTE j = 0; j < strTingCard.bOutCardCout; j++) { Card.add_btingcardcount(strTingCard.bTingCardCount[j]); } for (BYTE i = 0; i < strTingCard.bOutCardCout; i++) { SparrowMaJiang::pb_bTingCardData *CardData = Card.add_btingcarddata(); for (BYTE j = 0; j < strTingCard.bTingCardCount[i]; j++) { CardData->add_btingcarddatas(strTingCard.bTingCardData[i][j]); } } std::string pbdata = Card.SerializePartialAsString(); m_pITableFrame->SendTableData(wChairID, SUB_S_TING_CARD, (void*)pbdata.c_str(), pbdata.length()); } void CTableFrameSink::HttpOperateResult(WORD wChairID, BYTE cbCaiShenCard[4], int cbOperateCode, BYTE cbOperateCard, int cbActionMask, WORD cbActionCard[6]) { if (cbOperateCode & WIK_GANG_GANG) {//构造结果 CMD_S_OperateResult OperateResult; memset(&OperateResult, 0, sizeof(OperateResult)); OperateResult.wOperateUser = wChairID; OperateResult.wProvideUser = wChairID; OperateResult.cbOperateCode = cbOperateCode; OperateResult.cbOperateCard = cbOperateCard; CopyMemory(OperateResult.cbCaiShenCard, cbCaiShenCard, sizeof(OperateResult.cbCaiShenCard)); OperateResult.cbActionMask = cbActionMask; CopyMemory(OperateResult.cbActionCard, cbActionCard, sizeof(OperateResult.cbActionCard)); SparrowMaJiang::PB_CS_S_OperateResult Result; Result.set_woperateuser(OperateResult.wOperateUser); Result.set_cboperatecard(OperateResult.cbOperateCard); Result.set_cboperatecode(OperateResult.cbOperateCode); Result.set_wprovideuser(OperateResult.wProvideUser); for (BYTE j = 0; j < 4; j++) { Result.add_cbcaishencard(OperateResult.cbCaiShenCard[j]); } Result.set_cbactionmask(OperateResult.cbActionMask); for (BYTE j = 0; j < 5; j++) { Result.add_cbactioncard(OperateResult.cbActionCard[j]); } //发送数据 std::string pbdata = Result.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //发送消息 m_pITableFrame->SendTableData(wChairID, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); ZeroMemory(OperateResult.cbCaiShenCard, sizeof(OperateResult.cbCaiShenCard)); for (BYTE j = 0; j < 4; j++) { Result.add_cbcaishencard(OperateResult.cbCaiShenCard[j]); } for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == wChairID)continue; //发送消息 m_pITableFrame->SendTableData(i, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); } m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); } else { CMD_S_OperateResult OperateResult; memset(&OperateResult, 0, sizeof(OperateResult)); OperateResult.wOperateUser = wChairID; OperateResult.wProvideUser = m_wProvideUser; if (cbOperateCode &(WIK_DAN_BU_GANG | WIK_BU_GANG)) OperateResult.wProvideUser = wChairID; OperateResult.cbOperateCode = cbOperateCode; OperateResult.cbOperateCard = cbOperateCard; CopyMemory(OperateResult.cbCaiShenCard, cbCaiShenCard, sizeof(OperateResult.cbCaiShenCard)); OperateResult.cbActionMask = cbActionMask; CopyMemory(OperateResult.cbActionCard, cbActionCard, sizeof(OperateResult.cbActionCard)); SparrowMaJiang::PB_CS_S_OperateResult Result; Result.set_woperateuser(OperateResult.wOperateUser); Result.set_cboperatecard(OperateResult.cbOperateCard); Result.set_cboperatecode(OperateResult.cbOperateCode); Result.set_wprovideuser(OperateResult.wProvideUser); for (BYTE j = 0; j < 4; j++) { Result.add_cbcaishencard(OperateResult.cbCaiShenCard[j]); } Result.set_cbactionmask(OperateResult.cbActionMask); for (BYTE j = 0; j < 6; j++) { Result.add_cbactioncard(OperateResult.cbActionCard[j]); } //发送数据 std::string pbdata = Result.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //发送消息 m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); } } BYTE CTableFrameSink::GetNextMagicCardData(BYTE cbMagicCardFirstIndex) { BYTE TmpCardData=0; BYTE HuaSe = m_GameLogic.GetCardColor(cbMagicCardFirstIndex); switch (HuaSe) { case 0: case 1: case 2: { if ((cbMagicCardFirstIndex & MASK_VALUE) == 0x09) { TmpCardData = (cbMagicCardFirstIndex & MASK_COLOR) | 0x01; } else { TmpCardData = cbMagicCardFirstIndex + 1; } break; } case 3: { if ((cbMagicCardFirstIndex & MASK_VALUE) == 0x04) { TmpCardData = (cbMagicCardFirstIndex & MASK_COLOR) | 0x01; } else if ((cbMagicCardFirstIndex & MASK_VALUE) == 0x07) { TmpCardData = cbMagicCardFirstIndex - 2; } else { TmpCardData = cbMagicCardFirstIndex + 1; } break; } default: { ASSERT(false); break; } } return TmpCardData; } void CTableFrameSink::FanMagicCaculation(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CChiHuRight chr, CMD_S_GangScore& cmd_Score) { switch (WinWay) { case Win_FangPao:{ if (!(chr&ZJ_TAI_QingYiSe).IsEmpty()&& m_cbWeaveItemCount[WinChairID] >= 3) { WinFangMagic_FangPao_QingYiSe_Score(WinChairID, nTai, WinWay, provideUserID, chr, cmd_Score); } else { WinFanMagic_FangPao_Score(WinChairID, nTai, WinWay, provideUserID, chr, cmd_Score); } break; } case Win_ZiMo:{ WinFanMagic_ZiMo_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); break; } case win_DiHu:{ WinFanMagic_DiHu_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); break; } default: break; } } void CTableFrameSink::BaoMjCalculation(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CMD_S_GangScore& cmd_Score) { switch (WinWay) { case Win_FangPao:{ WinBaoMagic_FangPao_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); break; } case Win_ZiMo:{ WinBaoMagic_ZiMo_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); break; } case win_DiHu:{ WinBaoMagic_DiHu_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); break; } default: break; } } void CTableFrameSink::WinFanMagic_FangPao_Score(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CChiHuRight chr, CMD_S_GangScore& cmd_Score) { int TempInfoScore = 0; int nFengDingNum = m_gameConfig.wDiScore*pow(2, mMaxTaiNum); for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == WinChairID)continue; LianXuHuPai[i] = 0; if (i == m_wProvideUser) { if (m_gameConfig.wDiScore *pow(2, nTai) >= nFengDingNum) { cmd_Score.lGangScore[i] -= nFengDingNum; } else { cmd_Score.lGangScore[i] -= m_gameConfig.wDiScore *pow(2, nTai); } m_lGameScore[i] += cmd_Score.lGangScore[i]; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; } else { if (m_gameConfig.wDiScore *pow(2, nTai) / 2 >= nFengDingNum) { cmd_Score.lGangScore[i] -= nFengDingNum; } else { cmd_Score.lGangScore[i] -= (m_gameConfig.wDiScore*pow(2, nTai) / 2); } m_lGameScore[i] += cmd_Score.lGangScore[i]; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; } TempInfoScore -= cmd_Score.lGangScore[i]; } cmd_Score.lGangScore[WinChairID] = TempInfoScore; m_lGameScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; m_lGameTatolScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; cmd_Score.cbWanJiaScore[WinChairID] = m_lGameTatolScore[WinChairID]; } void CTableFrameSink::WinFangMagic_FangPao_QingYiSe_Score(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CChiHuRight Userchr, CMD_S_GangScore& cmd_Score) { int ProvideUserHaveTwoTai=false; for (int i = 0; i < MAX_INDEX;i++) { CChiHuRight chr; BYTE nTaiShu=0; int TempAction; TempAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[provideUserID], m_WeaveItemArray[provideUserID], m_cbWeaveItemCount[provideUserID], m_GameLogic.SwitchToCardData(i), chr, nTaiShu); if (TempAction!=WIK_NULL&&nTaiShu>2) { ProvideUserHaveTwoTai = true; break; } if (TempAction!=WIK_NULL&&nTaiShu==2) { if (TempAction&ZJ_TAI_WuMagic) { continue; } else { ProvideUserHaveTwoTai = true; break; } } } if (ProvideUserHaveTwoTai) { WinFanMagic_FangPao_Score(WinChairID, nTai, WinWay, provideUserID, Userchr, cmd_Score); } else { //计算4家积分变动 输家 同时包赔3家的 int TempInfoScore = 0; int nFengDingNum = m_gameConfig.wDiScore*pow(2, mMaxTaiNum); //32 for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == WinChairID)continue; LianXuHuPai[i] = 0; if (i == m_wProvideUser) { int nOneUserScore = 0; if (m_gameConfig.wDiScore *pow(2, nTai) >= nFengDingNum) { nOneUserScore -= nFengDingNum; } else { nOneUserScore -= m_gameConfig.wDiScore *pow(2, nTai); } cmd_Score.lGangScore[i] += nOneUserScore; TempInfoScore -= nOneUserScore; } else { int nOneUserScore = 0; if (m_gameConfig.wDiScore *pow(2, nTai) / 2 >= nFengDingNum) { nOneUserScore -= nFengDingNum; } else { nOneUserScore -= (m_gameConfig.wDiScore*pow(2, nTai) / 2); } cmd_Score.lGangScore[provideUserID] += nOneUserScore; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; TempInfoScore -= nOneUserScore; } } m_lGameScore[m_wProvideUser] += cmd_Score.lGangScore[m_wProvideUser]; m_lGameTatolScore[m_wProvideUser] += cmd_Score.lGangScore[m_wProvideUser]; cmd_Score.cbWanJiaScore[m_wProvideUser] = m_lGameTatolScore[m_wProvideUser]; cmd_Score.lGangScore[WinChairID] = TempInfoScore; m_lGameScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; m_lGameTatolScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; cmd_Score.cbWanJiaScore[WinChairID] = m_lGameTatolScore[WinChairID]; } } void CTableFrameSink::WinFanMagic_ZiMo_Score(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CMD_S_GangScore& cmd_Score) { int TempInfoScore = 0; int nFengDingNum = m_gameConfig.wDiScore*pow(2, mMaxTaiNum); for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == WinChairID)continue; LianXuHuPai[i] = 0; if (m_gameConfig.wDiScore *pow(2, nTai) >= nFengDingNum) { cmd_Score.lGangScore[i] -= nFengDingNum; } else { cmd_Score.lGangScore[i] -= m_gameConfig.wDiScore *pow(2, nTai); } m_lGameScore[i] += cmd_Score.lGangScore[i]; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; TempInfoScore -= cmd_Score.lGangScore[i]; } cmd_Score.lGangScore[WinChairID] = TempInfoScore; m_lGameScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; m_lGameTatolScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; cmd_Score.cbWanJiaScore[WinChairID] = m_lGameTatolScore[WinChairID]; } void CTableFrameSink::WinFanMagic_DiHu_Score(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CMD_S_GangScore& cmd_Score) { WinFanMagic_ZiMo_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); } void CTableFrameSink::WinBaoMagic_FangPao_Score(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CMD_S_GangScore& cmd_Score) { WORD BankUserID = m_wBankerUser & 0x00ff; int FanBei = 1; if (LianXuHuPai[BankUserID] >= 2) { FanBei++; } //包家 if (WinChairID == mbaoMjUserID) { int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } int TempInfoScore = 0; for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i==WinChairID) { continue; } LianXuHuPai[i] = 0; } for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i==WinChairID) { //包家计分变动 int nZFBScore = mZFBBianScore[i]; if (m_bTwoPlayerFlag) { cmd_Score.lGangScore[WinChairID] = ((nTmpOneUserScore * (mPlayGameUserCount - 2)) + (nZFBScore)); } else { cmd_Score.lGangScore[WinChairID] = ((nTmpOneUserScore * (mPlayGameUserCount - 1)) + (nZFBScore)); } m_lGameScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; m_lGameTatolScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; cmd_Score.cbWanJiaScore[WinChairID] = m_lGameTatolScore[WinChairID]; } else if (i== provideUserID) { //放炮玩家 计分变动 int nZFBScore = mZFBBianScore[i]; if (m_bTwoPlayerFlag) { cmd_Score.lGangScore[provideUserID] -= ((nTmpOneUserScore * (mPlayGameUserCount - 2)) + abs(nZFBScore)); } else { cmd_Score.lGangScore[provideUserID] -= ((nTmpOneUserScore * (mPlayGameUserCount - 1)) + abs(nZFBScore)); } m_lGameScore[provideUserID] += cmd_Score.lGangScore[provideUserID]; m_lGameTatolScore[provideUserID] += cmd_Score.lGangScore[provideUserID]; cmd_Score.cbWanJiaScore[provideUserID] = m_lGameTatolScore[provideUserID]; } else { //其他玩家计分变动 cmd_Score.lGangScore[i] = mZFBBianScore[i]; m_lGameScore[i] += cmd_Score.lGangScore[i]; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; } } CString strInfo; strInfo.Format(_T("WinBaoMagic_FangPao_Score 包家赢 包家Id=%d,所有玩家计分变动 %d,%d,%d,%d"), WinChairID, cmd_Score.lGangScore[0], cmd_Score.lGangScore[1], cmd_Score.lGangScore[2], cmd_Score.lGangScore[3]); OutputDebugString(strInfo); } else { //其他玩家胡牌 包家付3家的,胡牌玩家直接得到单人积分*3 int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } int TempInfoScore = 0; for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == WinChairID) { continue; } LianXuHuPai[i] = 0; } for (int i=0;i= 2) { FanBei++; } //包家自摸 if (WinChairID == mbaoMjUserID) { int nTmpOneUserScore = 0; if (mMagicType==MagicType_TwoMagic) { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } int TempInfoScore = 0; for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == WinChairID)continue; LianXuHuPai[i] = 0; cmd_Score.lGangScore[i] -= (nTmpOneUserScore+abs(mZFBBianScore[i])); m_lGameScore[i] += cmd_Score.lGangScore[i]; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; TempInfoScore -= cmd_Score.lGangScore[i]; } cmd_Score.lGangScore[WinChairID] = TempInfoScore; m_lGameScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; m_lGameTatolScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; cmd_Score.cbWanJiaScore[WinChairID] = m_lGameTatolScore[WinChairID]; //CString strInfo; //strInfo.Format(_T("WinBaoMagic_ZiMo_Score 包家自摸 包家Id=%d ,所有玩家计分变动 %d %d %d %d;"), // WinChairID, cmd_Score.lGangScore[0], cmd_Score.lGangScore[1], cmd_Score.lGangScore[2], cmd_Score.lGangScore[3]); //OutputDebugString(strInfo); } else { //其他玩家胡牌 包家付3家的,胡牌玩家直接得到单人积分*3 int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } int TempInfoScore = 0; for (BYTE i = 0; i < mPlayGameUserCount; i++)//各个玩家游戏积分变动 { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == WinChairID) { continue; } LianXuHuPai[i] = 0; } for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (WinChairID == i) { int nZFBScore = mZFBBianScore[i]; if (m_bTwoPlayerFlag) { //胡牌玩家积分变动 cmd_Score.lGangScore[WinChairID] = (nTmpOneUserScore * (mPlayGameUserCount - 2) + nZFBScore); } else { //胡牌玩家积分变动 cmd_Score.lGangScore[WinChairID] = (nTmpOneUserScore * (mPlayGameUserCount - 1) + nZFBScore); } m_lGameScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; m_lGameTatolScore[WinChairID] += cmd_Score.lGangScore[WinChairID]; cmd_Score.cbWanJiaScore[WinChairID] = m_lGameTatolScore[WinChairID]; } else if (i == mbaoMjUserID) { //包家积分变动 int nZFBScore = mZFBBianScore[i]; if (m_bTwoPlayerFlag) { cmd_Score.lGangScore[mbaoMjUserID] -= ((nTmpOneUserScore * (mPlayGameUserCount - 2)) + abs(nZFBScore)); } else { cmd_Score.lGangScore[mbaoMjUserID] -= ((nTmpOneUserScore * (mPlayGameUserCount - 1)) + abs(nZFBScore)); } m_lGameScore[mbaoMjUserID] += cmd_Score.lGangScore[mbaoMjUserID]; m_lGameTatolScore[mbaoMjUserID] += cmd_Score.lGangScore[mbaoMjUserID]; cmd_Score.cbWanJiaScore[mbaoMjUserID] = m_lGameTatolScore[mbaoMjUserID]; } else { //其他玩家计分变动 cmd_Score.lGangScore[i] = mZFBBianScore[i]; m_lGameScore[i] += cmd_Score.lGangScore[i]; m_lGameTatolScore[i] += cmd_Score.lGangScore[i]; cmd_Score.cbWanJiaScore[i] = m_lGameTatolScore[i]; } } /*CString strInfo; strInfo.Format(_T("WinBaoMagic_ZiMo_Score 闲家自摸 闲家id=%d 所有玩家计分变动 %d %d %d %d"), WinChairID, cmd_Score.lGangScore[0], cmd_Score.lGangScore[1], cmd_Score.lGangScore[2], cmd_Score.lGangScore[3]);*/ //OutputDebugString(strInfo); } } void CTableFrameSink::WinBaoMagic_DiHu_Score(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CMD_S_GangScore& cmd_Score) { WinBaoMagic_ZiMo_Score(WinChairID, nTai, WinWay, provideUserID, cmd_Score); } void CTableFrameSink::CalcDongZFB(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID) { /* BYTE m_cbWeaveItemCount[GAME_PLAYER]; //组合数目 tagWeaveItem m_WeaveItezmArray[GAME_PLAYER][MAX_WEAVE];//组合扑克 */ //OutputDebugString(_T("计算东中发白分数")); WORD BankUserID = m_wBankerUser & 0x00ff; int FanBei = 1; if (LianXuHuPai[BankUserID] >= 2) { FanBei++; } //包家胡了 if (WinChairID==mbaoMjUserID) { // if (WinWay==Win_ZiMo) { //遍历手牌 是否碰过其他三家的 东中发白。碰过则 增减分数 for (int i = 0; i < m_cbWeaveItemCount[WinChairID];i++) { //东中发白组成落地派 只有 碰和刚 所以不需要计算落地类型 只需要判断center牌值,以及是否是自己提供的就可以 if (m_WeaveItemArray[WinChairID][i].cbCenterCard == 0x31 && m_WeaveItemArray[WinChairID][i].wProvideUser!=WinChairID) { //自身增加分数 int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = 2 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = 2 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } { mZFBBianScore[WinChairID] += nTmpOneUserScore; int nWprovideUserID = m_WeaveItemArray[WinChairID][i].wProvideUser; mZFBBianScore[nWprovideUserID] -= nTmpOneUserScore; CString str; str.Format(_T("CalcDongZFB 包家胡 包家ID=%d 碰/杠闲家=%d 东风 ,包家增加 %d ,闲家减少%d "), WinChairID, m_WeaveItemArray[WinChairID][i].wProvideUser, nTmpOneUserScore, nTmpOneUserScore); OutputDebugString(str); } } //东中发白组成落地派 只有 碰和刚 所以不需要计算落地类型 只需要判断center牌值,以及是否是自己提供的就可以 if ( (m_WeaveItemArray[WinChairID][i].cbCenterCard == 0x35 || m_WeaveItemArray[WinChairID][i].cbCenterCard == 0x36 || m_WeaveItemArray[WinChairID][i].cbCenterCard == 0x37 ) && m_WeaveItemArray[WinChairID][i].wProvideUser != WinChairID) { //自身增加分数 int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = 1 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = 1 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } { mZFBBianScore[WinChairID] += nTmpOneUserScore; int nWprovideUserID = m_WeaveItemArray[WinChairID][i].wProvideUser; mZFBBianScore[nWprovideUserID] -= nTmpOneUserScore; CString str; str.Format(_T("CalcDongZFB 包家胡 包家ID=%d 碰/杠闲家=%d 中发白 ,包家增加 %d ,闲家减少%d "), WinChairID, m_WeaveItemArray[WinChairID][i].wProvideUser, nTmpOneUserScore, nTmpOneUserScore); OutputDebugString(str); } } } } } else { //闲家胡了 //遍历包家落地派,是否有胡牌闲家提供的东中发白 for (int i = 0; i < m_cbWeaveItemCount[mbaoMjUserID]; i++) { //东中发白组成落地派 只有 碰和刚 所以不需要计算落地类型 只需要判断center牌值,以及是否是自己提供的就可以 if (m_WeaveItemArray[mbaoMjUserID][i].cbCenterCard == 0x31 && m_WeaveItemArray[mbaoMjUserID][i].wProvideUser == WinChairID) { //自身增加分数 int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = 2 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = 2 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } { mZFBBianScore[WinChairID] += nTmpOneUserScore; int nWprovideUserID = mbaoMjUserID; mZFBBianScore[nWprovideUserID] -= nTmpOneUserScore; CString str; str.Format(_T("CalcDongZFB 闲家胡 闲家ID=%d 东 ,包家减少 %d; 闲家增加%d;"), WinChairID, nTmpOneUserScore, nTmpOneUserScore); //OutputDebugString(str); } } //东中发白组成落地派 只有 碰和刚 所以不需要计算落地类型 只需要判断center牌值,以及是否是自己提供的就可以 if ( (m_WeaveItemArray[mbaoMjUserID][i].cbCenterCard == 0x35 || m_WeaveItemArray[mbaoMjUserID][i].cbCenterCard == 0x36 || m_WeaveItemArray[mbaoMjUserID][i].cbCenterCard == 0x37 ) && m_WeaveItemArray[mbaoMjUserID][i].wProvideUser == WinChairID) { //自身增加分数 int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = 1 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = 1 * m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } { mZFBBianScore[WinChairID] += nTmpOneUserScore; int nWprovideUserID = mbaoMjUserID; mZFBBianScore[nWprovideUserID] -= nTmpOneUserScore; CString str; str.Format(_T("CalcDongZFB 闲家胡 闲家ID=%d 中发白 ,包家减少 %d; 闲家增加%d;"), WinChairID, nTmpOneUserScore, nTmpOneUserScore); //OutputDebugString(str); } } } } } bool CTableFrameSink::SelectBaoTaiNum(WORD wChairID, BYTE nMagicTai) { CMD_S_BAO_CHOICE baoChoice; ZeroMemory(&baoChoice, sizeof(CMD_S_BAO_CHOICE)); if (mBLastBaoStart==true&&nMagicTai==255) { baoChoice.baochoice = mUserOptBaoTai[wChairID]; baoChoice.m_wChairID = wChairID; } else { baoChoice.baochoice = nMagicTai; baoChoice.m_wChairID = wChairID; mUserOptBaoTai[wChairID] = nMagicTai; if (nMagicTai != 255) { mMaxBaoNum = (BaoEnum)nMagicTai; mbaoMjUserID = wChairID; mBaoTaiNum[wChairID] = (nMagicTai / 3) + 2; } else{ mBaoTaiNum[wChairID] = 0; } } SparrowMaJiang::PB_CS_S_BAO_CHOICE pbaoChoice; pbaoChoice.set_baochoice(baoChoice.baochoice); pbaoChoice.set_m_wchairid(baoChoice.m_wChairID); std::string pbbao = pbaoChoice.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_BAO_CHOICE, (void*)pbbao.c_str(), pbbao.length()); CString strTmp; strTmp.Format(_T("广播 用户包台完毕 121 SUB_S_BAO_CHOICE 包台玩家=%d 台数=%d\r\n"), baoChoice.m_wChairID, baoChoice.baochoice); OutputDebugString(strTmp); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_BAO_CHOICE, (void*)pbbao.c_str(), pbbao.length()); RepayRecord(INVALID_CHAIR, SUB_S_BAO_CHOICE, (void*)pbbao.c_str(), pbbao.length()); if (!IsCanReturnResult()) { //找到下一家 广播 //通知下一家 继续包 CMD_S_BAO_NOTICE NotifyBao; NotifyBao.m_wChairID = FindNextBaoJiaID(wChairID); if (IsAddTaiNum(NotifyBao.m_wChairID)) { NotifyBao.minBao = mMaxBaoNum + 1; } else { NotifyBao.minBao = mMaxBaoNum; } mCurrentBaoUser = NotifyBao.m_wChairID; mCurrentMinBaoTai = NotifyBao.minBao; SparrowMaJiang::PB_CS_S_BAO_NOTICE pNotifyBao; pNotifyBao.set_minbao(NotifyBao.minBao); pNotifyBao.set_m_wchairid(NotifyBao.m_wChairID); std::string pbbao = pNotifyBao.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_NOTICE_BAO, (void*)pbbao.c_str(), pbbao.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_NOTICE_BAO, (void*)pbbao.c_str(), pbbao.length()); CString strTmp; strTmp.Format(_T("广播 用户包台 120 SUB_S_NOTICE_BAO 包台玩家=%d 最小台数=%d\r\n"), NotifyBao.m_wChairID, NotifyBao.minBao); OutputDebugString(strTmp); return true; } else { //是否是无人包 无人包台,直接结束 if (IsNoBaoUser() && wChairID==(m_wBankerUser&0xff) ) { //计算积分 并结束 NoHaveBaoUser(); return true; } if (IsNoBaoUser() && wChairID != (m_wBankerUser & 0xff)) { //给庄家发一次 CMD_S_BAO_NOTICE NotifyBao; NotifyBao.m_wChairID = m_wBankerUser&0xff; if (IsAddTaiNum(NotifyBao.m_wChairID)) { NotifyBao.minBao = mMaxBaoNum + 1; } else { NotifyBao.minBao = mMaxBaoNum; } mCurrentBaoUser = NotifyBao.m_wChairID&0xff; mCurrentMinBaoTai = NotifyBao.minBao; SparrowMaJiang::PB_CS_S_BAO_NOTICE pNotifyBao; pNotifyBao.set_minbao(NotifyBao.minBao); pNotifyBao.set_m_wchairid(NotifyBao.m_wChairID); std::string pbbao = pNotifyBao.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_NOTICE_BAO, (void*)pbbao.c_str(), pbbao.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_NOTICE_BAO, (void*)pbbao.c_str(), pbbao.length()); CString strTmp; strTmp.Format(_T("广播 无人包台给庄家再包一次 用户包台 120 SUB_S_NOTICE_BAO 包台玩家=%d 最小台数=%d\r\n"), NotifyBao.m_wChairID, NotifyBao.minBao); mBLastBaoStart = true; //OutputDebugString(strTmp); return true; } if (mBLastBaoStart==false) { mBLastBaoStart = true; //通知包家在包一次 CMD_S_BAO_NOTICE NotifyBao; NotifyBao.m_wChairID = mbaoMjUserID; NotifyBao.minBao = mMaxBaoNum; mCurrentBaoUser = NotifyBao.m_wChairID; mCurrentMinBaoTai = NotifyBao.minBao; SparrowMaJiang::PB_CS_S_BAO_NOTICE pNotifyBao; pNotifyBao.set_minbao(NotifyBao.minBao); pNotifyBao.set_m_wchairid(NotifyBao.m_wChairID); std::string pbbao = pNotifyBao.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_NOTICE_BAO, (void*)pbbao.c_str(), pbbao.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_NOTICE_BAO, (void*)pbbao.c_str(), pbbao.length()); CString strTmp; strTmp.Format(_T("广播 用户包台 120 SUB_S_NOTICE_BAO 包台玩家=%d 最小台数=%d\r\n"), NotifyBao.m_wChairID, NotifyBao.minBao); //OutputDebugString(strTmp); return true; } mBLastBaoStart = false; mbStartBaoTai = 2; //无财神 if (mMaxBaoNum % 3 == 2) { SetMagicType(MagicType_NoMagic); m_GameLogic.SetMagicIndex(MAX_INDEX, MAX_INDEX); for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } CMD_S_BAO_RESULT baoResult; ZeroMemory(&baoResult, sizeof(baoResult)); baoResult.m_wChairID = mbaoMjUserID; baoResult.baoTai = mMaxBaoNum; int nMagicCount = mMaxBaoNum % 3; if (nMagicCount == 2){ nMagicCount = MagicZero; } else if (nMagicCount == 0) { nMagicCount = MagicTwo; } baoResult.cbMagicCount = nMagicCount; if (i == (m_wBankerUser & 0xff)) { //// 胡牌判断 CChiHuRight chr; BYTE TaiShu = 0; m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)]--; if (mbaoMjUserID == i) { int nTmpAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[i], NULL, 0, m_cbProvideCard, chr, TaiShu); if (TaiShu >= mBaoTaiNum[mbaoMjUserID]) { m_cbUserAction[m_wCurrentUser] |= nTmpAction; } } else { m_cbUserAction[m_wCurrentUser] |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[i], NULL, 0, m_cbProvideCard, chr, TaiShu); } m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)]++; // if (m_cbUserAction[i] & WIK_ZI_MO) // { // m_cbUserAction[i] = WIK_TIAN_ZI_MO; // } //杠牌判断 tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult, sizeof(GangCardResult)); m_cbUserAction[m_wCurrentUser] |= m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wCurrentUser], NULL, 0, GangCardResult); for (BYTE j = 0; j < GangCardResult.cbCardCount; j++) { baoResult.gangCard[j] = GangCardResult.cbCardData[j]; } baoResult.actionMask = m_cbUserAction[m_wCurrentUser]; SparrowMaJiang::PB_CS_S_BAO_RESULT pbaoResult; pbaoResult.set_actionmask(baoResult.actionMask); pbaoResult.set_baotai(baoResult.baoTai); pbaoResult.set_cbmagiccount(baoResult.cbMagicCount); pbaoResult.set_m_wchairid(baoResult.m_wChairID); for (BYTE j = 0; j < GangCardResult.cbCardCount; j++) { pbaoResult.add_gangcard(baoResult.gangCard[j]); } std::string pbbao = pbaoResult.SerializePartialAsString(); m_pITableFrame->SendTableData(i, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); m_pITableFrame->SendLookonData(i, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); CString strTmp; strTmp.Format(_T("通知 包台结果 122 SUB_S_BAO_RESULT 玩家(庄家)=%d 包家=%d 台数=%d 财神个数=%d 玩家动作=0x%x\r\n"), i, baoResult.m_wChairID, baoResult.baoTai, baoResult.cbMagicCount, baoResult.actionMask); //OutputDebugString(strTmp); if (m_TabbOutCardCout[m_wCurrentUser] > 0) HttpTingCard(m_wCurrentUser); } else { SparrowMaJiang::PB_CS_S_BAO_RESULT pbaoResult; pbaoResult.set_actionmask(baoResult.actionMask); pbaoResult.set_baotai(baoResult.baoTai); pbaoResult.set_cbmagiccount(baoResult.cbMagicCount); pbaoResult.set_m_wchairid(baoResult.m_wChairID); std::string pbbao = pbaoResult.SerializePartialAsString(); m_pITableFrame->SendTableData(i, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); strTmp.Format(_T("通知 包台结果 122 SUB_S_BAO_RESULT 玩家=%d 包家=%d 台数=%d 财神个数=%d 玩家动作=0x%x\r\n"), i, baoResult.m_wChairID, baoResult.baoTai, baoResult.cbMagicCount, baoResult.actionMask); //OutputDebugString(strTmp); m_pITableFrame->SendLookonData(i, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); RepayRecord(INVALID_CHAIR, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); } } mbStartBaoTai = 3; } else { CMD_S_BAO_RESULT baoResult; ZeroMemory(&baoResult, sizeof(baoResult)); baoResult.m_wChairID = mbaoMjUserID; baoResult.baoTai = mMaxBaoNum; int nMagicCount = mMaxBaoNum % 3; if (nMagicCount == 2){ nMagicCount = MagicZero; } else if (nMagicCount == 0) { nMagicCount = MagicTwo; } baoResult.cbMagicCount = nMagicCount; SparrowMaJiang::PB_CS_S_BAO_RESULT pbaoResult; pbaoResult.set_actionmask(baoResult.actionMask); pbaoResult.set_baotai(baoResult.baoTai); pbaoResult.set_cbmagiccount(baoResult.cbMagicCount); pbaoResult.set_m_wchairid(baoResult.m_wChairID); std::string pbbao = pbaoResult.SerializePartialAsString(); //遍历4加 全部发包结果 for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } m_pITableFrame->SendTableData(i, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); strTmp.Format(_T("通知 包台结果 122 SUB_S_BAO_RESULT 玩家=%d 包家=%d 台数=%d 财神个数=%d 玩家动作=%x\r\n"), i, baoResult.m_wChairID, baoResult.baoTai, baoResult.cbMagicCount, baoResult.actionMask); //OutputDebugString(strTmp); } m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); RepayRecord(INVALID_CHAIR, SUB_S_BAO_RESULT, (void*)pbbao.c_str(), pbbao.length()); } } return true; } bool CTableFrameSink::SelectBaoMagic(WORD wChairID, BYTE cbMagicFirst, BYTE cbMagicSenced) { //得到包财神之后, 发送庄家操作。 int nFirst=0; int nSencend=0; if (cbMagicFirst == 255 || cbMagicFirst==0) { nFirst = MAX_INDEX; m_cbMagicFirstData = 0; } else { nFirst = m_GameLogic.SwitchToCardIndex(cbMagicFirst); m_cbMagicFirstData = cbMagicFirst; SetMagicType(MagicType_OneMagic); } if (cbMagicSenced == 255 || cbMagicSenced==0) { nSencend = MAX_INDEX; m_cbMagicSecondData = 0; } else { nSencend = m_GameLogic.SwitchToCardIndex(cbMagicSenced); m_cbMagicSecondData = cbMagicSenced; SetMagicType(MagicType_TwoMagic); } m_GameLogic.SetMagicIndex(nFirst, nSencend); for (int i = 0; i < mPlayGameUserCount;i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } CMD_S_Magic_RESULT MagicResult; ZeroMemory(&MagicResult, sizeof(MagicResult)); MagicResult.cbMagicFirst = cbMagicFirst; MagicResult.cbMagicSenced = cbMagicSenced; if (i == (m_wBankerUser & 0xff)) { //// 胡牌判断 CChiHuRight chr; BYTE TaiShu = 0; m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)]--; if (mbaoMjUserID == i) { int nTmpAction = m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[i], NULL, 0, m_cbProvideCard, chr, TaiShu); if (TaiShu >= mBaoTaiNum[mbaoMjUserID]) { m_cbUserAction[m_wCurrentUser] |= nTmpAction; } } else { m_cbUserAction[m_wCurrentUser] |= m_GameLogic.AnalyseChiHuCard(m_cbCardIndex[i], NULL, 0, m_cbProvideCard, chr, TaiShu); } m_cbCardIndex[m_wCurrentUser][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)]++; // if (m_cbUserAction[i] & WIK_ZI_MO) // { // m_cbUserAction[i] = WIK_TIAN_ZI_MO; // } //杠牌判断 tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult, sizeof(GangCardResult)); m_cbUserAction[m_wCurrentUser] |= m_GameLogic.AnalyseGangCard(m_cbCardIndex[m_wCurrentUser], NULL, 0, GangCardResult); for (BYTE j = 0; j < GangCardResult.cbCardCount; j++) { MagicResult.gangCard[j] = GangCardResult.cbCardData[j]; } MagicResult.actionMask = m_cbUserAction[m_wCurrentUser]; CString strTmp; strTmp.Format(_T("通知 选财结果 123 SUB_S_CAI_RESULT 玩家=%d 财神1=%d 财神2=%d 庄家动作=0x%x \r\n"), i, MagicResult.cbMagicFirst,MagicResult.cbMagicSenced,MagicResult.actionMask); //OutputDebugString(strTmp); SparrowMaJiang::PB_CS_S_Magic_RESULT pMagicResult; pMagicResult.set_actionmask(MagicResult.actionMask); pMagicResult.set_cbmagicfirst(MagicResult.cbMagicFirst); pMagicResult.set_cbmagicsenced(MagicResult.cbMagicSenced); for (BYTE j = 0; j < GangCardResult.cbCardCount; j++) { pMagicResult.add_gangcard(MagicResult.gangCard[j]); } std::string pbdate = pMagicResult.SerializePartialAsString(); m_pITableFrame->SendTableData(i, SUB_S_CAI_RESULT, (void*)pbdate.c_str(), pbdate.length()); m_pITableFrame->SendLookonData(i, SUB_S_CAI_RESULT, (void*)pbdate.c_str(), pbdate.length()); RepayRecord(INVALID_CHAIR, SUB_S_CAI_RESULT, (void*)pbdate.c_str(), pbdate.length()); if (m_TabbOutCardCout[(m_wBankerUser & 0xff)] > 0) HttpTingCard((m_wBankerUser & 0xff)); } else { CString strTmp; strTmp.Format(_T("通知 选财结果 123 SUB_S_CAI_RESULT 玩家=%d 财神1=%d 财神2=%d 动作=0x%x \r\n"), i, MagicResult.cbMagicFirst, MagicResult.cbMagicSenced, MagicResult.actionMask); //OutputDebugString(strTmp); SparrowMaJiang::PB_CS_S_Magic_RESULT pMagicResult; pMagicResult.set_actionmask(MagicResult.actionMask); pMagicResult.set_cbmagicfirst(MagicResult.cbMagicFirst); pMagicResult.set_cbmagicsenced(MagicResult.cbMagicSenced); std::string pbdate = pMagicResult.SerializePartialAsString(); m_pITableFrame->SendTableData(i, SUB_S_CAI_RESULT, (void*)pbdate.c_str(), pbdate.length()); m_pITableFrame->SendLookonData(i, SUB_S_CAI_RESULT, (void*)pbdate.c_str(), pbdate.length()); } } mbStartBaoTai = 3; return true; } bool CTableFrameSink::IsCanReturnResult() { if (mMaxBaoNum== NoMagic_QI_TAI) { return true; } int nGuoCount = 0; for (int i = 0; i < mPlayGameUserCount;i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (mUserOptBaoTai[i]==255) { nGuoCount++; } } if (m_bTwoPlayerFlag) { if (nGuoCount >= (mPlayGameUserCount - 2)) { if (mUserOptBaoTai[0] == -1 || mUserOptBaoTai[2] == -1) { return false; } return true; } } else { if (nGuoCount >= (mPlayGameUserCount - 1)) { if (mUserOptBaoTai[((m_wBankerUser & 0xff) + (mPlayGameUserCount - 1)) % mPlayGameUserCount] == -1) { return false; } return true; } } return false; } int CTableFrameSink::FindNextBaoJiaID(int CurrentId) { if (m_bTwoPlayerFlag) { if (CurrentId==0) { return 2; } if (CurrentId==2) { return 0; } } for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } int NextId = ((i + CurrentId + 1) % mPlayGameUserCount); if (mUserOptBaoTai[((i + CurrentId+1) % mPlayGameUserCount)]==255) { continue; } CString strFindNextID; strFindNextID.Format(_T("下一个包家ID=%d 之前台数=%d\r\n"), NextId, mUserOptBaoTai[(CurrentId + i) % (mPlayGameUserCount-1)]); OutputDebugString(strFindNextID); return (CurrentId + i + 1) % mPlayGameUserCount; } return ((m_wBankerUser & 0xff) + (mPlayGameUserCount-1)) % mPlayGameUserCount; } //条件是 是否有人选过台 bool CTableFrameSink::IsAddTaiNum(int nNextID) { int nCount = 0; for (int i = 0; i < mPlayGameUserCount;i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (mUserOptBaoTai[i] != -1 && mUserOptBaoTai[i] != 255) { nCount++; } } CString str; str.Format(_T("选台玩家个数 %d\r\n"),nCount); OutputDebugString(str); return nCount; } bool CTableFrameSink::IsNoBaoUser() { int nCount = 0; for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if ( mUserOptBaoTai[i] == 255) { nCount++; } } if (m_bTwoPlayerFlag) { return nCount == mPlayGameUserCount-1; } return nCount == mPlayGameUserCount; } void CTableFrameSink::NoHaveBaoUser() { WORD BankUserID = m_wBankerUser & 0x00ff; int FanBei = 1; if (LianXuHuPai[BankUserID] >= 2) { FanBei++; } CMD_S_GangScore gs; ZeroMemory(&gs, sizeof(gs)); gs.wChairId = 0; gs.cbOperateCode = WIK_NULL; //积分 for (int i = 0; i < mPlayGameUserCount;i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == mbaoMjUserID) { continue; } gs.lGangScore[i] += (m_gameConfig.wDiScore)*FanBei; m_lGameScore[i] += gs.lGangScore[i]; m_lGameTatolScore[i] += gs.lGangScore[i]; gs.cbWanJiaScore[i] = m_lGameTatolScore[i]; } if (m_bTwoPlayerFlag) { gs.lGangScore[mbaoMjUserID] -= m_gameConfig.wDiScore * (mPlayGameUserCount - 2) * FanBei; } else { gs.lGangScore[mbaoMjUserID] -= m_gameConfig.wDiScore * (mPlayGameUserCount - 1) * FanBei; } m_lGameScore[mbaoMjUserID] += gs.lGangScore[mbaoMjUserID]; m_lGameTatolScore[mbaoMjUserID] += gs.lGangScore[mbaoMjUserID]; gs.cbWanJiaScore[mbaoMjUserID] = m_lGameTatolScore[mbaoMjUserID]; SparrowMaJiang::PB_CS_S_GangScore GangScore; GangScore.set_cboperatecode(gs.cbOperateCode); for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); GangScore.add_lgangscore(gs.lGangScore[j]); } GangScore.set_wchairid(gs.wChairId); std::string pbscore = GangScore.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); m_wProvideUser = INVALID_CHAIR; bIsHuang = true; m_cbLeftCardCount = 0; OnEventGameConclude(m_wProvideUser, NULL, GER_NORMAL); //通知慌庄 } void CTableFrameSink::CaculationScore(BYTE WinChairID, BYTE nTai, BYTE WinWay, BYTE provideUserID, CChiHuRight UserChr, CMD_S_GangScore& cmd_Score) { if (mMjType==0)//翻财神 { FanMagicCaculation(WinChairID, nTai, WinWay, provideUserID, UserChr, cmd_Score); } if (mMjType==1)//包麻将 { PrintUsersScore(_T("计算积分前")); if (mBaoCacleDZFB) { //ZeroMemory(mZFBBianScore, sizeof(mZFBBianScore)); CalcDongZFB(WinChairID, nTai, WinWay, provideUserID); for (int i=0;iSendTableData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_OPERATE_RESULT, (void*)pbdata.c_str(), pbdata.length()); //包麻将 黄装 计算分数 WORD BankUserID = m_wBankerUser & 0x00ff; int FanBei = 1; if (LianXuHuPai[BankUserID] >= 2) { FanBei++; } CMD_S_GangScore gs; ZeroMemory(&gs, sizeof(gs)); gs.wChairId = 0; gs.cbOperateCode = WIK_ZAHU; int nTmpOneUserScore = 0; if (mMagicType == MagicType_TwoMagic) { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2)*FanBei; } else { nTmpOneUserScore = m_gameConfig.wDiScore* pow(2, mBaoTaiNum[mbaoMjUserID] - 2) * 2 * FanBei; } //积分 for (int i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } if (i == mbaoMjUserID) { continue; } gs.lGangScore[i] += nTmpOneUserScore; m_lGameScore[i] += gs.lGangScore[i]; m_lGameTatolScore[i] += gs.lGangScore[i]; gs.cbWanJiaScore[i] = m_lGameTatolScore[i]; } if (m_bTwoPlayerFlag) { gs.lGangScore[mbaoMjUserID] -= nTmpOneUserScore * (mPlayGameUserCount - 2); } else { gs.lGangScore[mbaoMjUserID] -= nTmpOneUserScore * (mPlayGameUserCount - 1); } m_lGameScore[mbaoMjUserID] += gs.lGangScore[mbaoMjUserID]; m_lGameTatolScore[mbaoMjUserID] += gs.lGangScore[mbaoMjUserID]; gs.cbWanJiaScore[mbaoMjUserID] = m_lGameTatolScore[mbaoMjUserID]; SparrowMaJiang::PB_CS_S_GangScore GangScore; GangScore.set_cboperatecode(gs.cbOperateCode); for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); GangScore.add_lgangscore(gs.lGangScore[j]); } GangScore.set_wchairid(gs.wChairId); std::string pbscore = GangScore.SerializePartialAsString(); m_pITableFrame->SendTableData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); m_pITableFrame->SendLookonData(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbscore.c_str(), pbscore.length()); for (BYTE i = 0; i < mPlayGameUserCount; i++) { if (m_bTwoPlayerFlag&&i == TowMjNullseat) { continue; } gs.cbWanJiaScore[i] = m_lGameScore[i]; } for (BYTE j = 0; j < mPlayGameUserCount; j++) { GangScore.add_cbwanjiascore(gs.cbWanJiaScore[j]); } std::string pbrecord = GangScore.SerializePartialAsString(); RepayRecord(INVALID_CHAIR, SUB_S_GANG_SCORE, (void*)pbrecord.c_str(), pbrecord.length()); mBZaHu = TRUE; OnEventGameConclude(wChairID, NULL, GER_NORMAL); return true; } //被动操作删除手牌 bool CTableFrameSink::DeleteCaiShenCard(WORD wTargetUser, BYTE cbTargetCaiCard[4], int cbTargetAction, BYTE cbTargetCard) { switch (cbTargetAction) { case WIK_SAN_MING_GANG: { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[0])]--) { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[1])]--) { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[2])]--) { ASSERT(m_cbWeaveItemCount[wTargetUser] < 4); if (m_cbWeaveItemCount[wTargetUser] > 4)return false; WORD wIndex = m_cbWeaveItemCount[wTargetUser]++; m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard = TRUE; m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard = cbTargetCard; m_WeaveItemArray[wTargetUser][wIndex].cbWeaveKind = cbTargetAction; m_WeaveItemArray[wTargetUser][wIndex].wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[0] = cbTargetCaiCard[0]; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[1] = cbTargetCaiCard[1]; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[2] = cbTargetCaiCard[2]; if (mMjType==0&&mPlayGameUserCount==4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount !=4 ) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount ++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_DAN_CHI: case WIK_SHUANG_CAICHI: case WIK_SHUANG_PENG: { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[0])]--) { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[1])]--) { ASSERT(m_cbWeaveItemCount[wTargetUser] < 4); if (m_cbWeaveItemCount[wTargetUser] > 4)return false; WORD wIndex = m_cbWeaveItemCount[wTargetUser]++; m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard = TRUE; m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard = cbTargetCard; m_WeaveItemArray[wTargetUser][wIndex].cbWeaveKind = cbTargetAction; m_WeaveItemArray[wTargetUser][wIndex].wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[0] = cbTargetCaiCard[0]; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[1] = cbTargetCaiCard[1]; return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_SHUANG_MING_GANG: { BYTE CardIndex = m_GameLogic.SwitchToCardIndex(cbTargetCard); if (m_cbCardIndex[wTargetUser][CardIndex]--) { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[0])]--) { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[1])]--) { ASSERT(m_cbWeaveItemCount[wTargetUser] < 4); if (m_cbWeaveItemCount[wTargetUser] > 4)return false; WORD wIndex = m_cbWeaveItemCount[wTargetUser]++; m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard = TRUE; m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard = cbTargetCard; m_WeaveItemArray[wTargetUser][wIndex].cbWeaveKind = cbTargetAction; m_WeaveItemArray[wTargetUser][wIndex].wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[0] = cbTargetCaiCard[0]; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[1] = cbTargetCaiCard[1]; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[2] = cbTargetCard; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_DAN_PENG: { BYTE CardIndex = m_GameLogic.SwitchToCardIndex(cbTargetCard); if (m_cbCardIndex[wTargetUser][CardIndex]--) { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[0])]--) { ASSERT(m_cbWeaveItemCount[wTargetUser] < 4); if (m_cbWeaveItemCount[wTargetUser] > 4)return false; WORD wIndex = m_cbWeaveItemCount[wTargetUser]++; m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard = TRUE; m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard = cbTargetCard; m_WeaveItemArray[wTargetUser][wIndex].cbWeaveKind = cbTargetAction; m_WeaveItemArray[wTargetUser][wIndex].wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[0] = cbTargetCaiCard[0]; return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_DAN_MING_GANG: { BYTE CardIndex = m_GameLogic.SwitchToCardIndex(cbTargetCard); if (m_cbCardIndex[wTargetUser][CardIndex] - 2 >= 0) { m_cbCardIndex[wTargetUser][CardIndex] -= 2; if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(cbTargetCaiCard[0])]--) { ASSERT(m_cbWeaveItemCount[wTargetUser] < 4); if (m_cbWeaveItemCount[wTargetUser] > 4)return false; WORD wIndex = m_cbWeaveItemCount[wTargetUser]++; m_WeaveItemArray[wTargetUser][wIndex].cbPublicCard = TRUE; m_WeaveItemArray[wTargetUser][wIndex].cbCenterCard = cbTargetCard; m_WeaveItemArray[wTargetUser][wIndex].cbWeaveKind = cbTargetAction; m_WeaveItemArray[wTargetUser][wIndex].wProvideUser = (m_wProvideUser == INVALID_CHAIR) ? wTargetUser : m_wProvideUser; m_WeaveItemArray[wTargetUser][wIndex].cbMargicOffset[0] = cbTargetCaiCard[0]; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_LEFT: //上牌操作,左吃 { //删除扑克 BYTE cbRemoveCard[3]; BYTE cbMagicCard[4] = { 0 }; m_GameLogic.GetWeaveCard(WIK_LEFT, cbTargetCard, cbMagicCard, cbRemoveCard); VERIFY(m_GameLogic.RemoveCard(cbRemoveCard, 3, &cbTargetCard, 1)); VERIFY(m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser], cbRemoveCard, 2)); return true; } case WIK_RIGHT: //上牌操作,右吃 { //删除扑克 BYTE cbRemoveCard[3]; BYTE cbMagicCard[4] = { 0 }; m_GameLogic.GetWeaveCard(WIK_RIGHT, cbTargetCard, cbMagicCard, cbRemoveCard); VERIFY(m_GameLogic.RemoveCard(cbRemoveCard, 3, &cbTargetCard, 1)); VERIFY(m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser], cbRemoveCard, 2)); return true; } case WIK_CENTER: //上牌操作,中吃 { //删除扑克 BYTE cbRemoveCard[3]; BYTE cbMagicCard[4] = { 0 }; m_GameLogic.GetWeaveCard(WIK_CENTER, cbTargetCard, cbMagicCard, cbRemoveCard); VERIFY(m_GameLogic.RemoveCard(cbRemoveCard, 3, &cbTargetCard, 1)); VERIFY(m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser], cbRemoveCard, 2)); return true; } case WIK_PENG: //碰牌操作 { //删除扑克 if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)] < 2) { ASSERT(false); return false; } BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard }; VERIFY(m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser], cbRemoveCard, 2)); return true; } case WIK_MING_GANG: //明杠牌操作 { if (m_cbCardIndex[wTargetUser][m_GameLogic.SwitchToCardIndex(m_cbProvideCard)] != 3) { ASSERT(false); return false; } BYTE cbRemoveCard[] = { cbTargetCard, cbTargetCard, cbTargetCard }; VERIFY(m_GameLogic.RemoveCard(m_cbCardIndex[wTargetUser], cbRemoveCard, CountArray(cbRemoveCard))); if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } default: { ASSERT(false); return false; } } } //自主操作删除手牌 bool CTableFrameSink::DeleteCard(WORD wChairID, BYTE cbCaiShenCard[4], int cbOperateCode, BYTE cbOperateCard) { switch (cbOperateCode) { case WIK_QUANG_AN_GANG: { //变量定义 BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); BYTE CaiShenCount = m_GameLogic.GetMaigcCardCount(m_cbCardIndex[wChairID]); if (CaiShenCount > 3) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[0])]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[1])]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[2])]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[3])]--) { cbWeaveIndex = m_cbWeaveItemCount[wChairID]++; m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = FALSE; m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[0] = cbCaiShenCard[0]; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[1] = cbCaiShenCard[1]; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[2] = cbCaiShenCard[2]; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[3] = cbCaiShenCard[3]; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_SAN_AN_GANG: { //变量定义 BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); BYTE CaiShenCount = m_GameLogic.GetMaigcCardCount(m_cbCardIndex[wChairID]); if (CaiShenCount > 2) { if (m_cbCardIndex[wChairID][cbCardIndex]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[0])]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[1])]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[2])]--) { cbWeaveIndex = m_cbWeaveItemCount[wChairID]++; m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = FALSE; m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[0] = cbCaiShenCard[0]; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[1] = cbCaiShenCard[1]; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[2] = cbCaiShenCard[2]; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_SHUANG_AN_GANG: { //变量定义 BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); BYTE CaiShenCount = m_GameLogic.GetMaigcCardCount(m_cbCardIndex[wChairID]); if (CaiShenCount > 1) { if (m_cbCardIndex[wChairID][cbCardIndex] - 2 >= 0) { m_cbCardIndex[wChairID][cbCardIndex] -= 2; if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[0])]--) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[1])]--) { cbWeaveIndex = m_cbWeaveItemCount[wChairID]++; m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = FALSE; m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[0] = cbCaiShenCard[0]; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[1] = cbCaiShenCard[1]; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_DAN_AN_GANG: { //变量定义 BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); BYTE CaiShenCount = m_GameLogic.GetMaigcCardCount(m_cbCardIndex[wChairID]); if (CaiShenCount > 0) { if (m_cbCardIndex[wChairID][cbCardIndex] - 3 >= 0) { m_cbCardIndex[wChairID][cbCardIndex] -= 3; if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[0])]--) { cbWeaveIndex = m_cbWeaveItemCount[wChairID]++; m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = FALSE; m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[0] = cbCaiShenCard[0]; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_DAN_BU_GANG: { //变量定义 BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); BYTE CaiShenCount = m_GameLogic.GetMaigcCardCount(m_cbCardIndex[wChairID]); if (CaiShenCount > 0 && cbCaiShenCard[0] != 0) { if (m_cbCardIndex[wChairID][m_GameLogic.SwitchToCardIndex(cbCaiShenCard[0])]--) { INT cbWeaveKind; for (BYTE i = 0; i < m_cbWeaveItemCount[wChairID]; i++) { cbWeaveKind = m_WeaveItemArray[wChairID][i].cbWeaveKind; BYTE cbCenterCard = m_WeaveItemArray[wChairID][i].cbCenterCard; if ((cbCenterCard == cbOperateCard) && (cbWeaveKind & (WIK_PENG|WIK_DAN_PENG|WIK_SHUANG_PENG))) { cbWeaveIndex = i; break; } } if (cbWeaveKind == WIK_PENG) { m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = true; //m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[0] = cbCaiShenCard[0]; } else if (cbWeaveKind == WIK_DAN_PENG) { m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = true; //m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[1] = cbCaiShenCard[0]; } else { m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = true; //m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; m_WeaveItemArray[wChairID][cbWeaveIndex].cbMargicOffset[2] = cbCaiShenCard[0]; } if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } else { ASSERT(false); return false; } } else { ASSERT(false); return false; } } case WIK_AN_GANG: //暗杠牌操作 { //扑克效验 ASSERT((cbOperateCode == WIK_AN_GANG) || (m_GameLogic.IsValidCard(cbOperateCard) == true)); if ((cbOperateCode != WIK_AN_GANG) && (m_GameLogic.IsValidCard(cbOperateCard) == false)) return false; //变量定义 BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); //杠牌处理 if (m_cbCardIndex[wChairID][cbCardIndex] == 4) { //扑克效验 ASSERT(m_cbCardIndex[wChairID][cbCardIndex] == 4); if (m_cbCardIndex[wChairID][cbCardIndex] != 4) { ASSERT(false); return false; } cbWeaveIndex = m_cbWeaveItemCount[wChairID]++; m_WeaveItemArray[wChairID][cbWeaveIndex].cbPublicCard = FALSE; m_WeaveItemArray[wChairID][cbWeaveIndex].wProvideUser = wChairID; m_WeaveItemArray[wChairID][cbWeaveIndex].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; } else { ASSERT(FALSE); return false; } //删除扑克 m_cbCardIndex[wChairID][cbCardIndex] = 0; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } case WIK_BU_GANG: { //扑克效验 ASSERT((cbOperateCode == WIK_NULL) || (cbOperateCode == WIK_BU_GANG) || (m_GameLogic.IsValidCard(cbOperateCard) == true)); if ((cbOperateCode != WIK_BU_GANG) && (m_GameLogic.IsValidCard(cbOperateCard) == false)) return false; BYTE cbWeaveIndex = 0xFF; BYTE cbCardIndex = m_GameLogic.SwitchToCardIndex(cbOperateCard); //杠牌处理 if (m_cbCardIndex[wChairID][cbCardIndex] >= 1)//表示续杠类型 { //寻找组合 for (BYTE i = 0; i < m_cbWeaveItemCount[wChairID]; i++) { INT cbWeaveKind = m_WeaveItemArray[wChairID][i].cbWeaveKind; BYTE cbCenterCard = m_WeaveItemArray[wChairID][i].cbCenterCard; if ((cbCenterCard == cbOperateCard) && (cbWeaveKind &(WIK_DAN_PENG|WIK_PENG|WIK_SHUANG_PENG))) { 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].cbWeaveKind = cbOperateCode; m_WeaveItemArray[wChairID][cbWeaveIndex].cbCenterCard = cbOperateCard; } else { ASSERT(false); return false; } //删除扑克 m_cbCardIndex[wChairID][cbCardIndex] -= 1; if (mMjType == 0 && mPlayGameUserCount == 4) { if (m_cbLeftCardCount > 6)//扣除3墩可摸的牌 m_cbLeftCardCount -= 6; else//少于三墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } if (mMjType == 0 && mPlayGameUserCount != 4) { if (m_cbLeftCardCount > 4)//扣除2墩可摸的牌 m_cbLeftCardCount -= 4; else//少于二墩就只有一张可以抓的牌咯 m_cbLeftCardCount = 1; } m_cbGangCount++;//打了几个杠 return true; } default: { ASSERT(false); return false; }; } } //优先级判断 bool CTableFrameSink::OperatorPriority(WORD TempUser, WORD &wTargetUser, int &cbTargetAction) { for (WORD UserPlayIndex = 0; UserPlayIndex < mPlayGameUserCount; UserPlayIndex++)//除了打牌人,操作人与其他两位对操作优先级 { if (m_bTwoPlayerFlag&&UserPlayIndex == TowMjNullseat) { continue; } TempUser = (TempUser + 1) % mPlayGameUserCount; if (TempUser == wTargetUser)continue; //获取动作 int cbUserAction = (m_bResponse[TempUser] == false) ? m_cbUserAction[TempUser] : m_cbPerformAction[TempUser]; //优先级别 BYTE cbUserActionRank = m_GameLogic.GetUserActionRank(cbUserAction); BYTE cbTargetActionRank = m_GameLogic.GetUserActionRank(cbTargetAction); //动作判断 if (cbUserActionRank > cbTargetActionRank) { wTargetUser = TempUser; cbTargetAction = cbUserAction; continue; } if (cbUserActionRank == cbTargetActionRank && cbTargetActionRank != WIK_NULL) { if (UserPlayIndex == 2)//肯定和其他人都比了,最后一次两个人的操作一样,且表示操作人不在末端操作人 { return true; } else if (UserPlayIndex == 1)//对比一次,对比了两次说明操作人不是下家的下家;操作人只能是第一家或者最后一家,如果是第一家操作:,如果是最后一家 { WORD TempTempUser = (TempUser + 1) % mPlayGameUserCount; if (wTargetUser == TempTempUser)//确定操作人是最后一个,这是第二次对比 { wTargetUser = TempUser; cbTargetAction = cbUserAction; return true; } else//第一次对比,确定操作人是出牌人下家,这个时候再把他和后面一个人的牌权对比 { int cbUserAction = (m_bResponse[TempTempUser] == false) ? m_cbUserAction[TempTempUser] : m_cbPerformAction[TempTempUser]; //优先级别 BYTE cbUserActionRank = m_GameLogic.GetUserActionRank(cbUserAction); BYTE cbTargetActionRank = m_GameLogic.GetUserActionRank(cbTargetAction); if (cbUserActionRank > cbTargetActionRank) { wTargetUser = TempTempUser; cbTargetAction = cbUserAction; return true; } break; } } else//冲上来就比了一次,说操作人不是打牌人下家 { wTargetUser = TempUser; cbTargetAction = cbUserAction; WORD TempTempUser = (TempUser + 1) % mPlayGameUserCount; if (wTargetUser == TempTempUser)TempTempUser = (TempTempUser + 1) % mPlayGameUserCount;//如果在中间就换一个人 int cbUserAction = (m_bResponse[TempTempUser] == false) ? m_cbUserAction[TempTempUser] : m_cbPerformAction[TempTempUser]; //优先级别 BYTE cbUserActionRank = m_GameLogic.GetUserActionRank(cbUserAction); BYTE cbTargetActionRank = m_GameLogic.GetUserActionRank(cbTargetAction); if (cbUserActionRank > cbTargetActionRank) { wTargetUser = TempTempUser; cbTargetAction = cbUserAction; return true; } return true; } } } return true; } int CTableFrameSink::bHuPaiType(CChiHuRight &CChiHuRight) { int hutype = 0; if (!(CChiHuRight&ZJ_TAI_QingYiSe).IsEmpty()) { hutype |= ZJ_TAI_QingYiSe; } if (!(CChiHuRight&ZJ_TAI_DongFeng).IsEmpty()) { hutype |= ZJ_TAI_DongFeng; } if (!(CChiHuRight&ZJ_TAI_WuMagic).IsEmpty()) { hutype |= ZJ_TAI_WuMagic; } if (!(CChiHuRight&ZJ_TAI_QuanShun).IsEmpty()) { hutype |= ZJ_TAI_QuanShun; } if (!(CChiHuRight&ZJ_TAI_PengPeng).IsEmpty()) { hutype |= ZJ_TAI_PengPeng; } if (!(CChiHuRight&ZJ_TAI_HunYiSe).IsEmpty()) { hutype |= ZJ_TAI_HunYiSe; } if (!(CChiHuRight&ZJ_TAI_Gang).IsEmpty()) { hutype |= ZJ_TAI_Gang; } if (!(CChiHuRight&ZJ_TAI_ZFB).IsEmpty()) { hutype |= ZJ_TAI_ZFB; } if (!(CChiHuRight&ZJ_TAI_QuanZi).IsEmpty()) { hutype = ZJ_TAI_QuanZi; } if (!(CChiHuRight&ZJ_TAI_ZHAHU).IsEmpty()) { hutype = ZJ_TAI_ZHAHU; } return hutype; }