//======================================================================================== // 功能 : 前面已经有人敲了 // 参数 : BYTE byCardType [in] 当前最大的牌类型 //======================================================================================== void CClientGameDlg::HaveSetAllNote(BYTE byCardType) { int iRand = rand()%100; if(byCardType >= ZX_HE_PAI) //丁皇,天,地,人,和 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME); } else if(byCardType >= ZX_DI_GANG) //地杠 { if(iRand < 100) //敲 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME); } else { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_GIVE_UP_TIME); } } else //散牌 { if(iRand < 90) //敲 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME); } else { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_GIVE_UP_TIME); } } }
int CGameFlyControl::StartGame() { SetGameTimer(BIRDMOVETIMER,100); SetGameTimer(BIRDFLYLEVELTIMER,18000); SetGameTimer(GUNMOVETIMER,60); return 2; }
//用户叫庄 bool CGameClientDlg::OnSubCallBanker(const void * pBuffer, WORD wDataSize) { //效验数据 if (wDataSize!=sizeof(CMD_S_CallBanker)) return false; CMD_S_CallBanker * pCallBanker=(CMD_S_CallBanker *)pBuffer; //首次叫庄 if(pCallBanker->bFirstTimes) { //用户信息 for (WORD i=0;i<GAME_PLAYER;i++) { //视图位置 m_wViewChairID[i]=SwitchViewChairID(i); //获取用户 const tagUserData * pUserData=GetUserData(i); if (pUserData==NULL) continue; //游戏信息 m_cbPlayStatus[i]=TRUE; //用户名字 lstrcpyn(m_szAccounts[i],pUserData->szName,CountArray(m_szAccounts[i])); } //旁观者清理数据 if (IsLookonMode()) OnStart(0,0); } //删除定时器/按钮 if(m_GameClientView.m_btIdler.IsWindowVisible()==TRUE) { KillGameTimer(IDI_CALL_BANKER); m_GameClientView.m_btIdler.ShowWindow(SW_HIDE); m_GameClientView.m_btBanker.ShowWindow(SW_HIDE); } //用户控件显示 if(IsCurrentUser(pCallBanker->wCallBanker)) { m_GameClientView.m_btBanker.ShowWindow(SW_SHOW); m_GameClientView.m_btIdler.ShowWindow(SW_SHOW); } //等待标志 WORD wViewID=m_wViewChairID[pCallBanker->wCallBanker]; m_GameClientView.SetWaitCall((BYTE)wViewID); //实际定时器 if(pCallBanker->wCallBanker==GetMeChairID()) { SetGameTimer(pCallBanker->wCallBanker,IDI_CALL_BANKER,TIME_USER_CALL_BANKER); } else SetGameTimer(pCallBanker->wCallBanker,IDI_NULLITY,TIME_USER_CALL_BANKER); return true; }
//放弃出牌 bool CGameClientDlg::OnSubPassCard(const void * pBuffer, WORD wDataSize) { //效验数据 if (wDataSize!=sizeof(CMD_S_PassCard)) return false; CMD_S_PassCard * pPassCard=(CMD_S_PassCard *)pBuffer; //删除定时器 KillGameTimer(IDI_OUT_CARD); //玩家设置 if ((IsLookonMode()==true)||(pPassCard->wPassUser!=GetMeChairID())) { WORD wViewChairID=SwitchViewChairID(pPassCard->wPassUser); m_GameClientView.SetPassFlag(wViewChairID,true); m_GameClientView.m_UserCardControl[wViewChairID].SetCardData(NULL,0); } //一轮判断 if (pPassCard->bNewTurn==TRUE) { m_bTurnCardCount=0; m_bTurnOutType=CT_ERROR; memset(m_bTurnCardData,0,sizeof(m_bTurnCardData)); } //设置界面 WORD wViewChairID=SwitchViewChairID(pPassCard->wCurrentUser); m_GameClientView.SetPassFlag(wViewChairID,false); m_GameClientView.m_UserCardControl[wViewChairID].SetCardData(NULL,0); //玩家设置 if ((IsLookonMode()==false)&&(pPassCard->wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.ShowWindow(SW_SHOW); m_GameClientView.m_btOutPrompt.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.EnableWindow((m_bTurnCardCount>0)?TRUE:FALSE); m_GameClientView.m_btOutCard.EnableWindow((VerdictOutCard()==true)?TRUE:FALSE); m_GameClientView.m_btOutPrompt.EnableWindow(m_bTurnCardCount>0?TRUE:FALSE); } //播放声音 if ((IsLookonMode()==true)||(pPassCard->wPassUser!=GetMeChairID())) PlayGameSound(AfxGetInstanceHandle(),TEXT("OUT_CARD")); //设置时间 if (m_bTurnCardCount!=0) { WORD wTimeCount=30; if (m_GameClientView.m_btPassCard.IsWindowEnabled()) wTimeCount=10; SetGameTimer(pPassCard->wCurrentUser,IDI_OUT_CARD,wTimeCount); } else SetGameTimer(pPassCard->wCurrentUser,IDI_OUT_CARD,30); return true; }
int CGameFlyControl::PauseGame(BOOL bPause) { if (bPause) { KillAllTimer(); } else { SetGameTimer(BIRDMOVETIMER,100); SetGameTimer(BIRDFLYLEVELTIMER,18000); SetGameTimer(GUNMOVETIMER,60); } return 2; }
void CClientGameDlg::SetBoboTime( void * pNetData, UINT uDataSize) { m_bSepartorFlag = false; BeginUpgradeStruct * pBegin=(BeginUpgradeStruct *)pNetData; m_bNtPeople = pBegin->bNtStation; //庄家位置 m_i64BoBase = pBegin->i64BoBase; //簸底 m_i64SmallBobo = pBegin->i64SmallBobo; //最小簸簸 m_i64TempBobo = m_i64SmallBobo; //设置簸簸的最小数值 ::CopyMemory(m_bPlayer,pBegin->bPlay,sizeof(m_bPlayer)); //记录当前玩家是不是中途加入的(true:不是中途加入) ::memset(m_byUserOperatorType,0xff,sizeof(m_byUserOperatorType)); m_i64FrontNote = 0; //前家下的注 m_i64MyAddNote = 0; //我自已要下的注 __int64 myMoney = GetMeUserInfo()->i64Money * m_iBoboPercentage/100; //最高能设置簸簸数值 if(myMoney < m_i64BoBase) //检测数据设置是否合法 { myMoney = GetMeUserInfo()->i64Money - m_i64BoBase; } else { myMoney -= m_i64BoBase; } srand(GetTickCount()+m_iMyLogDesk); int iRand = rand() % 7 + 1; m_i64TempBobo = (myMoney * iRand)/7 + m_i64BoBase; int iTime = m_byBoBoTime /(rand()/10 + 1); SetGameTimer(m_iMyLogDesk,iTime,ID_SET_BOBOTIME); }
//游戏空闲 bool CGameClientDlg::OnSubGameFree(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_GameFree)); if (wDataSize!=sizeof(CMD_S_GameFree)) return false; //消息处理 CMD_S_GameFree * pGameFree=(CMD_S_GameFree *)pBuffer; //设置时间 SetGameTimer(GetMeChairID(),IDI_FREE,pGameFree->cbTimeLeave); //设置状态 SetGameStatus(GS_FREE); //清理桌面 m_GameClientView.SetWinnerSide(0xFF); m_GameClientView.m_bShowResult=false; m_GameClientView.CleanUserJetton(); for (int nAreaIndex=ID_TIAN_MARK; nAreaIndex<=ID_HUANG_MARK; nAreaIndex*=2) SetMePlaceJetton(nAreaIndex,0); //更新控件 UpdateButtonContron(); for(int i=0;i<5;i++) m_GameClientView.m_CardControl[i].ReSet(); m_GameClientView.KillTimer(123456); m_GameClientView.m_cbWaitPre=0; return true; }
//用户掀牌 bool CGameClientDlg::OnSubXianPai(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_User_XianPai)); if (wDataSize!=sizeof(CMD_S_User_XianPai)) return false; //消息处理 CMD_S_User_XianPai * pXianPai=(CMD_S_User_XianPai *)pBuffer; m_GameClientView.ShowXianPaiTitle(SW_NORMAL,SwitchViewChairID(pXianPai->wXianPaiUserID)); m_GameClientView.HideAllTitle(false,INVALID_CHAIR); //设置界面 m_GameClientView.SetIncreaseXian(SwitchViewChairID(pXianPai->wXianPaiUserID)); if(pXianPai->wCurrentUser==GetMeChairID()) { ActiveGameFrame(); m_GameClientView.m_btAutoOutCard.ShowWindow(SW_NORMAL); m_GameClientView.m_btOutCard.ShowWindow(SW_NORMAL); //设置被掀次数 m_GameClientView.SetIncreaseBeiXian(SwitchViewChairID(GetMeChairID())); } //设置定时器 KillGameTimer(IDI_OUT_CARD); SetGameTimer(pXianPai->wCurrentUser,IDI_OUT_CARD,30); return true; }
//定时器消息 void CGameClientDlg::OnTimer(UINT nIDEvent) { if ((nIDEvent==IDI_MOST_CARD)&&(m_wMostUser!=INVALID_CHAIR)) { //变量定义 WORD wCurrentUser=m_wMostUser; m_wMostUser=INVALID_CHAIR; //删除定时器 KillTimer(IDI_MOST_CARD); //设置界面 m_GameClientView.SetPassFlag(INVALID_CHAIR,false); for (WORD i=0;i<GAME_PLAYER;i++) m_GameClientView.m_UserCardControl[i].SetCardData(NULL,0); //玩家设置 if ((IsLookonMode()==false)&&(wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.EnableWindow(FALSE); m_GameClientView.m_btAutoOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btAutoOutCard.EnableWindow(FALSE); m_GameClientView.m_btOutCard.EnableWindow((VerdictOutCard()==true)?TRUE:FALSE); } //设置时间 SetGameTimer(wCurrentUser,IDI_OUT_CARD,30); return; } __super::OnTimer(nIDEvent); }
//游戏空闲 bool CGameClientDlg::OnSubGameFree(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_GameFree)); if (wDataSize!=sizeof(CMD_S_GameFree)) return false; //消息处理 CMD_S_GameFree * pGameFree=(CMD_S_GameFree *)pBuffer; //设置时间 SetGameTimer(GetMeChairID(),IDI_FREE,pGameFree->cbTimeLeave); //设置空闲状态 m_GameClientView.SetFreeTime(); //设置状态 SetGameStatus(GS_FREE); //清理桌面 m_GameClientView.SetWinnerSide(0xFF); m_GameClientView.CleanUserJetton(); for (int nAreaIndex=ID_HORSE1; nAreaIndex<=ID_HORSE8; ++nAreaIndex) SetMePlaceJetton(nAreaIndex,0); //更新控件 UpdateButtonContron(); return true; }
//发牌完成 LRESULT CGameClientDlg::OnSendCardFinish(WPARAM wParam, LPARAM lParam) { //响应扑克 WORD wMeChairID=GetMeChairID(); if(!IsLookonMode())m_GameClientView.m_CardControl[MY_VIEW_CHAIRID].SetPositively(true); //设置时间 SetGameTimer(wMeChairID,IDI_NULLITY,TIME_USER_OPEN_CARD); //过虑观看 if (IsLookonMode())return 0; //特殊牌型 BYTE bCardType = m_GameLogic.GetCardType(m_cbHandCardData[wMeChairID],MAX_COUNT); if(bCardType >= OX_THREE_SAME) { //提示信息 m_GameClientView.SetUserAction(true); //用户信息 WORD wViewChairID=m_wViewChairID[wMeChairID]; m_GameClientView.m_CardControl[wViewChairID].ShootAllCard(false); //发送消息 CMD_C_OxCard OxCard; OxCard.bOX=TRUE; SendData(SUB_C_OPEN_CARD,&OxCard,sizeof(OxCard)); //预先处理 m_GameClientView.ShowOpenCard(wViewChairID); m_GameClientView.m_CardControl[wViewChairID].SetPositively(false); //显示牌型 m_GameClientView.SetUserOxValue(wViewChairID,bCardType); //保存牛信息 m_bUserOxCard[wMeChairID]=OxCard.bOX; return 0; } //控件处理 if(!m_GameClientView.m_CardControl[MY_VIEW_CHAIRID].GetKey()) { m_GameClientView.m_btOx.EnableWindow(FALSE); } m_GameClientView.m_btOpenCard.ShowWindow(SW_SHOW); m_GameClientView.m_btHintOx.ShowWindow(SW_SHOW); //等待标志 m_GameClientView.m_bOpenCard=true; //时间设置 SetTimer(IDI_TIME_OPEN_CARD,TIME_USER_OPEN_CARD*1000,NULL); return 0; }
//发送扑克 bool CGameClientDlg::OnSubSendCard(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_SendCard)); if (wDataSize!=sizeof(CMD_S_SendCard)) return false; //变量定义 CMD_S_SendCard * pSendCard=(CMD_S_SendCard *)pBuffer; //设置数据 m_bHandCardCount=CountArray(pSendCard->bCardData); CopyMemory(m_bHandCardData,pSendCard->bCardData,sizeof(pSendCard->bCardData)); for (WORD i=0;i<GAME_PLAYER;i++) m_bCardCount[i]=CountArray(pSendCard->bCardData); //设置界面 for (WORD i=0;i<GAME_PLAYER;i++) { m_GameClientView.SetLandScore(i,0); m_GameClientView.SetPassFlag(i,false); m_GameClientView.SetCardCount(i,m_bCardCount[i]); m_GameClientView.m_UserCardControl[i].SetCardData(NULL,0); } if (IsLookonMode()==true) { m_GameClientView.SetLandUser(INVALID_CHAIR,0); m_GameClientView.m_ScoreView.ShowWindow(SW_HIDE); m_GameClientView.m_LeaveCardControl[0].SetCardData(NULL,0); m_GameClientView.m_LeaveCardControl[1].SetCardData(NULL,0); } m_GameClientView.ShowLandTitle(true); m_GameClientView.SetBombTime(m_wBombTime); //设置扑克 BYTE bBackCard[LEFT_CARD_NUM /*3*/]={0,0,0,0}; m_GameClientView.m_HandCardControl.SetCardData(pSendCard->bCardData, ONE_USER_GET_CARD_NUM /*17*/); m_GameClientView.m_BackCardControl.SetCardData(bBackCard,CountArray(bBackCard)); if (IsLookonMode()==true) m_GameClientView.m_HandCardControl.SetDisplayFlag(false); //当前玩家 if ((IsLookonMode()==false)&&(pSendCard->wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btOneScore.ShowWindow(SW_SHOW); m_GameClientView.m_btTwoScore.ShowWindow(SW_SHOW); m_GameClientView.m_btThreeScore.ShowWindow(SW_SHOW); m_GameClientView.m_btGiveUpScore.ShowWindow(SW_SHOW); } //播放声音 PlayGameSound(AfxGetInstanceHandle(),TEXT("KAI_WA")); //设置时间 SetGameTimer(pSendCard->wCurrentUser,IDI_LAND_SCORE,30); return true; }
//游戏开始 bool CGameClientDlg::OnSubGameStart(const void * pBuffer, WORD wDataSize) { //效验数据 if (wDataSize!=sizeof(CMD_S_GameStart)) return false; CMD_S_GameStart * pGameStart=(CMD_S_GameStart *)pBuffer; //删除定时器/按钮 if(m_GameClientView.m_btIdler.IsWindowVisible()==TRUE) { KillGameTimer(IDI_CALL_BANKER); m_GameClientView.m_btIdler.ShowWindow(SW_HIDE); m_GameClientView.m_btBanker.ShowWindow(SW_HIDE); } //设置变量 m_lTurnMaxScore=pGameStart->lTurnMaxScore; m_wBankerUser=pGameStart->wBankerUser; m_GameClientView.SetWaitCall(0xff); //设置筹码 if (!IsLookonMode() && pGameStart->lTurnMaxScore>0) { LONGLONG lUserMaxScore[GAME_PLAYER]; ZeroMemory(lUserMaxScore,sizeof(lUserMaxScore)); LONGLONG lTemp=m_lTurnMaxScore; for (WORD i=0;i<GAME_PLAYER;i++) { if(i>0)lTemp/=2; lUserMaxScore[i]=__max(lTemp,1L); } //更新控件 //ActiveGameFrame(); UpdateScoreControl(lUserMaxScore,SW_SHOW); //实际定时器 SetTimer(IDI_TIME_USER_ADD_SCORE,(TIME_USER_ADD_SCORE)*1000,NULL); } //庄家标志 WORD wID=m_wViewChairID[m_wBankerUser]; m_GameClientView.SetBankerUser(wID); //等待标志 m_GameClientView.SetWaitInvest(true); //辅助显示中心时钟 SetGameTimer(GetMeChairID(),IDI_NULLITY,TIME_USER_ADD_SCORE); //环境设置 PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START")); return true; }
//用户叫分 bool CGameClientDlg::OnSubLandScore(const void * pBuffer, WORD wDataSize) { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sOnSubLandScore.log",strTime); strTemp.Format("into OnSubLandScore"); theApp.WriteLog(strFile, strTemp); //效验数据 ASSERT(wDataSize==sizeof(CMD_S_LandScore)); if (wDataSize!=sizeof(CMD_S_LandScore)) return false; //消息处理 CMD_S_LandScore * pLandScore=(CMD_S_LandScore *)pBuffer; //设置界面 WORD wViewChairID=SwitchViewChairID(pLandScore->bLandUser); m_GameClientView.SetLandScore(wViewChairID,pLandScore->bLandScore); //玩家设置 if ((IsLookonMode()==false)&&(pLandScore->wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btGiveUpScore.ShowWindow(SW_SHOW); m_GameClientView.m_btOneScore.ShowWindow(pLandScore->bCurrentScore<=0?SW_SHOW:SW_HIDE); m_GameClientView.m_btTwoScore.ShowWindow(pLandScore->bCurrentScore<=1?SW_SHOW:SW_HIDE); m_GameClientView.m_btThreeScore.ShowWindow(pLandScore->bCurrentScore<=2?SW_SHOW:SW_HIDE); } CString showMsg; showMsg.Format("s %d", pLandScore->bCurrentScore); strTemp.Format("into OnSubLandScore %d", pLandScore->bCurrentScore); theApp.WriteLog(strFile, strTemp); // PlayGameSound(AfxGetInstanceHandle(),TEXT("WA_1")); //AfxMessageBox(showMsg); //叫分声音 int voType = pLandScore->bCurrentScore; PlayJiaoSound( voType); //播放声音 // PlayGameSound(AfxGetInstanceHandle(),TEXT("OUT_CARD")); //设置时间 SetGameTimer(pLandScore->wCurrentUser,IDI_LAND_SCORE,30); return true; }
//操作提示 bool CGameClientDlg::OnSubOperateNotify(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_OperateNotify)); if (wDataSize!=sizeof(CMD_S_OperateNotify)) return false; //变量定义 CMD_S_OperateNotify * pOperateNotify=(CMD_S_OperateNotify *)pBuffer; //用户界面 if ((IsLookonMode()==false)&&(pOperateNotify->cbActionMask!=WIK_NULL)) { //获取变量 WORD wMeChairID=GetMeChairID(); BYTE cbActionMask=pOperateNotify->cbActionMask; BYTE cbActionCard=pOperateNotify->cbActionCard; //变量定义 tagGangCardResult GangCardResult; ZeroMemory(&GangCardResult,sizeof(GangCardResult)); //杠牌判断 if ((cbActionMask&WIK_GANG)!=0) { //桌面杆牌 if ((m_wCurrentUser==INVALID_CHAIR)&&(cbActionCard!=0)) { GangCardResult.cbCardCount=1; GangCardResult.cbCardData[0]=cbActionCard; } //自己杆牌 if ((m_wCurrentUser==wMeChairID)||(cbActionCard==0)) { WORD wMeChairID=GetMeChairID(); m_GameLogic.AnalyseGangCard(m_cbCardIndex,m_WeaveItemArray[wMeChairID],m_cbWeaveCount[wMeChairID],GangCardResult); } } //设置界面 ActiveGameFrame(); m_GameClientView.m_ControlWnd.SetControlInfo(cbActionCard,cbActionMask,GangCardResult); //设置时间 m_GameClientView.SetCurrentUser(INVALID_CHAIR); SetGameTimer(GetMeChairID(),IDI_OPERATE_CARD,TIME_OPERATE_CARD); } return true; }
//发牌结束 LRESULT CGameClientDlg::OnSendFinish(WPARAM wParam,LPARAM lParam) { //控制界面 if ((IsLookonMode()==false)&&(m_wCurrentUser==GetMeChairID())) { ActiveGameFrame(); UpdateScoreControl(); } if(m_wCurrentUser<GAME_PLAYER) { SetGameTimer(m_wCurrentUser,IDI_USER_ADD_SCORE,TIME_USER_ADD_SCORE); } return 0; }
void CClientGameDlg::ReceiveAndShowCards(TSendCards* ptSendCards) { m_vbyCards.clear(); memcpy(m_byCards,ptSendCards->byCards,(int)ptSendCards->byCardCount); //启动叫主定时器 OutputDebugString("chs 启动叫主定时器"); SetGameTimer(m_pGameInfo->pMeUserInfo->GameUserInfo.bDeskStation,15,TIMER_CALLLEVELCARD); m_CardCounts = ptSendCards->byCardCount; //设置要显示的牌的张数 // 保存牌数据 for(int i = 0;i<ptSendCards->byCardCount;++i) { m_vbyCards.push_back(ptSendCards->byCards[i]); } }
//设置游戏状态 bool CClientGameDlg::SetGameStation(void * pStationData, UINT uDataSize) { OutputDebugString("liuwen::设置游戏状态"); switch (GetStationParameter()) { case GS_WAIT_SETGAME: //游戏没有开始状态 case GS_WAIT_ARGEE: case GS_WAIT_NEXT: //等待下一盘开始 { SetGameTimer(m_pGameInfo->pMeUserInfo->GameUserInfo.bDeskStation,GenerateRand(3),TIMER_GETREADY); return true; } } return false; }
//游戏开始 bool CGameClientDlg::OnSubGameStart(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_SendCard)); if (wDataSize!=sizeof(CMD_S_SendCard)) return false; //消息处理 CMD_S_SendCard * pGameStart=(CMD_S_SendCard *)pBuffer; //设置变量 m_bTurnCardCount=0; m_bTurnOutType=CT_INVALID; ZeroMemory(m_bTurnCardData,sizeof(m_bTurnCardData)); //设置界面 m_GameClientView.SetCardCount(SwitchViewChairID(pGameStart->wCurrentEnthronement),m_bCardCount[pGameStart->wCurrentEnthronement]); ////地主设置 //if (pGameStart->wCurrentEnthronement==GetMeChairID()) //{ // m_GameClientView.m_HandCardControl.SetCardData(m_bHandCardData,m_bHandCardCount); //} //玩家设置 if (IsLookonMode()==false) m_GameClientView.m_HandCardControl.SetPositively(true); //当前玩家 if ((IsLookonMode()==false)&&(pGameStart->wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btOutCard.EnableWindow(FALSE); m_GameClientView.m_btOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.EnableWindow(FALSE); m_GameClientView.m_btPassCard.ShowWindow(SW_SHOW); m_GameClientView.m_btAutoOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btAutoOutCard.EnableWindow(FALSE); } // m_GameClientView.m_LeaveCardControl[0].SetBackCard(m_bCardCount[0]);//.SetCardData(m_GameClientView.m_byZerodata,m_bCardCount[0]); // m_GameClientView.m_LeaveCardControl[1].SetBackCard(m_bCardCount[1]);//.SetCardData(m_GameClientView.m_byZerodata,m_bCardCount[1]); //播放声音 PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START")); //设置时间 SetGameTimer(pGameStart->wCurrentUser,IDI_OUT_CARD,30); m_GameClientView.m_bGamePlaying = true; return true; }
//开始倒计 LRESULT CGameClientDlg::OnStartTimes(WPARAM wParam,LPARAM lParam) { //隐藏控件 m_GameClientView.m_btOpenCard.ShowWindow(SW_HIDE); if(m_bAutoStart!=TRUE) { SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_START_GAME); } else //自动开始 { OnStart(0,0); } return 0; }
//======================================================================================== // 功能 : 前面已经有人大了 // 参数 : BYTE byCardType [in] 当前最大的牌类型 //======================================================================================== void CClientGameDlg::HaveSetBigNote(BYTE byCardType) { int iRand = rand()%100; if(byCardType >= ZX_HE_PAI) //丁皇,天,地,人,和 { if(iRand < 50) //跟 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_FOLLOW_TIME); } if(iRand < 85) //大 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_BIG_TIME); } else //敲 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_SET_ALL_TIME); } } else if(byCardType >= ZX_DI_GANG) //地杠 { if(iRand < 50) //大 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_BIG_TIME); } else //跟 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_FOLLOW_TIME); } } else //散牌 { if(iRand < 60) //大 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_BIG_TIME); } else if(iRand < 90) //跟 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_FOLLOW_TIME); } else //丢 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 3 +2,ID_GIVE_UP_TIME); } } }
void CClientGameDlg::GameStationProc(TGameStation& tGameStation) { BYTE byGameStation = tGameStation.byGameStation; switch(byGameStation) { case GS_WAIT_ARGEE: { SetGameTimer(m_pGameInfo->pMeUserInfo->GameUserInfo.bDeskStation,GenerateRand(10),TIMER_GETREADY); } break; default: { } break; } }
//======================================================================================== // 功能 : 还没有人操作时机器人的操作 // 参数 : BYTE byCardType [in] 当前最大的牌类型 //======================================================================================== void CClientGameDlg::NoOneOperator(BYTE byCardType) //可操作的有 敲,大,休,丢 { int iRand = rand()%100; if(byCardType >= ZX_HE_PAI) //丁皇,天,地,人,和 { if(iRand < 60) //大 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BIG_TIME); } else //敲 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME); } } else if(byCardType >= ZX_DI_GANG) //地杠 { if(iRand < 60) //大 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BIG_TIME); } else if(iRand < 85) //休 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_STOP_TIME); } else //敲 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_SET_ALL_TIME); } } else //散牌 { if(iRand < 60) //大 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_BIG_TIME); } else if(iRand < 90) //休 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_STOP_TIME); } else //丢 { SetGameTimer(GetMeUserInfo()->bDeskStation,MyRand()% 6 +2,ID_GIVE_UP_TIME); } } }
//发牌完成 LRESULT CGameClientDlg::OnSendCardFinish(WPARAM wParam, LPARAM lParam) { //状态判断 if (m_wCurrentUser==INVALID_CHAIR) return 0; //加注状态 if ((IsLookonMode()==false)&&(GetMeChairID()==m_wCurrentUser)) { //界面设置 ActiveGameFrame(); UpdateScoreControl(); } //设置时间 SetGameTimer(m_wCurrentUser,IDI_USER_ADD_SCORE,TIME_USER_ADD_SCORE); return 0; }
//游戏开始 bool CGameClientDlg::OnSubGameStart(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_GameStart)); if (wDataSize!=sizeof(CMD_S_GameStart)) return false; //消息处理 CMD_S_GameStart * pGameStart=(CMD_S_GameStart *)pBuffer; //庄家信息 SetBankerInfo(pGameStart->wBankerUser,pGameStart->lBankerScore); //玩家信息 m_lMeMaxScore=pGameStart->lUserMaxScore; m_GameClientView.SetMeMaxScore(m_lMeMaxScore); m_lAreaLimitScore = pGameStart->lAreaLimitScore; m_GameClientView.SetAreaLimitScore(m_lAreaLimitScore); //设置时间 SetGameTimer(GetMeChairID(),IDI_PLACE_JETTON,pGameStart->cbTimeLeave); //设置空闲状态 m_GameClientView.SetFreeTime(); //设置状态 SetGameStatus(GS_PLACE_JETTON); //更新控制 UpdateButtonContron(); //更新界面 m_GameClientView.UpdateGameView(NULL); //播放声音 if (IsEnableSound()) { PlayGameSound(GAME_START); m_DTSDBackground.Play(0,true); } return true; }
//用户扣牌 bool CGameClientDlg::OnSubKouPai(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_User_CouPai)); if (wDataSize!=sizeof(CMD_S_User_CouPai)) return false; //消息处理 CMD_S_User_CouPai * pCouPai=(CMD_S_User_CouPai *)pBuffer; m_GameClientView.ShowKouPaiTitle(SW_NORMAL,SwitchViewChairID(pCouPai->wCouPaiUserID)); if(pCouPai->wCurrentUser==GetMeChairID()) { ActiveGameFrame(); m_GameClientView.m_btKouPai.EnableWindow(true); m_GameClientView.m_btXianPai.EnableWindow(true); } //设置定时器 KillGameTimer(IDI_OUT_CARD); SetGameTimer(pCouPai->wCurrentUser,IDI_KOU_CARD,10); return true; }
//定时器消息 bool CServerGameDesk::OnTimer(UINT uTimerID) { DebugPrintf("定时器 ID=【%d】",uTimerID); switch(uTimerID) { case TIME_WAIT_THINK: //等待进入游戏状态 { KillTimer(TIME_WAIT_THINK); m_bGameStation = GS_PLAY_GAME; //游戏中状态 SetGameTimer(TIME_THINK,m_byTTime,true); break; } case TIME_THINK: //摆牌思考时间 { m_iSurplusTime--; if(m_iSurplusTime<= 0) { KillTimer(TIME_THINK); for(int i = 0; i < PLAY_COUNT; ++i) { AutoTanPai(i); //时间到了自动摆牌 } } break; } default:break; } return __super::OnTimer(uTimerID); }
//游戏结束 bool CGameClientDlg::OnSubGameEnd(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_GameEnd)); if (wDataSize!=sizeof(CMD_S_GameEnd)) return false; //消息处理 CMD_S_GameEnd * pGameEnd=(CMD_S_GameEnd *)pBuffer; //设置状态 SetGameStatus(GS_RF_FREE); //删除定时器 KillTimer(IDI_MOST_CARD); KillGameTimer(IDI_OUT_CARD); //隐藏控件 m_GameClientView.m_btOutCard.ShowWindow(SW_HIDE); m_GameClientView.m_btPassCard.ShowWindow(SW_HIDE); m_GameClientView.m_btOutPrompt.ShowWindow(SW_HIDE); //禁用控件 m_GameClientView.m_btOutCard.EnableWindow(FALSE); m_GameClientView.m_btPassCard.EnableWindow(FALSE); m_GameClientView.m_btOutPrompt.EnableWindow(FALSE); //设置积分 for (WORD i=0;i<GAME_PLAYER;i++) { const tagUserData * pUserData=GetUserData(i); m_GameClientView.m_ScoreView.SetGameScore(i,pUserData->szName,pGameEnd->lGameScore[i]); m_GameClientView.m_lAllTurnScore[SwitchViewChairID(i)]+=pGameEnd->lGameScore[i]; m_GameClientView.m_lLastTurnScore[SwitchViewChairID(i)]=pGameEnd->lGameScore[i]; } m_GameClientView.m_ScoreView.SetTax(pGameEnd->lGameTax); m_GameClientView.m_ScoreView.ShowWindow(SW_SHOW); //设置扑克 BYTE bCardPos=0; for (WORD i=0;i<GAME_PLAYER;i++) { //设置扑克 WORD wViewChairID=SwitchViewChairID(i); if (wViewChairID!=2) { if (wViewChairID>2) m_GameClientView.m_LeaveCardControl[wViewChairID-1].SetCardData(&pGameEnd->bCardData[bCardPos],pGameEnd->bCardCount[i]); else m_GameClientView.m_LeaveCardControl[wViewChairID].SetCardData(&pGameEnd->bCardData[bCardPos],pGameEnd->bCardCount[i]); } //界面设置 bCardPos+=pGameEnd->bCardCount[i]; if (pGameEnd->bCardCount[i]!=0) { m_GameClientView.SetPassFlag(wViewChairID,false); m_GameClientView.m_UserCardControl[wViewChairID].SetCardData(NULL,0); } } //显示扑克 if (IsLookonMode()==true) m_GameClientView.m_HandCardControl.SetDisplayFlag(true); //播放声音 WORD wMeChairID=GetMeChairID(); LONG lMeScore=pGameEnd->lGameScore[GetMeChairID()]; if (lMeScore>0L) PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_WIN")); else if (lMeScore<0L) PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_LOST")); else PlayGameSound(GetModuleHandle(NULL),TEXT("GAME_END")); //设置界面 if (IsLookonMode()==false) { m_GameClientView.m_btStart.ShowWindow(SW_SHOW); SetGameTimer(GetMeChairID(),IDI_START_GAME,90); } return true; }
//用户出牌 bool CGameClientDlg::OnSubOutCard(const void * pBuffer, WORD wDataSize) { //变量定义 CMD_S_OutCard * pOutCard=(CMD_S_OutCard *)pBuffer; WORD wHeadSize=sizeof(CMD_S_OutCard)-sizeof(pOutCard->bCardData); //效验数据 ASSERT(wDataSize>=wHeadSize); if (wDataSize<wHeadSize) return false; ASSERT(wDataSize==(wHeadSize+pOutCard->bCardCount*sizeof(pOutCard->bCardData[0]))); if (wDataSize!=(wHeadSize+pOutCard->bCardCount*sizeof(pOutCard->bCardData[0]))) return false; //删除定时器 KillTimer(IDI_MOST_CARD); KillGameTimer(IDI_OUT_CARD); //界面设置 WORD wOutViewChairID=SwitchViewChairID(pOutCard->wOutCardUser); m_bCardCount[pOutCard->wOutCardUser]-=pOutCard->bCardCount; m_GameClientView.SetCardCount(wOutViewChairID,m_bCardCount[pOutCard->wOutCardUser]); //出牌设置 if ((IsLookonMode()==true)||(GetMeChairID()!=pOutCard->wOutCardUser)) { m_GameClientView.m_UserCardControl[wOutViewChairID].SetCardData(pOutCard->bCardData,pOutCard->bCardCount); } //清理桌面 if (m_bTurnCardCount==0) { for (WORD i=0;i<GAME_PLAYER;i++) { if (i==pOutCard->wOutCardUser) continue; m_GameClientView.m_UserCardControl[SwitchViewChairID(i)].SetCardData(NULL,0); } m_GameClientView.SetPassFlag(INVALID_CHAIR,false); } //记录出牌 m_bTurnCardCount=pOutCard->bCardCount; m_bTurnOutType=m_GameLogic.GetCardType(pOutCard->bCardData,pOutCard->bCardCount); CopyMemory(m_bTurnCardData,pOutCard->bCardData,sizeof(BYTE)*pOutCard->bCardCount); //自己扑克 if ((IsLookonMode()==true)&&(pOutCard->wOutCardUser==GetMeChairID())) { //删除扑克 BYTE bSourceCount=m_bHandCardCount; m_bHandCardCount-=pOutCard->bCardCount; m_GameLogic.RemoveCard(pOutCard->bCardData,pOutCard->bCardCount,m_bHandCardData,bSourceCount); //设置界面 m_GameClientView.m_HandCardControl.SetCardData(m_bHandCardData,m_bHandCardCount); } //最大判断 if (pOutCard->wCurrentUser==pOutCard->wOutCardUser) { //设置变量 m_bTurnCardCount=0; m_bTurnOutType=CT_ERROR; m_wMostUser=pOutCard->wCurrentUser; memset(m_bTurnCardData,0,sizeof(m_bTurnCardData)); //设置界面 for (WORD i=0;i<GAME_PLAYER;i++) { if (i!=pOutCard->wOutCardUser) { WORD wViewChairID=SwitchViewChairID(i); m_GameClientView.SetPassFlag(wViewChairID,true); m_GameClientView.m_UserCardControl[wViewChairID].SetCardData(NULL,0); } } //环境设置 SetTimer(IDI_MOST_CARD,3000,NULL); PlayGameSound(AfxGetInstanceHandle(),TEXT("MOST_CARD")); return true; } //播放声音 if ((IsLookonMode()==true)||(GetMeChairID()!=pOutCard->wOutCardUser)) PlayGameSound(AfxGetInstanceHandle(),TEXT("OUT_CARD")); //玩家设置 if (pOutCard->wCurrentUser!=INVALID_CHAIR) { WORD wViewChairID=SwitchViewChairID(pOutCard->wCurrentUser); m_GameClientView.SetPassFlag(wViewChairID,false); m_GameClientView.m_UserCardControl[wViewChairID].SetCardData(NULL,0); } //玩家设置 if ((IsLookonMode()==false)&&(pOutCard->wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btPassCard.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.EnableWindow(TRUE); m_GameClientView.m_btOutPrompt.ShowWindow(SW_SHOW); m_GameClientView.m_btOutPrompt.EnableWindow(TRUE); m_GameClientView.m_btOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btOutCard.EnableWindow((VerdictOutCard()==true)?TRUE:FALSE); } //设置定时器 if (pOutCard->wCurrentUser!=INVALID_CHAIR) { WORD wTimeCount=30; if (m_GameClientView.m_btPassCard.IsWindowEnabled()) wTimeCount=10; SetGameTimer(pOutCard->wCurrentUser,IDI_OUT_CARD,wTimeCount); } return true; }
//游戏开始 bool CGameClientDlg::OnSubGameStart(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_GameStart)); if (wDataSize!=sizeof(CMD_S_GameStart)) return false; //消息处理 CMD_S_GameStart * pGameStart=(CMD_S_GameStart *)pBuffer; //设置变量 m_bTurnCardCount=0; m_bTurnOutType=CT_ERROR; m_wBankerUser=pGameStart->wBankerUser; memset(m_bTurnCardData,0,sizeof(m_bTurnCardData)); //设置界面 for (WORD i=0;i<GAME_PLAYER;i++) { m_GameClientView.SetPassFlag(i,false); m_GameClientView.m_UserCardControl[i].SetCardData(NULL,0); } if (IsLookonMode()==true) { m_GameClientView.m_ScoreView.ShowWindow(SW_HIDE); m_GameClientView.m_LeaveCardControl[0].SetCardData(NULL,0); m_GameClientView.m_LeaveCardControl[1].SetCardData(NULL,0); m_GameClientView.m_LeaveCardControl[2].SetCardData(NULL,0); } //设置扑克 m_bHandCardCount=CountArray(pGameStart->cbCardData); CopyMemory(m_bHandCardData,pGameStart->cbCardData,sizeof(pGameStart->cbCardData)); m_GameClientView.m_HandCardControl.SetCardData(pGameStart->cbCardData,m_bHandCardCount); //扑克数目 for (WORD i=0;i<GAME_PLAYER;i++) { m_bCardCount[i]=CountArray(pGameStart->cbCardData); m_GameClientView.SetCardCount(SwitchViewChairID(i),m_bCardCount[i]); } //控制设置 bool bPlayerMode=(IsLookonMode()==false); m_GameClientView.m_HandCardControl.SetPositively(bPlayerMode); m_GameClientView.m_HandCardControl.SetDisplayFlag(bPlayerMode); //当前玩家 if ((IsLookonMode()==false)&&(pGameStart->wCurrentUser==GetMeChairID())) { ActiveGameFrame(); m_GameClientView.m_btOutCard.ShowWindow(SW_SHOW); m_GameClientView.m_btOutCard.EnableWindow(FALSE); m_GameClientView.m_btPassCard.ShowWindow(SW_SHOW); m_GameClientView.m_btPassCard.EnableWindow(FALSE); m_GameClientView.m_btOutPrompt.ShowWindow(SW_SHOW); m_GameClientView.m_btOutPrompt.EnableWindow(FALSE); } ////检测全大全小 //for (WORD i=0;i<GAME_PLAYER;i++) //{ // if( m_GameLogic.IsAllSmall(m_bHandCardData,m_bCardCount[i]) ) // { // MessageBox("全小","",MB_OK); // } //} //for (WORD i=0;i<GAME_PLAYER;i++) //{ // if( m_GameLogic.IsAllBig(m_bHandCardData,m_bCardCount[i]) ) // { // MessageBox("全大","",MB_OK); // } //} //设置定时器 WORD wTimeCount=30; if (pGameStart->wCurrentUser!=INVALID_CHAIR) SetGameTimer(pGameStart->wCurrentUser,IDI_OUT_CARD,wTimeCount); //环境设置 PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START")); return true; }