Exemplo n.º 1
0
//框架消息
bool CGameClientDlg::OnFrameMessage(WORD wSubCmdID, const void * pBuffer, WORD wDataSize)
{
	switch(wSubCmdID)
	{
	case SUB_GF_MESSAGE:		//系统消息
		{
			//效验参数
			CMD_GF_Message * pMessage=(CMD_GF_Message *)pBuffer;
			ASSERT(wDataSize>(sizeof(CMD_GF_Message)-sizeof(pMessage->szContent)));
			if (wDataSize<=(sizeof(CMD_GF_Message)-sizeof(pMessage->szContent))) return false;

			//关闭房间
			if (pMessage->wMessageType&SMT_CLOSE_GAME) 
			{
				//隐藏按钮
				m_GameClientView.m_btAutoStart.ShowWindow(SW_HIDE);
				m_GameClientView.m_btStart.ShowWindow(SW_HIDE);
				m_GameClientView.m_btExit.ShowWindow(SW_SHOW);

				//停止复位
				m_bReset = false;
				m_GameClientView.SetResetTag();
				ZeroMemory(m_bUserName,sizeof(m_bUserName));
				for (WORD i=0;i<GAME_PLAYER;i++)
				{
					//变量定义
					const tagUserData * pUserData=GetUserData(i);
					if(pUserData!=NULL)
					{
						//用户名字
						CopyMemory(&m_bUserName[i],pUserData->szName,sizeof(pUserData->szName));

						//用户姓别
						WORD wTemp = ((pUserData->cbGender==0)?2:1);
						m_GameClientView.SetUserGender(i,wTemp);
					}
				}

				//信息提示
				TCHAR szBuffer[1024]=TEXT("");
				_snprintf(szBuffer,CountArray(szBuffer),TEXT("\n[系统信息]"));
				InsertGeneralString(szBuffer,RGB(255,0,0),true);

				//_snprintf(szBuffer,sizeof(szBuffer),TEXT("你的金额少于%ld,不能继续游戏!"),m_lCellScore*3);
				InsertGeneralString(pMessage->szContent,RGB(0,0,255),true);

				//提示框
				m_GameClientView.m_Prompt.SetString(pMessage->szContent);

				//设置定时器
				m_GameClientView.SetNoScoreDlg();

				return true;
			}
		}
	}
	return false;
}
Exemplo n.º 2
0
//提示信息
LRESULT CGameClientDlg::OnShowInfo(WPARAM wParam, LPARAM lParam)
{
	//变量定义
	TCHAR szBuffer[64];
	_snprintf(szBuffer,CountArray(szBuffer),TEXT("[提示信息]:不能构成牛"));
	InsertGeneralString(szBuffer,RGB(255,128,0),true);

	return 0;
}
Exemplo n.º 3
0
//游戏结束
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;
}
Exemplo n.º 4
0
//游戏结束
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;
}
Exemplo n.º 5
0
//游戏结束
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;
}