//游戏空闲 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::OnSubGiveUp(const void * pBuffer, WORD wDataSize) { //效验数据 if (wDataSize!=sizeof(CMD_S_GiveUp)) return false; CMD_S_GiveUp * pGiveUp=(CMD_S_GiveUp *)pBuffer; //设置变量 m_cbPlayStatus[pGiveUp->wGiveUpUser]=FALSE; //变量定义 WORD wGiveUpUser=pGiveUp->wGiveUpUser; BYTE cbCardData[MAX_COUNT]={0,0,0,0,0}; WORD wViewChairID=SwitchViewChairID(wGiveUpUser); BYTE cbCardCount=(BYTE)m_GameClientView.m_CardControl[wViewChairID].GetCardCount(); //设置扑克 m_GameClientView.m_CardControl[wViewChairID].SetPositively(false); m_GameClientView.m_CardControl[wViewChairID].SetDisplayHead(false); m_GameClientView.m_CardControl[wViewChairID].SetCardData(cbCardData,cbCardCount); //状态设置 if ((IsLookonMode()==false)&&(pGiveUp->wGiveUpUser==GetMeChairID())) { HideScoreControl(); SetGameStatus(GS_FREE); } //环境设置 if (wGiveUpUser==GetTimeChairID()) KillGameTimer(IDI_USER_ADD_SCORE); if ((IsLookonMode()==true)||(wGiveUpUser!=GetMeChairID())) PlayGameSound(AfxGetInstanceHandle(),TEXT("GIVE_UP")); return true; }
//游戏空闲 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; }
//游戏开始 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::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_MJ_FREE); m_GameClientView.SetStatusFlag(false,false); //删除定时器 KillGameTimer(IDI_OPERATE_CARD); //设置控件 m_GameClientView.SetStatusFlag(false,false); m_GameClientView.m_ControlWnd.ShowWindow(SW_HIDE); m_GameClientView.m_HandCardControl.SetPositively(false); ////结束设置 荒庄 //if (pGameEnd->cbChiHuCard==0) //{ // DeductionTableCard(true); // m_GameClientView.SetHuangZhuang(true); //} //设置扑克 for (WORD i=0;i<GAME_PLAYER;i++) { m_GameClientView.m_WeaveCard[i][0].SetDisplayItem(true); m_GameClientView.m_WeaveCard[i][1].SetDisplayItem(true); m_GameClientView.m_WeaveCard[i][2].SetDisplayItem(true); m_GameClientView.m_WeaveCard[i][3].SetDisplayItem(true); } //变量定义 tagScoreInfo ScoreInfo; tagWeaveInfo WeaveInfo; ZeroMemory(&ScoreInfo,sizeof(ScoreInfo)); ZeroMemory(&WeaveInfo,sizeof(WeaveInfo)); //成绩变量 ScoreInfo.wBankerUser=m_wBankerUser; ScoreInfo.wProvideUser=pGameEnd->wProvideUser; ScoreInfo.cbProvideCard=pGameEnd->cbProvideCard; //设置积分 CString strTemp ,strEnd = "\n"; for (WORD i=0;i<GAME_PLAYER;i++) { const tagUserData * pUserData=GetUserData(i); //胡牌类型 ScoreInfo.dwChiHuKind[i]=pGameEnd->dwChiHuKind[i]; ScoreInfo.dwChiHuRight[i]=pGameEnd->dwChiHuRight[i]; //设置成绩 ScoreInfo.lGameScore[i]=pGameEnd->lGameScore[i]; lstrcpyn(ScoreInfo.szUserName[i],pUserData->szName,CountArray(ScoreInfo.szUserName[i])); if(pGameEnd->lGameScore[i]>0) strTemp.Format("%s: %+ld\n",pUserData->szName,pGameEnd->lGameScore[i]); else strTemp.Format("%s: %ld\n",pUserData->szName,pGameEnd->lGameScore[i]); strEnd += strTemp; //胡牌扑克 if ((ScoreInfo.cbCardCount==0)&&(pGameEnd->dwChiHuKind[i]!=CHK_NULL)) { //组合扑克 WeaveInfo.cbWeaveCount=m_cbWeaveCount[i]; for (BYTE j=0;j<WeaveInfo.cbWeaveCount;j++) { BYTE cbWeaveKind=m_WeaveItemArray[i][j].cbWeaveKind; BYTE cbCenterCard=m_WeaveItemArray[i][j].cbCenterCard; WeaveInfo.cbPublicWeave[j]=m_WeaveItemArray[i][j].cbPublicCard; WeaveInfo.cbCardCount[j]=m_GameLogic.GetWeaveCard(cbWeaveKind,cbCenterCard,WeaveInfo.cbCardData[j]); } //设置扑克 ScoreInfo.cbCardCount=pGameEnd->cbCardCount[i]; CopyMemory(ScoreInfo.cbCardData,&pGameEnd->cbCardData[i],ScoreInfo.cbCardCount*sizeof(BYTE)); //提取胡牌 for (BYTE j=0;j<ScoreInfo.cbCardCount;j++) { if (ScoreInfo.cbCardData[j]==pGameEnd->cbProvideCard) { MoveMemory(&ScoreInfo.cbCardData[j],&ScoreInfo.cbCardData[j+1],(ScoreInfo.cbCardCount-j-1)*sizeof(BYTE)); ScoreInfo.cbCardData[ScoreInfo.cbCardCount-1]=pGameEnd->cbProvideCard; break; } } } } //消息积分 InsertSystemString((LPCTSTR)strEnd); //成绩界面 m_GameClientView.m_ScoreControl.SetScoreInfo(ScoreInfo,WeaveInfo); //用户扑克 for (WORD i=0;i<GAME_PLAYER;i++) { WORD wViewChairID=SwitchViewChairID(i); if (pGameEnd->dwChiHuKind[i]!=CHK_NULL) m_GameClientView.SetUserAction(wViewChairID,WIK_CHI_HU); m_GameClientView.m_TableCard[wViewChairID].SetCardData(pGameEnd->cbCardData[i],pGameEnd->cbCardCount[i]); } //设置扑克 m_GameClientView.m_UserCard[0].SetCardData(0,false); m_GameClientView.m_UserCard[1].SetCardData(0,false); m_GameClientView.m_UserCard[2].SetCardData(0,false); m_GameClientView.m_HandCardControl.SetCardData(NULL,0,0); //播放声音 //播放声音 LONG lScore=pGameEnd->lGameScore[GetMeChairID()]; if (lScore>0L) { PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_WIN")); } else if (lScore<0L) { PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_LOST")); } else { PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_END")); } //设置界面 if (IsLookonMode()==false) { m_GameClientView.m_btStart.ShowWindow(SW_SHOW); m_GameClientView.SetCurrentUser(INVALID_CHAIR); SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_START_GAME); } //取消托管 if(m_bStustee) OnStusteeControl(0,0); //更新界面 m_GameClientView.UpdateGameView(NULL); return true; }
//游戏开始 bool CGameClientDlg::OnSubGameStart(const void * pBuffer, WORD wDataSize) { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_GameStart)); if (wDataSize!=sizeof(CMD_S_GameStart)) return false; m_GameClientView.SetCenterCount(); //设置状态 SetGameStatus(GS_PLAYING); //旁观玩家 if(IsLookonMode()) { //清理界面 m_GameClientView.SetGameEndEnd(); m_GameClientView.m_ScoreView.ShowWindow(SW_HIDE); m_GameClientView.m_btStart.ShowWindow(SW_HIDE); m_GameClientView.m_btExit.ShowWindow(SW_HIDE); m_GameClientView.m_ScoreView.SetStartTimes(false); ZeroMemory(m_cbHandCardData,sizeof(m_cbHandCardData)); ZeroMemory(m_cbCenterCardData,sizeof(m_cbCenterCardData)); ZeroMemory(m_cbPlayStatus,sizeof(m_cbPlayStatus)); ZeroMemory(m_lTableScore,sizeof(m_lTableScore)); for (WORD i = 0;i<GAME_PLAYER;i++) { m_GameClientView.SetUserTableScore(i,m_lTableScore[i]); m_GameClientView.SetTotalScore(i,0L); m_GameClientView.m_SmallCardControl[i].SetCardData(NULL,0); m_GameClientView.m_CardControl[i].SetCardData(NULL,0); } m_GameClientView.m_CenterCardControl.SetCardData(NULL,0); m_GameClientView.SetDFlag(INVALID_CHAIR); m_GameClientView.SetCenterScore(0L); m_lCenterScore = 0L; m_lCellScore = 0L; } //消息处理 CMD_S_GameStart * pGameStart=(CMD_S_GameStart *)pBuffer; //设置变量 m_wDUser = pGameStart->wDUser; m_wCurrentUser = pGameStart->wCurrentUser; m_lAddLessScore = pGameStart->lAddLessScore; m_lTurnLessScore = pGameStart->lTurnLessScore; m_lTurnMaxScore = pGameStart->lTurnMaxScore; m_lCellScore = pGameStart->lCellScore; //用户状态 for (WORD i=0;i<GAME_PLAYER;i++) { //获取用户 const tagUserData * pUserData=GetUserData(i); if (pUserData!=NULL) { //游戏信息 //m_GameClientView.SetUserIdInfo(i,pUserData); m_cbPlayStatus[i]=TRUE; } else { //m_GameClientView.SetUserIdInfo(i,NULL); m_cbPlayStatus[i]=FALSE; } } //环境设置 PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START")); //加注信息 m_lTableScore[pGameStart->wDUser] += m_lCellScore; m_lTableScore[pGameStart->wMaxChipInUser] = 2*m_lCellScore; m_lTotalScore[pGameStart->wDUser] = m_lCellScore; m_lTotalScore[pGameStart->wMaxChipInUser] = 2*m_lCellScore; //设置界面 m_GameClientView.SetDFlag(m_wDUser); m_GameClientView.DrawMoveAnte(pGameStart->wDUser,CGameClientView::AA_BASEFROM_TO_BASEDEST,m_lTotalScore[pGameStart->wDUser]); m_GameClientView.DrawMoveAnte(pGameStart->wMaxChipInUser,CGameClientView::AA_BASEFROM_TO_BASEDEST,m_lTotalScore[pGameStart->wMaxChipInUser]); m_GameClientView.SetTotalScore(pGameStart->wDUser,m_lTotalScore[pGameStart->wDUser]); m_GameClientView.SetTotalScore(pGameStart->wMaxChipInUser,m_lTotalScore[pGameStart->wMaxChipInUser]); //发送暗牌 CopyMemory(m_cbHandCardData,pGameStart->cbCardData,sizeof(m_cbHandCardData)); for (BYTE j = 0;j<2;j++) { for (WORD i=0;i<GAME_PLAYER;i++) { if (m_cbPlayStatus[i]==TRUE) { if(GetMeChairID()==i) { m_GameClientView.DrawMoveCard(i,TO_USERCARD,m_cbHandCardData[i][j]); } else { m_GameClientView.DrawMoveCard(i,TO_USERCARD,0); } } } } ////控件设置 //if ((IsLookonMode()==false)&&(m_wCurrentUser==GetMeChairID())) //{ // ActiveGameFrame(); // UpdateScoreControl(); //} //SetGameTimer(m_wCurrentUser,IDI_USER_ADD_SCORE,TIME_USER_ADD_SCORE); return true; }
//游戏结束 LRESULT CGameClientDlg::OnGameOver(WPARAM wParam,LPARAM lParam) { //设置状态 SetGameStatus(GS_FREE); if(!m_bExitTag) { if(m_cbPlayStatus[m_wMeChairID] == TRUE) m_GameClientView.m_CardControl[m_wMeChairID].SetCardData(m_cbHandCardData[m_wMeChairID],2); } else { //胜利列表 UserWinList WinnerList; //临时数据 BYTE bTempData[GAME_PLAYER][MAX_CENTERCOUNT]; CopyMemory(bTempData,m_cbOverCardData,GAME_PLAYER*MAX_CENTERCOUNT); //查找胜利者 m_GameLogic.SelectMaxUser(bTempData,WinnerList,NULL); ASSERT(WinnerList.bSameCount>0); //设置扑克 for (WORD i = 0;i<GAME_PLAYER;i++) { if(m_cbPlayStatus[i] == TRUE) m_GameClientView.m_CardControl[i].SetCardData(m_cbHandCardData[i],2); else m_GameClientView.m_CardControl[i].SetCardData(NULL,0); } //特效变量 bool wIsMyWin =false ; WORD wWinnerID = INVALID_CHAIR; BYTE cbEffectHandCard[MAX_COUNT]; BYTE cbEffectCenterCardData[MAX_CENTERCOUNT]; ZeroMemory(cbEffectHandCard,sizeof(cbEffectHandCard)); ZeroMemory(cbEffectCenterCardData,sizeof(cbEffectCenterCardData)); BYTE bTempCount1,bTempCount2; //查找胜利扑克 for (WORD i=0;i<WinnerList.bSameCount;i++) { wWinnerID=WinnerList.wWinerList[i]; if(!wIsMyWin && m_wMeChairID==WinnerList.wWinerList[i]) { wIsMyWin = true; } //查找扑克数据 BYTE bTempCount1=m_GameLogic.GetSameCard(m_cbHandCardData[wWinnerID],bTempData[wWinnerID],MAX_COUNT,MAX_CENTERCOUNT,cbEffectHandCard); BYTE bTempCount2=m_GameLogic.GetSameCard(m_cbCenterCardData,bTempData[wWinnerID],MAX_CENTERCOUNT,MAX_CENTERCOUNT,cbEffectCenterCardData); ASSERT(bTempCount1+bTempCount2<=MAX_CENTERCOUNT); //设置扑克特效数据 m_GameClientView.m_CardControl[wWinnerID].SetCardEffect(cbEffectHandCard,bTempCount1); m_GameClientView.m_CenterCardControl.SetCardEffect(cbEffectCenterCardData,bTempCount2); } //自己扑克 if(!wIsMyWin) { wWinnerID = m_wMeChairID; //自己扑克数据 ZeroMemory(cbEffectHandCard,sizeof(cbEffectHandCard)); ZeroMemory(cbEffectCenterCardData,sizeof(cbEffectCenterCardData)); //查找扑克数据 bTempCount1=m_GameLogic.GetSameCard(m_cbHandCardData[wWinnerID],bTempData[wWinnerID],MAX_COUNT,MAX_CENTERCOUNT,cbEffectHandCard); bTempCount2=m_GameLogic.GetSameCard(m_cbCenterCardData,bTempData[wWinnerID],MAX_CENTERCOUNT,MAX_CENTERCOUNT,cbEffectCenterCardData); ASSERT(bTempCount1+bTempCount2<=MAX_CENTERCOUNT); //设置标志扑克数据 m_GameClientView.m_CardControl[wWinnerID].SetMyCard(cbEffectHandCard,bTempCount1); m_GameClientView.m_CenterCardControl.SetMyCard(cbEffectCenterCardData,bTempCount2); } //游戏结束 m_GameClientView.SetGameEndStart(); } //赢金币 for (WORD i =0;i<GAME_PLAYER;i++) { if(m_cbPlayStatus[i] == FALSE) continue; if(m_dEndScore[i]>0L) { m_lCenterScore = m_lCenterScore -m_dEndScore[i]-m_lTotalScore[i]; m_GameClientView.UpdateWindow(); m_GameClientView.DrawMoveAnte(i,CGameClientView::AA_CENTER_TO_BASEFROM,m_dEndScore[i]+m_lTotalScore[i]); m_GameClientView.SetCenterScore(m_lCenterScore); } else if(m_dEndScore[i] == 0L) { m_GameClientView.DrawMoveAnte(i,CGameClientView::AA_CENTER_TO_BASEFROM,m_lTotalScore[i]); m_lCenterScore = m_lCenterScore-m_lTotalScore[i]; m_GameClientView.SetCenterScore(m_lCenterScore); m_GameClientView.UpdateWindow(); } m_GameClientView.SetTotalScore(i,0L); m_GameClientView.UpdateWindow(); } //播放声音 if (IsLookonMode()==false) { if (m_dEndScore[m_wMeChairID]>=0L) PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_WIN")); else PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_LOST")); } else PlayGameSound(GetModuleHandle(NULL),TEXT("GAME_END")); if(m_cbPlayStatus[m_wMeChairID]==TRUE && !IsLookonMode()) { //调整位置 CRect rcControl; m_GameClientView.m_ScoreView.GetWindowRect(&rcControl); CRect rcView ; m_GameClientView.GetWindowRect( &rcView ); m_GameClientView.m_ScoreView.MoveWindow(rcView.left+5,rcView.bottom-15-rcControl.Height()*3/2,rcControl.Width(),rcControl.Height()/*nWidth/2-rcControl.Width()/2,nHeight/2+56,0,0,SWP_NOZORDER|SWP_NOSIZE*/); m_GameClientView.m_ScoreView.SetGameScore(m_wMeChairID,m_dEndScore[m_wMeChairID]); m_GameClientView.m_ScoreView.ShowWindow(SW_SHOW); m_GameClientView.m_ScoreView.SetShowTimes(); } if(!IsLookonMode()) { //开牌按钮 if(m_bOpenCard) { m_GameClientView.m_btOpenCard.ShowWindow(SW_SHOW); } if (m_GameClientView.m_ScoreView.IsWindowVisible()==TRUE) { m_GameClientView.m_ScoreView.SetStartTimes(); } else if(m_bAutoStart==FALSE) { SetGameTimer(m_wMeChairID,IDI_START_GAME,TIME_START_GAME); } else //自动开始 { m_GameClientView.m_ScoreView.SetStartTimes(); m_GameClientView.m_ScoreView.SetShowTimes(); //OnStart(0,0); } } //状态设置 KillGameTimer(IDI_USER_ADD_SCORE); //开始按钮 if (!IsLookonMode() && m_bAutoStart==FALSE) { m_GameClientView.m_btStart.ShowWindow(SW_SHOW); m_GameClientView.m_btExit.ShowWindow(SW_SHOW); } //成绩显示在即时聊天对话框 TCHAR szBuffer[256]=TEXT(""); _snprintf(szBuffer,CountArray(szBuffer),TEXT("\n本局结束,成绩统计")); InsertGeneralString(szBuffer,RGB(0,128,255),true); if(m_bReset) { for (WORD i=0;i<GAME_PLAYER;i++) { if(m_lTotalScore[i]==0)continue; const tagUserData * pUserData=GetUserData(i); //成绩输出 if (pUserData!=NULL) { _snprintf(szBuffer,CountArray(szBuffer),TEXT("%s:%+ld"),/*%s玩家\n得分:%ld*/ pUserData->szName,m_dEndScore[i]); InsertGeneralString(szBuffer,RGB(0,128,255),true); } else { _snprintf(szBuffer,CountArray(szBuffer),TEXT("用户已离开:%+ld"),-m_lTotalScore[i]);/*\n得分:%ld*/ InsertGeneralString(szBuffer,RGB(0,128,255),true); } } } else //不足金额 { for (WORD i=0;i<GAME_PLAYER;i++) { if(m_lTotalScore[i]==0)continue; //成绩输出 if (m_bUserName[i]!=NULL) { _snprintf(szBuffer,CountArray(szBuffer),TEXT("%s:%+ld"), &m_bUserName[i],m_dEndScore[i]); InsertGeneralString(szBuffer,RGB(0,128,255),true); } else { _snprintf(szBuffer,CountArray(szBuffer),TEXT("用户已离开:%+ld"),-m_lTotalScore[i]); InsertGeneralString(szBuffer,RGB(0,128,255),true); } } } //重值变量 ZeroMemory(m_lTotalScore,sizeof(m_lTotalScore)); ZeroMemory(m_lTableScore,sizeof(m_lTableScore)); m_lCenterScore = 0L; return 0; }
//游戏场景 bool CGameClientDlg::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize) { //显示用户 m_GameClientView.SetShowUserView(TRUE); //物理位置 m_wMeChairID = GetMeChairID(); for(WORD i=0;i<GAME_PLAYER;i++) { m_GameClientView.SetUserPost(i,SwitchViewChairID(i)); m_GameClientView.SetMePost(m_wMeChairID); } switch (cbGameStation) { case GS_FREE: //空闲状态 { //效验数据 if (wDataSize!=sizeof(CMD_S_StatusFree)) return false; CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pBuffer; //设置状态 SetGameStatus(GS_FREE); //下注信息 m_GameClientView.SetTitleInfo(pStatusFree->lCellMinScore,pStatusFree->lCellMaxScore); //设置控件 if (IsLookonMode()==false) { m_GameClientView.m_btStart.ShowWindow(SW_SHOW); m_GameClientView.m_btStart.SetFocus(); m_GameClientView.m_btExit.ShowWindow(SW_SHOW); m_GameClientView.m_btAutoStart.ShowWindow(SW_SHOW); } //设置时间 SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_START_GAME); //旁观设置 OnLookonChanged(bLookonOther,NULL,0); return true; } case GS_PLAYING: //游戏状态 { //效验数据 if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false; CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pBuffer; //设置状态 SetGameStatus(GS_PLAYING); //设置变量 m_wDUser = pStatusPlay->wDUser; m_wCurrentUser=pStatusPlay->wCurrentUser;//当前玩家 CopyMemory(m_lTableScore,pStatusPlay->lTableScore,sizeof(m_lTableScore));//下注数目 CopyMemory(m_lTotalScore,pStatusPlay->lTotalScore,sizeof(m_lTotalScore));//下注数目 CopyMemory(m_cbPlayStatus,pStatusPlay->cbPlayStatus,sizeof(m_cbPlayStatus));//用户游戏状态 //加注信息 m_lAddLessScore = pStatusPlay->lAddLessScore; m_lCellScore = pStatusPlay->lCellScore; m_lTurnMaxScore = pStatusPlay->lTurnMaxScore; m_lTurnLessScore= pStatusPlay->lTurnLessScore; m_lCenterScore = pStatusPlay->lCenterScore; CopyMemory(m_cbHandCardData[GetMeChairID()],pStatusPlay->cbHandCardData,MAX_COUNT); CopyMemory(m_cbCenterCardData,pStatusPlay->cbCenterCardData,sizeof(m_cbCenterCardData)); //设置扑克 if(!IsLookonMode()) { if(m_cbPlayStatus[GetMeChairID()]==TRUE) m_GameClientView.m_CardControl[GetMeChairID()].SetCardData(m_cbHandCardData[GetMeChairID()],MAX_COUNT); m_GameClientView.m_btAutoStart.ShowWindow(SW_SHOW); } //中心扑克 if(pStatusPlay->cbBalanceCount >0) { BYTE cbTempCount = pStatusPlay->cbBalanceCount+2; m_GameClientView.m_CenterCardControl.SetCardData(m_cbCenterCardData,min(cbTempCount,MAX_CENTERCOUNT)); } //设置界面 for (WORD i =0;i<GAME_PLAYER;i++) { if(m_cbPlayStatus[i] == FALSE)continue; m_GameClientView.m_SmallCardControl[i].SetCardData(MAX_COUNT); m_GameClientView.SetUserTableScore(i,m_lTableScore[i]); m_GameClientView.SetTotalScore(i,m_lTotalScore[i]); } m_GameClientView.SetDFlag(m_wDUser); m_GameClientView.SetTitleInfo(m_lCellScore,pStatusPlay->lCellMaxScore); m_GameClientView.SetCenterScore(m_lCenterScore); //更新界面 m_GameClientView.UpdateGameView(NULL); //当前玩家 if((IsLookonMode() == false)&&(m_wCurrentUser == GetMeChairID())) UpdateScoreControl(); //设置时间 SetGameTimer(m_wCurrentUser,IDI_USER_ADD_SCORE,TIME_USER_ADD_SCORE); //旁观设置 OnLookonChanged(bLookonOther,NULL,0); //坐下按钮 if(IsLookonMode()) { m_GameClientView.SetMyLookOn(GetMeChairID()); //更新界面 m_GameClientView.UpdateGameView(NULL); } return true; } } return false; }
//用户放弃 bool CGameClientDlg::OnSubGiveUp(const void * pBuffer, WORD wDataSize) { //效验数据 if (wDataSize!=sizeof(CMD_S_GiveUp)) return false; CMD_S_GiveUp * pGiveUp=(CMD_S_GiveUp *)pBuffer; //设置变量 m_cbPlayStatus[pGiveUp->wGiveUpUser]=FALSE; //界面设置 m_GameClientView.m_SmallCardControl[pGiveUp->wGiveUpUser].SetCardData(NULL,0); m_GameClientView.m_CardControl[pGiveUp->wGiveUpUser].SetCardData(NULL,0); m_GameClientView.UpdateWindow(); m_GameClientView.DrawMoveCard(pGiveUp->wGiveUpUser,TO_GIVEUP_CARD,0); //状态设置 if ((IsLookonMode()==false)&&(pGiveUp->wGiveUpUser==GetMeChairID())) SetGameStatus(GS_FREE); //变量定义 WORD wGiveUpUser=pGiveUp->wGiveUpUser; //环境设置 if (wGiveUpUser==GetTimeChairID()) KillGameTimer(IDI_USER_ADD_SCORE); if ((IsLookonMode()==true)||(wGiveUpUser!=GetMeChairID())) PlayGameSound(AfxGetInstanceHandle(),TEXT("GIVE_UP")); //显示积分 if (wGiveUpUser==GetMeChairID()) { if(m_lTableScore[wGiveUpUser]!=0L) { m_GameClientView.DrawMoveAnte(wGiveUpUser,CGameClientView::AA_BASEDEST_TO_CENTER,m_lTableScore[wGiveUpUser]); m_GameClientView.SetUserTableScore(wGiveUpUser,0L); m_lTableScore[wGiveUpUser] = 0L; } if(!IsLookonMode()) { //调整位置 CRect rcControl; m_GameClientView.m_ScoreView.GetWindowRect(&rcControl); CRect rcView ; m_GameClientView.GetWindowRect( &rcView ); m_GameClientView.m_ScoreView.MoveWindow(rcView.left+5,rcView.bottom-15-rcControl.Height()*3/2,rcControl.Width(),rcControl.Height()); m_GameClientView.m_ScoreView.SetGameScore(wGiveUpUser,pGiveUp->lLost); m_GameClientView.m_ScoreView.ShowWindow(SW_SHOW); m_GameClientView.m_ScoreView.SetShowTimes(); } } else { if(m_lTableScore[wGiveUpUser]!=0L) { m_GameClientView.DrawMoveAnte(wGiveUpUser,CGameClientView::AA_BASEDEST_TO_CENTER,m_lTableScore[wGiveUpUser]); m_GameClientView.SetUserTableScore(wGiveUpUser,0L); m_lTableScore[wGiveUpUser] = 0L; } } return true; }
//游戏结束 bool CGameClientDlg::OnSubGameEnd(const void * pBuffer, WORD wDataSize) { //效验参数 if (wDataSize!=sizeof(CMD_S_GameEnd)) return false; CMD_S_GameEnd * pGameEnd=(CMD_S_GameEnd *)pBuffer; //删除定时器 KillGameTimer(IDI_NULLITY); KillGameTimer(IDI_CALL_BANKER); KillTimer(IDI_TIME_USER_ADD_SCORE); KillTimer(IDI_TIME_OPEN_CARD); //清理数据 for(WORD i=0;i<GAME_PLAYER;i++) { m_GameClientView.ShowOpenCard(i,FALSE); } m_GameClientView.SetWaitInvest(false); UpdateScoreControl(NULL,SW_HIDE); m_GameClientView.m_btOx.ShowWindow(SW_HIDE); m_GameClientView.m_btHintOx.ShowWindow(SW_HIDE); m_GameClientView.m_btOpenCard.ShowWindow(SW_HIDE); m_GameClientView.m_btReSort.ShowWindow(SW_HIDE); m_GameClientView.m_btShortcut.ShowWindow(SW_HIDE); m_GameClientView.m_btBanker.ShowWindow(SW_HIDE); m_GameClientView.m_btIdler.ShowWindow(SW_HIDE); m_GameClientView.SetWaitCall(0xff); m_GameClientView.m_bOpenCard=false; //状态设置 SetGameStatus(GS_FREE); //播放声音 if (IsLookonMode()==false) { if (pGameEnd->lGameScore[GetMeChairID()]>0L) PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_WIN")); else PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_LOST")); } else PlayGameSound(GetModuleHandle(NULL),TEXT("GAME_END")); //显示积分 for (WORD i=0;i<GAME_PLAYER;i++) { if(GetUserData(i)!=NULL)m_GameClientView.ShowScore(m_wViewChairID[i],true); m_GameClientView.SetUserTableScore(m_wViewChairID[i],pGameEnd->lGameScore[i]); } m_GameClientView.m_ScoreView.ResetScore(); for (WORD i=0;i<GAME_PLAYER;i++) { //设置信息 if (pGameEnd->lGameScore[i]!=0L || i==m_wBankerUser) { m_GameClientView.m_ScoreView.SetGameTax(pGameEnd->lGameTax[i],i); if (m_szAccounts[i][0]=='#') m_GameClientView.m_ScoreView.SetGameScore(i,TEXT("已离开"),pGameEnd->lGameScore[i]); else m_GameClientView.m_ScoreView.SetGameScore(i,m_szAccounts[i],pGameEnd->lGameScore[i]); } } m_GameClientView.m_ScoreView.ShowWindow(SW_SHOW); //显示牌型 bool bOxSound=false; for (WORD i=0;i<GAME_PLAYER;i++) { WORD wViewChairID=m_wViewChairID[i]; if(i==GetMeChairID() && !IsLookonMode())continue; m_GameClientView.m_CardControl[wViewChairID].SetDisplayFlag(true); //牛牛牌型 if(m_cbHandCardData[i][0]>0) { if(m_bUserOxCard[i]==TRUE) { //扑克数据 BYTE bCardData[MAX_COUNT]; CopyMemory(bCardData,m_cbHandCardData[i],sizeof(bCardData)); //获取牛牛数据 m_GameLogic.GetOxCard(bCardData,MAX_COUNT); BYTE bCardValue=m_GameLogic.GetCardType(bCardData,MAX_COUNT); ASSERT(bCardValue>0); //加载数据 if(bCardValue<OX_THREE_SAME) { m_GameClientView.m_CardControl[wViewChairID].SetCardData(bCardData,3); m_GameClientView.m_CardControlOx[wViewChairID].SetCardData(&bCardData[3],2); } //显示点数 if(bCardValue>=10)bOxSound=true; m_GameClientView.SetUserOxValue(wViewChairID,bCardValue); } else { //无牛 m_GameClientView.SetUserOxValue(wViewChairID,0); } } } m_GameClientView.DisplayType(true); ////////////////////////////////////////////////////////////////////////// // WORD wMeChiarID = GetMeChairID(); // if(m_bUserOxCard[wMeChiarID]==TRUE)//牛牌分类 // { // //设置变量 // BYTE bTemp[MAX_COUNT]; // CopyMemory(bTemp,m_cbHandCardData[wMeChiarID],sizeof(bTemp)); // // //获取牛牌 // m_GameLogic.GetOxCard(bTemp,MAX_COUNT); // // //显示点数 // BYTE bValue=m_GameLogic.GetCardLogicValue(bTemp[3])+m_GameLogic.GetCardLogicValue(bTemp[4]); // ASSERT(bValue>0); // if(bValue>10) // bValue-=10; // if(bValue>=10)bOxSound=true; // else // bOxSound =false; // } // // //牛牛声音 // if (bOxSound) // { // if(GetUserData(GetMeChairID())->cbGender== 0) // PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_OXOX0")); // else // PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_OXOX1")); // } ////////////////////////////////////////////////////////////////////////// // //牛牛声音 // if(bOxSound) // { // PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_OXOX")); // } //开始按钮 if (IsLookonMode()==false) { m_GameClientView.m_btStart.ShowWindow(SW_SHOW); SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_USER_START_GAME); } //成绩显示在即时聊天对话框 TCHAR szBuffer[512]=TEXT(""); _snprintf(szBuffer,CountArray(szBuffer),TEXT("\n本局结束,成绩统计:")); InsertGeneralString(szBuffer,RGB(0,128,255),true); for (WORD i=0;i<GAME_PLAYER;i++) { //变量定义 const tagUserData * pUserData=GetUserData(i); //成绩输出 if (pUserData!=NULL) { _snprintf(szBuffer,CountArray(szBuffer),TEXT("%s:%+I64d"),pUserData->szName,pGameEnd->lGameScore[i]); InsertGeneralString(szBuffer,RGB(0,128,255),true); } else if(m_szAccounts[i][0]=='#') { _snprintf(szBuffer,CountArray(szBuffer),TEXT("%s:%+I64d"),TEXT("用户离开"),pGameEnd->lGameScore[i]); InsertGeneralString(szBuffer,RGB(0,128,255),true); } } //状态变量 m_wBankerUser=INVALID_CHAIR; ZeroMemory(m_szAccounts,sizeof(m_szAccounts)); ZeroMemory(m_cbPlayStatus,sizeof(m_cbPlayStatus)); 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; //设置状态 SetGameStatus(GS_PLAYING); //下注变量 m_lMaxScore=pGameStart->lMaxScore; m_lCellScore=pGameStart->lCellScore; m_lTurnMaxScore=pGameStart->lTurnMaxScore; m_lTurnLessScore=pGameStart->lTurnLessScore; //状态变量 m_bAddScore=false; m_wCurrentUser=pGameStart->wCurrentUser; //设置变量 LONG lTableScore=0L; for (WORD i=0;i<GAME_PLAYER;i++) { //获取用户 const tagUserData * pUserData=GetUserData(i); if (pUserData==NULL) continue; //游戏信息 m_cbPlayStatus[i]=TRUE; lTableScore+=m_lCellScore; m_lTableScore[2*i+1]=m_lCellScore; //用户名字 lstrcpyn(m_szAccounts[i],pUserData->szName,CountArray(m_szAccounts[i])); } //设置界面 m_GameClientView.m_ScoreView.ShowWindow(SW_HIDE); m_GameClientView.SetUserTableScore(INVALID_CHAIR,0L); m_GameClientView.SetCellScore(m_lCellScore); //设置界面 lTableScore = 0L; for (WORD i=0;i<GAME_PLAYER;i++) { //变量定义 WORD wViewChairID=SwitchViewChairID(i); //设置扑克 m_GameClientView.m_CardControl[wViewChairID].SetCardData(NULL,0); m_GameClientView.m_CardControl[wViewChairID].SetDisplayHead(false); lTableScore += m_lTableScore[2*i+1]; //设置筹码 m_GameClientView.m_PlayerJeton[wViewChairID].SetScore(m_lTableScore[2*i]); m_GameClientView.SetUserTableScore(wViewChairID,m_lTableScore[i*2]+m_lTableScore[i*2+1]); } m_GameClientView.m_PlayerJeton[GAME_PLAYER].SetScore(lTableScore); //派发扑克 for (BYTE cbIndex=0;cbIndex<2;cbIndex++) { for (WORD i=0;i<GAME_PLAYER;i++) { if (m_cbPlayStatus[i]==TRUE) { //变量定义 WORD wViewChairID=SwitchViewChairID(i); BYTE cbCardData[2]={0,pGameStart->cbCardData[i]}; //派发扑克 cbCardData[0]=(GetMeChairID()==i)?pGameStart->cbObscureCard:0; m_GameClientView.DispatchUserCard(wViewChairID,cbCardData[cbIndex]); } } } //玩家设置 if (IsLookonMode()==false) { //控制设置 m_GameClientView.m_CardControl[2].SetPositively(true); } //环境设置 PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START")); //激活框架 if (IsLookonMode()==false) ActiveGameFrame(); // //获取胜者 //#ifdef SUPPER_VER // CMD_C_GetWinner GetWinner; // GetWinner.dwUserID=GetUserData(GetMeChairID())->dwUserID; // SendData(SUB_C_GET_WINNER,&GetWinner,sizeof(GetWinner)); //#endif return true; }
//游戏结束 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; //--取消 //取消动画 //for (WORD wAreaIndex=ID_TIAN_MARK; wAreaIndex<=ID_HUANG_MARK; wAreaIndex*=2) // m_GameClientView.SetBombEffect(false,wAreaIndex); m_GameClientView.m_bCanGo=false; m_GameClientView.m_bSet=false; //m_GameClientView.SetAreaFlash(0xFF); //设置时间 SetGameTimer(GetMeChairID(),IDI_DISPATCH_CARD, pGameEnd->cbTimeLeave); //扑克信息 m_GameClientView.SetCardInfo(true,pGameEnd->cbTableCardArray); //庄家信息 m_GameClientView.SetBankerScore(pGameEnd->nBankerTime, pGameEnd->lBankerTotallScore); //成绩信息 m_GameClientView.SetCurGameScore(pGameEnd->lUserScore,pGameEnd->lUserReturnScore,pGameEnd->lBankerScore,pGameEnd->lRevenue); //设置状态 SetGameStatus(GS_GAME_END); //更新成绩 for (WORD wUserIndex = 0; wUserIndex < MAX_CHAIR; ++wUserIndex) { tagUserData const *pUserData = GetUserData(wUserIndex); if ( pUserData == NULL ) continue; tagApplyUser ApplyUser ; //更新信息 ApplyUser.lUserScore = pUserData->lScore; ApplyUser.strUserName = pUserData->szName; m_GameClientView.m_ApplyUser.UpdateUser(ApplyUser); } //更新控件 UpdateButtonContron(); //停止声音 m_DTSDBackground.Stop(); m_DTSDCheer[0].Stop(); m_DTSDCheer[1].Stop(); m_DTSDCheer[2].Stop(); // m_DTSDCheer[3].Stop(); // m_DTSDCheer[4].Stop(); return true; }
//游戏场景 bool CGameClientDlg::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize) { switch (cbGameStation) { case GS_FREE: //空闲状态 { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_StatusFree)); if (wDataSize!=sizeof(CMD_S_StatusFree)) return false; //消息处理 CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pBuffer; //设置时间 SetGameTimer(GetMeChairID(),IDI_FREE,pStatusFree->cbTimeLeave); //玩家信息 m_lMeMaxScore=pStatusFree->lUserMaxScore; m_GameClientView.SetMeMaxScore(m_lMeMaxScore); WORD wMeChairID=GetMeChairID(); m_GameClientView.SetMeChairID(SwitchViewChairID(wMeChairID)); //庄家信息 SetBankerInfo(pStatusFree->wBankerUser,pStatusFree->lBankerScore); m_GameClientView.SetBankerScore(pStatusFree->cbBankerTime,pStatusFree->lBankerWinScore); m_bEnableSysBanker=pStatusFree->bEnableSysBanker; m_GameClientView.EnableSysBanker(m_bEnableSysBanker); //控制信息 m_lApplyBankerCondition=pStatusFree->lApplyBankerCondition; m_lAreaLimitScore=pStatusFree->lAreaLimitScore; m_GameClientView.SetAreaLimitScore(m_lAreaLimitScore); //设置状态 SetGameStatus(GS_FREE); //更新控制 UpdateButtonContron(); m_GameClientView.UpdateGameView(NULL); return true; } case GS_PLAYING: //游戏状态 case GS_GAME_END: //结束状态 { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_StatusPlay)); if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false; //消息处理 CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pBuffer; //全局下注 m_GameClientView.PlaceUserJetton(ID_TIAN_MARK,pStatusPlay->lAllTianScore); m_GameClientView.PlaceUserJetton(ID_DI_MARK,pStatusPlay->lAllDiScore); m_GameClientView.PlaceUserJetton(ID_XUAN_MARK,pStatusPlay->lAllXuanScore); m_GameClientView.PlaceUserJetton(ID_HUANG_MARK,pStatusPlay->lAllHuangScore); //玩家下注 SetMePlaceJetton(ID_TIAN_MARK,pStatusPlay->lUserTianScore); SetMePlaceJetton(ID_DI_MARK,pStatusPlay->lUserDiScore); SetMePlaceJetton(ID_XUAN_MARK,pStatusPlay->lUserXuanScore); SetMePlaceJetton(ID_HUANG_MARK,pStatusPlay->lUserHuangScore); //玩家积分 m_lMeMaxScore=pStatusPlay->lUserMaxScore; m_GameClientView.SetMeMaxScore(m_lMeMaxScore); WORD wMeChairID=GetMeChairID(); m_GameClientView.SetMeChairID(SwitchViewChairID(wMeChairID)); //控制信息 m_lApplyBankerCondition=pStatusPlay->lApplyBankerCondition; m_lAreaLimitScore=pStatusPlay->lAreaLimitScore; m_GameClientView.SetAreaLimitScore(m_lAreaLimitScore); if (pStatusPlay->cbGameStatus==GS_GAME_END) { //扑克信息 m_GameClientView.SetCardInfo(true,pStatusPlay->cbTableCardArray); m_GameClientView.FinishDispatchCard(); //设置成绩 m_GameClientView.SetCurGameScore(pStatusPlay->lEndUserScore,pStatusPlay->lEndUserReturnScore,pStatusPlay->lEndBankerScore,pStatusPlay->lEndRevenue); } else { m_GameClientView.SetCardInfo(false,NULL); //播放声音 if (IsEnableSound()) m_DTSDBackground.Play(0,true); } //庄家信息 SetBankerInfo(pStatusPlay->wBankerUser,pStatusPlay->lBankerScore); m_GameClientView.SetBankerScore(pStatusPlay->cbBankerTime,pStatusPlay->lBankerWinScore); m_bEnableSysBanker=pStatusPlay->bEnableSysBanker; m_GameClientView.EnableSysBanker(m_bEnableSysBanker); //设置状态 SetGameStatus(pStatusPlay->cbGameStatus); //设置时间 SetGameTimer(GetMeChairID(),pStatusPlay->cbGameStatus==GS_GAME_END?IDI_DISPATCH_CARD:IDI_PLACE_JETTON,pStatusPlay->cbTimeLeave); //更新按钮 UpdateButtonContron(); m_GameClientView.UpdateGameView(NULL); return true; } } return false; }
//游戏结束 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; //取消动画 for (WORD wAreaIndex=ID_HORSE1; wAreaIndex<=ID_HORSE8; ++wAreaIndex) m_GameClientView.SetBombEffect(false,wAreaIndex); //清空下注 //m_GameClientView.CleanUserJetton(); if (IsEnableSound()) { PlayGameSound(HORSE_GO); } //设置时间 SetGameTimer(GetMeChairID(),IDI_HORSE_RUN, pGameEnd->cbTimeLeave); ////扑克信息 m_GameClientView.SetHorseSpeed(pGameEnd->cbHorseSpeed); //庄家信息 m_GameClientView.SetBankerScore(pGameEnd->nBankerTime, pGameEnd->lBankerTotallScore); //成绩信息 m_GameClientView.SetCurGameScore(pGameEnd->lUserScore,pGameEnd->lUserReturnScore,pGameEnd->lBankerScore,pGameEnd->lRevenue); //设置状态 SetGameStatus(GS_GAME_END); //m_GameBank.ShowWindow(SW_HIDE); //更新成绩 for (WORD wUserIndex = 0; wUserIndex < MAX_CHAIR; ++wUserIndex) { tagUserData const *pUserData = GetUserData(wUserIndex); if ( pUserData == NULL ) continue; tagApplyUser ApplyUser ; //更新信息 ApplyUser.lUserScore = pUserData->lScore; ApplyUser.strUserName = pUserData->szName; m_GameClientView.m_ApplyUser.UpdateUser(ApplyUser); } //更新控件 UpdateButtonContron(); //停止声音 m_DTSDBackground.Stop(); m_DTSDCheer[0].Stop(); m_DTSDCheer[1].Stop(); m_DTSDCheer[2].Stop(); //m_DTSDRaceHorse.Stop(); 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; //设置状态 SetGameStatus(GS_MJ_PLAY); m_GameClientView.m_ScoreControl.RestorationData(); m_GameClientView.SetCurrentUser(INVALID_CHAIR); //设置变量 m_bHearStatus=false; m_bWillHearStatus=false; m_wBankerUser=pGameStart->wBankerUser; m_wCurrentUser=pGameStart->wCurrentUser; m_cbLeftCardCount=MAX_REPERTORY-GAME_PLAYER*(MAX_COUNT-1)-1; //出牌信息 m_cbOutCardData=0; m_wOutCardUser=INVALID_CHAIR; ZeroMemory(m_cbDiscardCard,sizeof(m_cbDiscardCard)); ZeroMemory(m_cbDiscardCount,sizeof(m_cbDiscardCount)); //组合扑克 ZeroMemory(m_cbWeaveCount,sizeof(m_cbWeaveCount)); ZeroMemory(m_WeaveItemArray,sizeof(m_WeaveItemArray)); //设置扑克 BYTE cbCardCount=(GetMeChairID()==m_wBankerUser)?MAX_COUNT:(MAX_COUNT-1); m_GameLogic.SwitchToCardIndex(pGameStart->cbCardData,cbCardCount,m_cbCardIndex); //设置界面 bool bPlayerMode=(IsLookonMode()==false); m_GameClientView.SetUserListenStatus(INVALID_CHAIR,false); m_GameClientView.m_HandCardControl.SetPositively(bPlayerMode); m_GameClientView.SetBankerUser(SwitchViewChairID(m_wBankerUser)); m_GameClientView.SetDiscUser(INVALID_CHAIR); //旁观界面 if (bPlayerMode==false) { m_GameClientView.SetHuangZhuang(false); m_GameClientView.SetStatusFlag(false,false); m_GameClientView.SetUserAction(INVALID_CHAIR,0); m_GameClientView.SetOutCardInfo(INVALID_CHAIR,0); } //堆立扑克 for (WORD i=0;i<GAME_PLAYER;i++) { m_cbHeapCardInfo[i][0]=0; m_cbHeapCardInfo[i][1]=0; } //分发扑克 BYTE cbTakeCount=(MAX_COUNT-1)*GAME_PLAYER+1; BYTE cbSiceFirst=HIBYTE(pGameStart->wSiceCount); BYTE cbSiceSecond=LOBYTE(pGameStart->wSiceCount); WORD wTakeChairID=(m_wBankerUser+7-cbSiceFirst)%GAME_PLAYER; for (WORD i=0;i<GAME_PLAYER;i++) { //计算数目 BYTE cbValidCount=HEAP_FULL_COUNT-m_cbHeapCardInfo[wTakeChairID][1]-((i==0)?(cbSiceSecond-1)*2:0); BYTE cbRemoveCount=__min(cbValidCount,cbTakeCount); //提取扑克 cbTakeCount-=cbRemoveCount; m_cbHeapCardInfo[wTakeChairID][(i==0)?1:0]+=cbRemoveCount; //完成判断 if (cbTakeCount==0) { m_wHeapHand=wTakeChairID; m_wHeapTail=(m_wBankerUser+7-cbSiceFirst)%GAME_PLAYER; break; } //切换索引 wTakeChairID=(wTakeChairID+1)%GAME_PLAYER; } //扑克设置 for (WORD i=0;i<GAME_PLAYER;i++) { //变量定义 WORD wViewChairID=SwitchViewChairID(i); //组合界面 m_GameClientView.m_WeaveCard[i][0].SetDisplayItem(true); m_GameClientView.m_WeaveCard[i][1].SetDisplayItem(true); m_GameClientView.m_WeaveCard[i][2].SetDisplayItem(true); m_GameClientView.m_WeaveCard[i][3].SetDisplayItem(true); m_GameClientView.m_HeapCard[wViewChairID].SetCardData(m_cbHeapCardInfo[i][0],m_cbHeapCardInfo[i][1],HEAP_FULL_COUNT); //用户扑克 if (wViewChairID!=2) { WORD wIndex=(wViewChairID>=3)?2:wViewChairID; m_GameClientView.m_UserCard[wIndex].SetCardData(CountArray(pGameStart->cbCardData)-1,(i==m_wBankerUser)); } else { BYTE cbBankerCard=(i==m_wBankerUser)?pGameStart->cbCardData[MAX_COUNT-1]:0; m_GameClientView.m_HandCardControl.SetCardData(pGameStart->cbCardData,MAX_COUNT-1,cbBankerCard); } //旁观界面 if (bPlayerMode==false) { m_GameClientView.m_TableCard[wViewChairID].SetCardData(NULL,0); m_GameClientView.m_DiscardCard[wViewChairID].SetCardData(NULL,0); m_GameClientView.m_WeaveCard[wViewChairID][0].SetCardData(NULL,0); m_GameClientView.m_WeaveCard[wViewChairID][1].SetCardData(NULL,0); m_GameClientView.m_WeaveCard[wViewChairID][2].SetCardData(NULL,0); m_GameClientView.m_WeaveCard[wViewChairID][3].SetCardData(NULL,0); } } //出牌提示 if ((bPlayerMode==true)&&(m_wCurrentUser!=INVALID_CHAIR)) { WORD wMeChairID=GetMeChairID(); if (m_wCurrentUser==wMeChairID) m_GameClientView.SetStatusFlag(true,false); } //动作处理 if ((bPlayerMode==true)&&(pGameStart->cbUserAction!=WIK_NULL)) { ShowOperateControl(pGameStart->cbUserAction,0); SetGameTimer(GetMeChairID(),IDI_OPERATE_CARD,TIME_OPERATE_CARD); } //更新界面 m_GameClientView.UpdateGameView(NULL); //激活框架 if (bPlayerMode==true) ActiveGameFrame(); //环境处理 PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START")); //设置时间 if (m_wCurrentUser!=INVALID_CHAIR) { m_GameClientView.SetCurrentUser(SwitchViewChairID(m_wCurrentUser)); SetGameTimer(m_wCurrentUser,IDI_OPERATE_CARD,TIME_OPERATE_CARD); } //托管设置 for (WORD i=0;i<GAME_PLAYER;i++) { m_GameClientView.SetTrustee(SwitchViewChairID(i),pGameStart->bTrustee[i]); } return true; }
//游戏结束 bool CGameClientDlg::OnSubGameEnd(const void * pBuffer, WORD wDataSize) { //效验参数 if (wDataSize!=sizeof(CMD_S_GameEnd)) return false; CMD_S_GameEnd * pGameEnd=(CMD_S_GameEnd *)pBuffer; //状态设置 HideScoreControl(); SetGameStatus(GS_FREE); KillGameTimer(IDI_USER_ADD_SCORE); m_GameClientView.SetUserTableScore(INVALID_CHAIR,0L); //播放声音 if (IsLookonMode()==false) { if (pGameEnd->lGameScore[GetMeChairID()]>0L) PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_WIN")); else PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_LOST")); } else PlayGameSound(GetModuleHandle(NULL),TEXT("GAME_END")); //正常结束 m_GameClientView.m_ScoreView.ResetScore(); for (WORD i=0;i<GAME_PLAYER;i++) { //设置信息 if (pGameEnd->lGameScore[i]!=0L) { if (m_szAccounts[i][0]==0) m_GameClientView.m_ScoreView.SetGameScore(i,TEXT("已离开"),pGameEnd->lGameScore[i]); else m_GameClientView.m_ScoreView.SetGameScore(i,m_szAccounts[i],pGameEnd->lGameScore[i]); //扣税 m_GameClientView.m_ScoreView.SetGameTax(i,pGameEnd->lGameTax[i]); if (pGameEnd->cbCardData[i]!=0) { //获取扑克 BYTE cbCardData[5]; WORD wViewChairID=SwitchViewChairID(i); BYTE cbCardCount=(BYTE)m_GameClientView.m_CardControl[wViewChairID].GetCardData(cbCardData,CountArray(cbCardData)); //设置扑克 cbCardData[0]=pGameEnd->cbCardData[i]; m_GameClientView.m_CardControl[wViewChairID].SetDisplayHead(true); m_GameClientView.m_CardControl[wViewChairID].SetCardData(cbCardData,cbCardCount); } } } m_GameClientView.m_ScoreView.ShowWindow(SW_SHOW); //设置积分 TCHAR szBuffer[128] = TEXT(""); InsertGeneralString(TEXT("\n本局结束,成绩统计:"),RGB(255,0,255),true); for (WORD i=0;i<GAME_PLAYER;i++) { if( pGameEnd->lGameScore[i] != 0L && m_szAccounts[i][0]!=0 ) { //在聊天框显示成绩 _snprintf(szBuffer,CountArray(szBuffer),TEXT(" %s: %+ld分"),m_szAccounts[i],pGameEnd->lGameScore[i]); InsertGeneralString(szBuffer,RGB(255,0,255),true); } } //加注信息 m_lMaxScore=0L; m_lCellScore=0L; m_lTurnMaxScore=0L; m_lTurnLessScore=0L; ZeroMemory(m_lTableScore,sizeof(m_lTableScore)); //状态变量 m_bAddScore=false; m_bShowHand=false; m_wCurrentUser=INVALID_CHAIR; ZeroMemory(m_szAccounts,sizeof(m_szAccounts)); ZeroMemory(m_cbPlayStatus,sizeof(m_cbPlayStatus)); //开始按钮 if (IsLookonMode()==false) { m_GameClientView.m_btStart.ShowWindow(SW_SHOW); SetGameTimer(GetMeChairID(),IDI_START_GAME,TIME_START_GAME); } return true; }
//游戏结束 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::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize) { switch (cbGameStation) { case GS_FREE: //空闲状态 { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_StatusFree)); if (wDataSize!=sizeof(CMD_S_StatusFree)) return false; //消息处理 CMD_S_StatusFree * pStatusFree=(CMD_S_StatusFree *)pBuffer; //设置时间 SetGameTimer(GetMeChairID(),IDI_FREE,pStatusFree->cbTimeLeave); //玩家信息 m_lMeMaxScore=pStatusFree->lUserMaxScore; m_GameClientView.SetMeMaxScore(m_lMeMaxScore); WORD wMeChairID=GetMeChairID(); m_GameClientView.SetMeChairID(SwitchViewChairID(wMeChairID)); //庄家信息 SetBankerInfo(pStatusFree->wBankerUser,pStatusFree->lBankerScore); m_GameClientView.SetBankerScore(pStatusFree->cbBankerTime,pStatusFree->lBankerWinScore); m_bEnableSysBanker=pStatusFree->bEnableSysBanker; m_GameClientView.EnableSysBanker(m_bEnableSysBanker); //控制信息 m_lApplyBankerCondition=pStatusFree->lApplyBankerCondition; m_lAreaLimitScore=pStatusFree->lAreaLimitScore; m_GameClientView.SetAreaLimitScore(m_lAreaLimitScore); //设置状态 SetGameStatus(GS_FREE); //更新控制 UpdateButtonContron(); m_GameClientView.UpdateGameView(NULL); return true; } case GS_PLAYING: //游戏状态 case GS_GAME_END: //结束状态 { //效验数据 ASSERT(wDataSize==sizeof(CMD_S_StatusPlay)); if (wDataSize!=sizeof(CMD_S_StatusPlay)) return false; //消息处理 CMD_S_StatusPlay * pStatusPlay=(CMD_S_StatusPlay *)pBuffer; //全局下注 m_GameClientView.PlaceUserJetton(ID_HORSE1,pStatusPlay->lAllScore1); m_GameClientView.PlaceUserJetton(ID_HORSE2,pStatusPlay->lAllScore2); m_GameClientView.PlaceUserJetton(ID_HORSE3,pStatusPlay->lAllScore3); m_GameClientView.PlaceUserJetton(ID_HORSE4,pStatusPlay->lAllScore4); m_GameClientView.PlaceUserJetton(ID_HORSE5,pStatusPlay->lAllScore5); m_GameClientView.PlaceUserJetton(ID_HORSE6,pStatusPlay->lAllScore6); m_GameClientView.PlaceUserJetton(ID_HORSE7,pStatusPlay->lAllScore7); m_GameClientView.PlaceUserJetton(ID_HORSE8,pStatusPlay->lAllScore8); //玩家下注 SetMePlaceJetton(ID_HORSE1,pStatusPlay->lUserScore1); SetMePlaceJetton(ID_HORSE2,pStatusPlay->lUserScore2); SetMePlaceJetton(ID_HORSE3,pStatusPlay->lUserScore3); SetMePlaceJetton(ID_HORSE4,pStatusPlay->lUserScore4); SetMePlaceJetton(ID_HORSE5,pStatusPlay->lUserScore5); SetMePlaceJetton(ID_HORSE6,pStatusPlay->lUserScore6); SetMePlaceJetton(ID_HORSE7,pStatusPlay->lUserScore7); SetMePlaceJetton(ID_HORSE8,pStatusPlay->lUserScore8); //玩家积分 m_lMeMaxScore=pStatusPlay->lUserMaxScore; m_GameClientView.SetMeMaxScore(m_lMeMaxScore); WORD wMeChairID=GetMeChairID(); m_GameClientView.SetMeChairID(SwitchViewChairID(wMeChairID)); //控制信息 m_lApplyBankerCondition=pStatusPlay->lApplyBankerCondition; m_lAreaLimitScore=pStatusPlay->lAreaLimitScore; m_GameClientView.SetAreaLimitScore(m_lAreaLimitScore); if (pStatusPlay->cbGameStatus==GS_GAME_END) { //扑克信息 m_GameClientView.SetHorseSpeed(pStatusPlay->cbHorseSpeed); m_GameClientView.FinishRun(); //设置成绩 m_GameClientView.SetCurGameScore(pStatusPlay->lEndUserScore,pStatusPlay->lEndUserReturnScore,pStatusPlay->lEndBankerScore,pStatusPlay->lEndRevenue); } else { //m_GameClientView.SetHorseSpeed(NULL); //播放声音 if (IsEnableSound()) m_DTSDBackground.Play(0,true); } //庄家信息 SetBankerInfo(pStatusPlay->wBankerUser,pStatusPlay->lBankerScore); m_GameClientView.SetBankerScore(pStatusPlay->cbBankerTime,pStatusPlay->lBankerWinScore); m_bEnableSysBanker=pStatusPlay->bEnableSysBanker; m_GameClientView.EnableSysBanker(m_bEnableSysBanker); //设置状态 SetGameStatus(pStatusPlay->cbGameStatus); //设置时间 SetGameTimer(GetMeChairID(),pStatusPlay->cbGameStatus==GS_GAME_END?IDI_HORSE_RUN:IDI_PLACE_JETTON,pStatusPlay->cbTimeLeave); //更新按钮 UpdateButtonContron(); m_GameClientView.UpdateGameView(NULL); return true; } } return false; }