示例#1
0
//用户掀牌
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;
}
示例#2
0
//鲜花消息
void __cdecl CGameFrameDlg::OnEventFlower(const tagUserData * pSendUserData, const tagUserData * pRecvUserData, UINT uFlowerID, UINT uFlowerEffectID)
{
	//界面显示
	m_pGameFrameView->ShowFlower(SwitchViewChairID(pSendUserData->wChairID), SwitchViewChairID(pRecvUserData->wChairID), uFlowerID, 
		uFlowerEffectID, m_ClientKernelHelper->GetMeChairID()==pRecvUserData->wChairID);

	return;
}
示例#3
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;
	m_wBlackUser=pGameStart->wBlackUser;
	m_wCurrentUser=pGameStart->wBlackUser;
	m_cbChessColor=(m_wBlackUser==GetMeChairID())?BLACK_CHESS:WHITE_CHESS;

	//设置时间
	m_wLeftClock[0]=m_wLeftClock[1]=pGameStart->wGameClock;
	m_GameClientView.SetGameClock(pGameStart->wGameClock);
	m_GameClientView.SetUserClock(SwitchViewChairID(0),m_wLeftClock[0]);
	m_GameClientView.SetUserClock(SwitchViewChairID(1),m_wLeftClock[1]);

	//设置变量
	m_cbXSourcePos=255;
	m_cbYSourcePos=255;
	m_cbXTargetPos=255;
	m_cbYTargetPos=255;

	//设置棋盘 
	m_GameLogic.ResetChessBorad();
	m_GameClientView.m_ChessBorad.SetChessColor(m_cbChessColor);
	m_GameClientView.m_ChessBorad.SetChessBorad(m_GameLogic.m_ChessBorad);

	//设置界面
	m_GameClientView.m_btPreserve.EnableWindow(TRUE);
	m_GameClientView.m_GameScoreWnd.ShowWindow(SW_HIDE);
	m_GameClientView.SetBlackUser(SwitchViewChairID(m_wBlackUser));

	//全部玩家
	if (IsLookonMode()==false)
	{
		m_GameClientView.m_btStart.EnableWindow(FALSE);
		m_GameClientView.m_btPeace.EnableWindow(TRUE);
		m_GameClientView.m_btGiveUp.EnableWindow(TRUE);
	}

	//玩家设置
	if ((IsLookonMode()==false)&&(m_wCurrentUser==GetMeChairID()))
	{
		ActiveGameFrame();
		CancelChessSelect();
		m_GameClientView.m_ChessBorad.SetPositively(true);
	}

	//设置定时器
	SetTimer(IDI_GAME_TIMER,1000,NULL);

	//播放声音
	PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_START"));

	return true;
}
示例#4
0
//放弃出牌
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;
}
示例#5
0
//上一轮提示
LRESULT CGameClientDlg::OnForeTurn(WPARAM wParam,LPARAM lParam)
{
	
	for(BYTE i=0;i<GAME_PLAYER;i++)
	{
		for(BYTE j=0;j<16&&m_bForCardItem[i][j].bCardData;j++);
		m_GameClientView.m_ForeTurn[SwitchViewChairID(i)].SetCardItem(m_bForCardItem[i],j);
		m_GameClientView.m_ForeTurn[SwitchViewChairID(i)].SetDisplayFlag(TRUE);
	}
	return 0;
}
示例#6
0
//重列处理
bool CGameClientDlg::OnSubRealign(const void * pBuffer, WORD wDataSize)
{
	if (wDataSize!=sizeof(CMD_S_Realign)) return false;
	CMD_S_Realign * psRealign=(CMD_S_Realign *)pBuffer;

	WORD id = SwitchViewChairID(psRealign->nCurrentPlayer);
	if(id ==2)
	{
		if(IsLookonMode())
		{
			memcpy(m_GameClientView.m_wndD3D.m_Chess[id],psRealign->nChess , sizeof(psRealign->nChess));
			m_GameClientView.m_wndD3D.UpdateBackSurface();

			//效果
			m_GameClientView.m_wndD3D.m_PointSprite_Star.On();

			//播放声音
			OnPlayMusic(IDM_MUSIC_FLYSTAR,0);
		}
		else
		{
			m_GameClientView.m_MyListView.m_ImplementCount[PROP_RESET] = psRealign->nPropCount;
			m_GameClientView.m_MyListView.UpdateImplementState();
		}
	}
	else
	{
		memcpy(m_GameClientView.m_wndD3D.m_Chess[id],psRealign->nChess , sizeof(psRealign->nChess));
		m_GameClientView.m_wndD3D.UpdateChessSmall(id);
	}
	return true;
}
示例#7
0
//用户放弃
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;
}
示例#8
0
//连接处理
bool CGameClientDlg::OnSubLink(const void * pBuffer, WORD wDataSize)
{
	if (wDataSize!=sizeof(CMD_S_Link)) return false;
	CMD_S_Link * pslink=(CMD_S_Link *)pBuffer;

	WORD id = SwitchViewChairID(pslink->nCurrentPlayer);
	if(id ==2)
	{
		if(IsLookonMode())
		{
			
			m_GameClientView.LinkPro(CPoint(pslink->nFirst_X,pslink->nFirst_Y),
				CPoint(pslink->nEnd_X,pslink->nEnd_Y),id);

			//播放声音
			OnPlayMusic(IDM_MUSIC_LINK,0);
			OnPlayMusic(IDM_MUSIC_BOMB,0);
		}
		else
		{
			if(pslink->nPropType != ERROR_ALL)
			{
				m_GameClientView.m_MyListView.m_ImplementCount[pslink->nPropType] = pslink->nPropCount;
				m_GameClientView.m_MyListView.UpdateImplementState();
			}
		}
	}
	else
	{
		m_GameClientView.OtherPlayLinkPro(CPoint(pslink->nFirst_X,pslink->nFirst_Y),
				CPoint(pslink->nEnd_X,pslink->nEnd_Y),id);
	}
	return true;
}
示例#9
0
//设置庄家
void CGameClientDlg::SetBankerInfo(WORD wBanker,LONG lScore)
{
	m_wCurrentBanker=wBanker;
	m_lBankerScore=lScore;
	WORD wBankerViewChairID=m_wCurrentBanker==INVALID_CHAIR ? INVALID_CHAIR:SwitchViewChairID(m_wCurrentBanker);
	m_GameClientView.SetBankerInfo(wBankerViewChairID,m_lBankerScore);
}
示例#10
0
//发牌消息
bool CGameClientDlg::OnSubSendCard(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	if (wDataSize!=sizeof(CMD_S_SendCard)) return false;
	CMD_S_SendCard * pSendCard=(CMD_S_SendCard *)pBuffer;

	//设置变量
	m_bAddScore=false;
	m_lTurnLessScore=0L;
	m_wCurrentUser=pSendCard->wCurrentUser;
	m_lTurnMaxScore=pSendCard->lTurnMaxScore;
	m_lTurnLessScore=pSendCard->lTurnLessScore;

	//设置筹码
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		WORD wViewChairID=SwitchViewChairID(i);
		m_GameClientView.m_PlayerJeton[wViewChairID].SetScore(0L);
		m_GameClientView.m_PlayerJeton[GAME_PLAYER].AddScore(m_lTableScore[i*2]);
	}

	//累计金币
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		m_lTableScore[i*2+1]+=m_lTableScore[i*2];
		m_lTableScore[i*2]=0L;
	}

	//派发扑克,从上次最大玩家开始发起
	WORD wLastMostUser = pSendCard->wLastMostUser;
	ASSERT( wLastMostUser != INVALID_CHAIR );
	for (BYTE i=0;i<pSendCard->cbSendCardCount;i++)
	{
		for (WORD j=0;j<GAME_PLAYER;j++)
		{
			WORD wChairId = (wLastMostUser+j)%GAME_PLAYER;
			if (m_cbPlayStatus[wChairId]==TRUE)
			{
				WORD wViewChairID=SwitchViewChairID(wChairId);
				m_GameClientView.DispatchUserCard(wViewChairID,pSendCard->cbCardData[wChairId][i]);
			}
		}
	}

	return true;
}
示例#11
0
//时间更新
void __cdecl CGameClientDlg::OnEventTimerKilled(WORD wChairID, UINT nTimerID)
{
	//设置界面
	WORD wViewChairID=SwitchViewChairID(wChairID);
	//m_GameClientView.SetUserTimer(wViewChairID,0);
	//需要
	return;
}
示例#12
0
//用户叫庄
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;
}
示例#13
0
// 特殊椅子位置转换
int CGameClientDlg::ChairSwitch(int chair)
{
	int otherChair = SwitchViewChairID(chair);

	if(otherChair == 3)
		return 2;

	return otherChair;
}
示例#14
0
//游戏场景
bool CGameClientDlg::OnGameSceneMessage(BYTE cbGameStation, bool bLookonOther, const void * pBuffer, WORD wDataSize)
{
	
	switch (cbGameStation)
	{
	case GS_FREE:		//空闲状态
		{
			m_GameClientView.m_MyListView.m_btStart.EnableWindow(TRUE);

			return true;
		}
	case GS_PLAYING:	//游戏状态
		{
			if (wDataSize!=sizeof(CMD_S_GameState)) return false;
			CMD_S_GameState * psGameState = (CMD_S_GameState *)pBuffer;

			int id;
			//装入棋盘
			for(int i=0; i<GAME_PLAYER; i++)
			{
				id = SwitchViewChairID(i);
				m_GameClientView.m_wndD3D.m_bPlayState[id] = psGameState->bPlayState[i];
				memcpy(m_GameClientView.m_wndD3D.m_Chess[id],psGameState->map[i],sizeof(psGameState->map[i]));
			}

			if(IsLookonMode() || !psGameState->bPlayState[GetMeChairID()])
			{
				m_GameClientView.m_wndD3D.m_bCanGame = false;
				m_GameClientView.m_wndD3D.m_bGameLose[2] = false;
			}
			else
			{
				memcpy(m_GameClientView.m_MyListView.m_ImplementCount,psGameState->bPropCnt,sizeof(psGameState->bPropCnt));
				//重设定时器
				m_GameClientView.m_wndD3D.m_nTimeCounter = psGameState->nLeaveTime;
				m_GameClientView.m_wndD3D.m_bCanGame = true;
				if(psGameState->nLeaveTime>=30)
				m_GameClientView.m_wndD3D.m_bGameLose[2] = true;
			}
			m_GameClientView.m_wndD3D.UpdateBackSurface();
			m_GameClientView.m_MyListView.UpdateImplementState();

			//关闭练习按钮
			m_GameClientView.m_MyListView.m_btStart.EnableWindow(FALSE);
			m_GameClientView.m_MyListView.m_btExercise.EnableWindow(FALSE);
			OnPlayMusic(IDM_MUSIC_BG,0);
			return true;
		}
	default:
		return true;
	}

	return true;
}
示例#15
0
//用户叫分
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;
}
示例#16
0
//内核事件
//时间消息
bool __cdecl CGameClientDlg::OnEventTimer(WORD wChairID, UINT nElapse, UINT nTimerID)
{
	//变量界面
	WORD wViewChairID=SwitchViewChairID(wChairID);
	//m_GameClientView.SetUserTimer(wViewChairID,nElapse);
	//需要

	//事件通知
	return OnTimerMessage(wChairID,nElapse,nTimerID);

	return true;
}
示例#17
0
//扣除扑克
void CGameClientDlg::DeductionTableCard(bool bHeadCard)
{
	if (bHeadCard==true)
	{
		//切换索引
		BYTE cbHeapCount=m_cbHeapCardInfo[m_wHeapHand][0]+m_cbHeapCardInfo[m_wHeapHand][1];
		if (cbHeapCount==HEAP_FULL_COUNT)
			m_wHeapHand=(m_wHeapHand+1)%CountArray(m_cbHeapCardInfo);

		//减少扑克
		m_cbLeftCardCount--;
		m_cbHeapCardInfo[m_wHeapHand][0]++;

		//堆立扑克
		WORD wHeapViewID=SwitchViewChairID(m_wHeapHand);
		WORD wMinusHeadCount=m_cbHeapCardInfo[m_wHeapHand][0];
		WORD wMinusLastCount=m_cbHeapCardInfo[m_wHeapHand][1];
		m_GameClientView.m_HeapCard[wHeapViewID].SetCardData(wMinusHeadCount,wMinusLastCount,HEAP_FULL_COUNT);
	}
	else
	{
		//切换索引
		BYTE cbHeapCount=m_cbHeapCardInfo[m_wHeapTail][0]+m_cbHeapCardInfo[m_wHeapTail][1];
		if (cbHeapCount==HEAP_FULL_COUNT)
			m_wHeapTail=(m_wHeapTail+3)%CountArray(m_cbHeapCardInfo);

		//减少扑克
		m_cbLeftCardCount--;
		m_cbHeapCardInfo[m_wHeapTail][1]++;

		//堆立扑克
		WORD wHeapViewID=SwitchViewChairID(m_wHeapTail);
		WORD wMinusHeadCount=m_cbHeapCardInfo[m_wHeapTail][0];
		WORD wMinusLastCount=m_cbHeapCardInfo[m_wHeapTail][1];
		m_GameClientView.m_HeapCard[wHeapViewID].SetCardData(wMinusHeadCount,wMinusLastCount,HEAP_FULL_COUNT);
	}

	return;
}
示例#18
0
//用户离开
void __cdecl CGameClientDlg::OnEventUserLeave(tagUserData * pUserData, WORD wChairID, bool bLookonUser)
{
	//设置界面
	if (bLookonUser==false)
	{
		WORD wViewChairID=SwitchViewChairID(wChairID);
		m_GameClientView.MySetUserInfo(wViewChairID,NULL);
		//需要
	}

	//test
	m_GameClientView.m_MyListView.DeleteUserItem(pUserData);
	return;
}
示例#19
0
//用户出牌
bool CGameClientDlg::OnSubOutCard(const void * pBuffer, WORD wDataSize)
{
	//效验消息
	ASSERT(wDataSize==sizeof(CMD_S_OutCard));
	if (wDataSize!=sizeof(CMD_S_OutCard)) return false;

	//消息处理
	CMD_S_OutCard * pOutCard=(CMD_S_OutCard *)pBuffer;

	//变量定义
	WORD wMeChairID=GetMeChairID();
	WORD wOutViewChairID=SwitchViewChairID(pOutCard->wOutCardUser);

	//设置变量
	m_wCurrentUser=INVALID_CHAIR;
	m_wOutCardUser=pOutCard->wOutCardUser;
	m_cbOutCardData=pOutCard->cbOutCardData;

	//其他用户
	if ((IsLookonMode()==true)||(pOutCard->wOutCardUser!=wMeChairID))
	{
		//环境设置
		KillGameTimer(IDI_OPERATE_CARD); 
		PlayCardSound(pOutCard->wOutCardUser,pOutCard->cbOutCardData);

		//出牌界面
		m_GameClientView.SetUserAction(INVALID_CHAIR,0);
		m_GameClientView.SetOutCardInfo(wOutViewChairID,pOutCard->cbOutCardData);

		//设置扑克
		if (wOutViewChairID==2)
		{
			//删除扑克
			BYTE cbCardData[MAX_COUNT];
			m_GameLogic.RemoveCard(m_cbCardIndex,pOutCard->cbOutCardData);

			//设置扑克
			BYTE cbCardCount=m_GameLogic.SwitchToCardData(m_cbCardIndex,cbCardData);
			m_GameClientView.m_HandCardControl.SetCardData(cbCardData,cbCardCount,0);
		}
		else
		{
			WORD wUserIndex=(wOutViewChairID>2)?2:wOutViewChairID;
			m_GameClientView.m_UserCard[wUserIndex].SetCurrentCard(false);
		}
	}

	return true;
}
示例#20
0
//游戏结束
bool CGameClientDlg::OnSubEnd(const void * pBuffer, WORD wDataSize)
{
	if (wDataSize!=sizeof(CMD_S_GameOver)) return false;
	CMD_S_GameOver * psGameOver = (CMD_S_GameOver *)pBuffer;

	m_midi.Pause();

	for(int i=0; i<GAME_PLAYER; i++)
	{
		int id = SwitchViewChairID(i);
		m_GameClientView.m_wndD3D.m_UserTaxis[id] = psGameOver->bOrder[i];
		m_GameClientView.m_wndD3D.m_UserGrade[id] = psGameOver->nScores[i];
		if(psGameOver->bOrder[i]!= 1)m_GameClientView.m_wndD3D.m_bGameLose[id] = true;
		else m_GameClientView.m_wndD3D.m_bGameLose[id] = false;
		
		this->InsertSystemString(TEXT("本局结束,成绩统计:"));
		if(m_ClientKernelHelper->GetUserInfo(i))
		{
			CString msg;
			msg.Format("%s : 名次: %d, 最后得分: %d",GetUserData(i)?GetUserData(i)->szName:"??", psGameOver->bOrder[i],psGameOver->nScores[i]);
			this->InsertSystemString(msg);
		}
	}

	if(m_GameClientView.m_wndD3D.m_bGameLose[2] == false)
	{
		//播放声音
		OnPlayMusic(IDM_MUSIC_END,0);
	}

	m_GameClientView.m_wndD3D.m_bCanGame = false;
	m_GameClientView.m_wndD3D.m_bGameOver = true;
	m_GameClientView.m_MyListView.PropZero();
	m_GameClientView.m_MyListView.UpdateImplementState();


	if(!IsLookonMode())
	{
		m_GameClientView.m_MyListView.m_btStart.EnableWindow(TRUE);

		//打开练习按钮
		m_GameClientView.m_MyListView.m_btExercise.EnableWindow(TRUE);
	}

	BYTE cbGameStatus = GetGameStatus() ;

	return true;
}
示例#21
0
//游戏开始
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;
}
示例#22
0
//用户听牌
bool CGameClientDlg::OnSubListenCard(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	ASSERT(wDataSize==sizeof(CMD_S_ListenCard));
	if (wDataSize!=sizeof(CMD_S_ListenCard)) 
		return false;

	//变量定义
	CMD_S_ListenCard * pListenCard=(CMD_S_ListenCard *)pBuffer;

	//设置界面
	WORD wViewChairID=SwitchViewChairID(pListenCard->wListenUser);
	m_GameClientView.SetUserListenStatus(wViewChairID,true);
	PlayActionSound(pListenCard->wListenUser,WIK_LISTEN);

	return true;
}
示例#23
0
//时间消息
bool CGameClientDlg::OnTimerMessage(WORD wChairID, UINT nElapse, UINT nTimerID)
{
	switch (nTimerID)
	{
	case IDI_START_GAME:		//开始定时器
		{
			//中止判断
			if (nElapse==0)
			{
				PostMessage(WM_CLOSE,0,0);
				return false;
			}

			//警告通知
			if (nElapse<=5) PlayGameSound(AfxGetInstanceHandle(),TEXT("START_WARN"));

			return true;
		}
	case IDI_USER_ADD_SCORE:	//加注定时器
		{
			//获取位置
			WORD wViewChairID=SwitchViewChairID(wChairID);

			//中止判断
			if (nElapse==0)
			{
				if ((IsLookonMode()==false)&&(wViewChairID==2)) OnGiveUp(1,1);
				return false;
			}

			//警告通知
			if ((nElapse<=3)&&(wViewChairID==2)&&(IsLookonMode()==false))
			{
				PlayGameSound(AfxGetInstanceHandle(),TEXT("TIME_END"));
				return true;
			}

			return true;
		}
	}

	return false;
}
示例#24
0
//用户抢刺
bool CGameClientDlg::OnSubQiangCi(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	ASSERT(wDataSize==sizeof(CMD_S_User_QiangCi));
	if (wDataSize!=sizeof(CMD_S_User_QiangCi)) return false;
	//消息处理
	CMD_S_User_QiangCi * pQiangCi=(CMD_S_User_QiangCi *)pBuffer;
	m_GameClientView.ShowQiangCiTitle(SW_NORMAL,SwitchViewChairID(pQiangCi->wQiangCiUserID));
	//设置界面
	m_GameClientView.m_btOutCard.ShowWindow(SW_HIDE);
	m_GameClientView.m_btAutoOutCard.ShowWindow(SW_HIDE);
	if(pQiangCi->wQiangCiUserID==GetMeChairID())
	{
		m_GameClientView.m_btOutCard.ShowWindow(SW_NORMAL);
		m_GameClientView.m_btAutoOutCard.ShowWindow(SW_NORMAL);

	}

	return true;
}
示例#25
0
//游戏失败
bool CGameClientDlg::OnSubLost(const void * pBuffer, WORD wDataSize)
{
	if (wDataSize!=sizeof(CMD_S_Lost)) return false;
	CMD_S_Lost * psGameLost = (CMD_S_Lost *)pBuffer;

	int id = SwitchViewChairID(psGameLost->wSeat);
	if(id == 2)
	{
		m_GameClientView.m_MyListView.PropZero();
		m_GameClientView.m_MyListView.UpdateImplementState();
		m_GameClientView.m_wndD3D.m_bCanGame = false;
		m_GameClientView.m_wndD3D.m_bGameLose[id] = true;
		//播放声音
		OnPlayMusic(IDM_MUSIC_END,0);
	}
	else
	{
		m_GameClientView.m_wndD3D.m_bGameLose[id] = true;
	}
	return true;
}
示例#26
0
//用户扣牌
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;
}
示例#27
0
//用户托管
bool CGameClientDlg::OnSubTrustee(const void * pBuffer,WORD wDataSize)
{
	//效验数据
	ASSERT(wDataSize==sizeof(CMD_S_Trustee));
	if (wDataSize!=sizeof(CMD_S_Trustee)) return false;

	//消息处理
	CMD_S_Trustee * pTrustee=(CMD_S_Trustee *)pBuffer;
	m_GameClientView.SetTrustee(SwitchViewChairID(pTrustee->wChairID),pTrustee->bTrustee);
	if ((IsLookonMode()==true)||(pTrustee->wChairID!=GetMeChairID()))
	{
		const tagUserData * pUserData=GetUserData(pTrustee->wChairID);
		TCHAR szBuffer[256];
		if(pTrustee->bTrustee==true)
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("玩家[%s]选择了托管功能."),pUserData->szName);
		else
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("玩家[%s]取消了托管功能."),pUserData->szName);
		InsertSystemString(szBuffer);
	}

	return true;
}
示例#28
0
//游戏开始
bool CGameClientDlg::OnSubStart(const void * pBuffer, WORD wDataSize)
{
	if (wDataSize!=sizeof(CMD_S_GameStart)) return false;
	CMD_S_GameStart * psGameStart = (CMD_S_GameStart *)pBuffer;

	m_GameClientView.m_wndD3D.InitChess();

	int id;
	for(int i=0; i<GAME_PLAYER; i++)
	{
		id = SwitchViewChairID(i);
		m_GameClientView.m_wndD3D.m_bPlayState[id] = psGameStart->bPlayState[i];
		if(m_GameClientView.m_wndD3D.m_bPlayState[id] == GS_PLAYING)
			memcpy(m_GameClientView.m_wndD3D.m_Chess[id], psGameStart->bChess, sizeof(psGameStart->bChess));
	}

	if(!IsLookonMode())
	{
		//初始道具
		for(int i=0; i<5;i++)
		m_GameClientView.m_MyListView.m_ImplementCount[i] = psGameStart->bPropCnt[i];
		//定时器
		m_GameClientView.m_wndD3D.m_nTimeCounter = 0;
		m_GameClientView.m_wndD3D.m_bCanGame = true;
	}
	m_GameClientView.m_wndD3D.AccountChessCount();
	m_GameClientView.m_wndD3D.UpdateBackSurface();
	m_GameClientView.m_MyListView.UpdateImplementState();

	//关闭练习按钮
	m_GameClientView.m_MyListView.m_btExercise.EnableWindow(FALSE);

	//播放声音
	OnPlayMusic(IDM_MUSIC_START,0);
	OnPlayMusic(IDM_MUSIC_BG, 0);
	return true;
}
示例#29
0
//定时器消息
void CGameClientDlg::OnTimer(UINT nIDEvent)
{
	//倒数定时器
	if ((nIDEvent==IDI_GAME_TIMER)&&(m_wCurrentUser!=INVALID_CHAIR))
	{
		//设置视图
		if (m_wLeftClock[m_wCurrentUser]>0)
		{
			m_wLeftClock[m_wCurrentUser]--;
			m_GameClientView.SetUserClock(SwitchViewChairID(m_wCurrentUser),m_wLeftClock[m_wCurrentUser]);
		}
		
		//超时判断
		if ((IsLookonMode()==false)&&(GetMeChairID()==m_wCurrentUser))
		{
			if (m_wLeftClock[m_wCurrentUser]==0)
			{
				//发送消息
				SendData(SUB_C_GIVEUP_REQ);

				//设置界面
				m_GameClientView.m_btPeace.EnableWindow(FALSE);
				m_GameClientView.m_btRegret.EnableWindow(FALSE);
				m_GameClientView.m_btGiveUp.EnableWindow(FALSE);
				m_GameClientView.m_ChessBorad.SetPositively(false);

				return;
			}
			else if (m_wLeftClock[m_wCurrentUser]<=30) PlayGameSound(AfxGetInstanceHandle(),TEXT("GAME_WARN"));
		}

		return;
	}

	__super::OnTimer(nIDEvent);
}
示例#30
0
//游戏结束
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;
}