百人牛牛-控制+机器人【源码】
http://img.woaidaima.com//upload/image/20170519/1495155008965069640.jpghttp://img.woaidaima.com//upload/image/20170519/1495155010671053994.jpg// ClientControlItemSink.cpp : 实现文件//
#include "stdafx.h"
#include "Resource.h"
#include "ClientControlItemSink.h"
#include ".\clientcontrolitemsink.h"
#include "../游戏客户端/GameClientEngine.h"
// CClientControlItemSinkDlg 对话框
IMPLEMENT_DYNAMIC(CClientControlItemSinkDlg, IClientControlDlg)
CClientControlItemSinkDlg::CClientControlItemSinkDlg(CWnd* pParent /*=NULL*/)
: IClientControlDlg(CClientControlItemSinkDlg::IDD, pParent)
{
}
CClientControlItemSinkDlg::~CClientControlItemSinkDlg()
{
}
void CClientControlItemSinkDlg::DoDataExchange(CDataExchange* pDX)
{
IClientControlDlg::DoDataExchange(pDX);
}
//申请结果
bool __cdecl CClientControlItemSinkDlg::ReqResult(const void * pBuffer)
{
const CMD_S_CommandResult*pResult=(CMD_S_CommandResult*)pBuffer;
CString str;
switch(pResult->cbAckType)
{
case ACK_SET_WIN_AREA:
{
if(pResult->cbResult==CR_ACCEPT)
{
str=TEXT("输赢控制命令已经接受!");
SetTimer(1,1000,0);
}
else
{
str.Format(TEXT("请求失败!"));
m_cbExcuteTimes=0;
m_cbControlStyle=0;
ZeroMemory(m_bWinArea,sizeof(m_bWinArea));
SetTimer(1,1000,0);
}
break;
}
case ACK_RESET_CONTROL:
{
if(pResult->cbResult==CR_ACCEPT)
{
m_cbControlStyle=0;
m_cbExcuteTimes=0;
ZeroMemory(m_bWinArea,sizeof(m_bWinArea));
ReSetAdminWnd();
str="重置请求已接受!";
SetTimer(1,1000,0);
}
break;
}
case ACK_PRINT_SYN:
{
if(pResult->cbResult==CR_ACCEPT)
{
str="服务器同步请求已接受!";
tagAdminReq*pAdminReq=(tagAdminReq*)pResult->cbExtendData;
m_cbExcuteTimes=pAdminReq->m_cbExcuteTimes;
m_cbControlStyle=pAdminReq->m_cbControlStyle;
memcpy(m_bWinArea,pAdminReq->m_bWinArea,sizeof(m_bWinArea));
ReSetAdminWnd();
SetTimer(1,1000,0);
}
else
{
str.Format(TEXT("请求失败!"));
}
break;
}
default: break;
}
SetWindowText(str);
return true;
}
void CClientControlItemSinkDlg::ReSetAdminWnd()
{
if(m_cbControlStyle!=CS_BANKER_WIN&&m_cbControlStyle!=CS_BANKER_LOSE)
{
((CButton*)GetDlgItem(IDC_RADIO_WIN))->SetCheck(0);
((CButton*)GetDlgItem(IDC_RADIO_LOSE))->SetCheck(0);
}
else
{
((CButton*)GetDlgItem(IDC_RADIO_CT_BANKER))->SetCheck(1);
((CButton*)GetDlgItem(IDC_RADIO_CT_AREA))->SetCheck(0);
((CButton*)GetDlgItem(IDC_RADIO_WIN))->SetCheck(m_cbControlStyle==CS_BANKER_WIN?1:0);
((CButton*)GetDlgItem(IDC_RADIO_LOSE))->SetCheck(m_cbControlStyle==CS_BANKER_LOSE?1:0);
}
if(m_cbControlStyle==CS_BET_AREA)
{
((CButton*)GetDlgItem(IDC_RADIO_CT_BANKER))->SetCheck(0);
((CButton*)GetDlgItem(IDC_RADIO_CT_AREA))->SetCheck(1);
BYTE cbIndex=0;
for(;cbIndex<CONTROL_AREA;cbIndex++)
((CButton*)GetDlgItem(IDC_CHECK_TIAN+cbIndex))->SetCheck(m_bWinArea?1:0);
}
((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->SetCurSel(m_cbExcuteTimes>0?(m_cbExcuteTimes-1):-1);
OnRadioClick();
}
BEGIN_MESSAGE_MAP(CClientControlItemSinkDlg, IClientControlDlg)
ON_BN_CLICKED(IDC_BT_RESET,OnReSet)
ON_BN_CLICKED(IDC_BT_CANCEL,OnCancel)
ON_BN_CLICKED(IDC_BT_EXCUTE,OnExcute)
ON_BN_CLICKED(IDC_BT_CURSET,OnRefresh)
ON_BN_CLICKED(IDC_RADIO_CT_AREA,OnRadioClick)
ON_BN_CLICKED(IDC_RADIO_CT_BANKER,OnRadioClick)
ON_BN_CLICKED(IDC_BT_GET, OnBnClickedBtGet)
ON_BN_CLICKED(IDC_BT_CHEAK, OnBnClickedBtCheak)
END_MESSAGE_MAP()
// CClientControlItemSinkDlg 消息处理程序
void CClientControlItemSinkDlg::PrintCurStatus()
{
CString str;
switch(m_cbControlStyle)
{
case CS_BET_AREA:
{
str="胜利区域:";
BYTE cbIndex=0;
bool bFlags=false;
for(cbIndex=0;cbIndex<AREA_COUNT;cbIndex++)
{
if(m_bWinArea)
{
bFlags=true;
switch(cbIndex)
{
case 0:str+=TEXT("天 ");break;
case 1:str+=TEXT("地 ");break;
case 2:str+=TEXT("玄 ");break;
case 3:str+=TEXT("黄 ");break;
default: break;
}
}
}
if(!bFlags)
{
str+=TEXT("庄家通杀");
}
str.AppendFormat(TEXT(",执行次数:%d"),m_cbExcuteTimes);
break;
}
case CS_BANKER_WIN:
{
str.Format(TEXT("庄家受控,受控方式:赢,执行次数:%d"),m_cbExcuteTimes);break;
}
case CS_BANKER_LOSE:
{
str.Format(TEXT("庄家受控,受控方式:输,执行次数:%d"),m_cbExcuteTimes);break;
}
default: str=TEXT("非控制状态");break;
}
SetWindowText(str);
}
void CClientControlItemSinkDlg::OnBnClickedBtGet()
{
// TODO: 在此添加控件通知处理程序代码,这功能很不想做,前无古人后有来者wsj迋尐茳
CGameFrameEngine * pGameFrameEngine=CGameFrameEngine::GetInstance();
if (pGameFrameEngine!=NULL) pGameFrameEngine->PostMessage(IDM_GET_ACCOUNT,0,0);
}
void CClientControlItemSinkDlg::OnBnClickedBtCheak()
{
CMD_C_CheakAccount CheakAccount;
CString strNickName;
((CComboBox*)GetDlgItem(IDC_COMBO_GAMEID))->GetWindowText(strNickName);
myprintf(CheakAccount.dwUserAccount,sizeof(CheakAccount.dwUserAccount),_T("%s"),strNickName);
CGameFrameEngine * pGameFrameEngine=CGameFrameEngine::GetInstance();
if (pGameFrameEngine!=NULL) pGameFrameEngine->PostMessage(IDM_CHEAK_ACCOUNT,(WPARAM)&CheakAccount,0);
}
void CClientControlItemSinkDlg::OnRadioClick()
{
if(((CButton*)GetDlgItem(IDC_RADIO_CT_BANKER))->GetCheck()==1)
{
GetDlgItem(IDC_RADIO_LOSE)->EnableWindow(TRUE);
GetDlgItem(IDC_RADIO_WIN)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECK_TIAN)->EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_DI)->EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_XUAN)->EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_HUANG)->EnableWindow(FALSE);
}
else
{
if(((CButton*)GetDlgItem(IDC_RADIO_CT_AREA))->GetCheck())
{
GetDlgItem(IDC_RADIO_LOSE)->EnableWindow(FALSE);
GetDlgItem(IDC_RADIO_WIN)->EnableWindow(FALSE);
GetDlgItem(IDC_CHECK_TIAN)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECK_DI)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECK_XUAN)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECK_HUANG)->EnableWindow(TRUE);
}
}
}
void CClientControlItemSinkDlg::OnReSet()
{
CMD_C_AdminReq adminReq;
adminReq.cbReqType=RQ_RESET_CONTROL;
CGameFrameEngine * pGameFrameEngine=CGameFrameEngine::GetInstance();
if (pGameFrameEngine!=NULL) pGameFrameEngine->PostMessage(IDM_ADMIN_COMMDN,(WPARAM)&adminReq,0);
}
void CClientControlItemSinkDlg::OnRefresh()
{
CMD_C_AdminReq adminReq;
adminReq.cbReqType=RQ_PRINT_SYN;
CGameFrameEngine * pGameFrameEngine=CGameFrameEngine::GetInstance();
if (pGameFrameEngine!=NULL) pGameFrameEngine->PostMessage(IDM_ADMIN_COMMDN,(WPARAM)&adminReq,0);
}
void CClientControlItemSinkDlg::OnExcute()
{
BYTE cbIndex=0;
bool bFlags=false;
m_cbControlStyle=0;
m_cbExcuteTimes=0;
ZeroMemory(m_bWinArea,sizeof(m_bWinArea));
//控制庄家
if(((CButton*)GetDlgItem(IDC_RADIO_CT_BANKER))->GetCheck())
{
if(((CButton*)GetDlgItem(IDC_RADIO_WIN))->GetCheck())
{
m_cbControlStyle=CS_BANKER_WIN;
bFlags=true;
}
else
{
if(((CButton*)GetDlgItem(IDC_RADIO_LOSE))->GetCheck())
{
m_cbControlStyle=CS_BANKER_LOSE;
bFlags=true;
}
}
}
else //控制区域
{
if(((CButton*)GetDlgItem(IDC_RADIO_CT_AREA))->GetCheck())
{
m_cbControlStyle=CS_BET_AREA;
for(cbIndex=0;cbIndex<CONTROL_AREA;cbIndex++)
m_bWinArea=((CButton*)GetDlgItem(IDC_CHECK_TIAN+cbIndex))->GetCheck()?true:false;
bFlags=true;
}
}
m_cbExcuteTimes=(BYTE)((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->GetCurSel()+1;
//获取执行次数
if(m_cbExcuteTimes<=0)
{
bFlags=false;
}
if(bFlags) //参数有效
{
CMD_C_AdminReq adminReq;
adminReq.cbReqType=RQ_SET_WIN_AREA;
tagAdminReq*pAdminReq=(tagAdminReq*)adminReq.cbExtendData;
pAdminReq->m_cbExcuteTimes=m_cbExcuteTimes;
pAdminReq->m_cbControlStyle=m_cbControlStyle;
memcpy(pAdminReq->m_bWinArea,m_bWinArea,sizeof(m_bWinArea));
CGameFrameEngine * pGameFrameEngine=CGameFrameEngine::GetInstance();
if (pGameFrameEngine!=NULL) pGameFrameEngine->PostMessage(IDM_ADMIN_COMMDN,(WPARAM)&adminReq,0);
}
else
{
AfxMessageBox(TEXT("请选择受控次数以及受控方式!"));
OnRefresh();
}
}
void CClientControlItemSinkDlg::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
CDialog::OnCancel();
}
//初始化
BOOL CClientControlItemSinkDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO:在此添加额外的初始化
SetDlgItemText(IDC_BT_RESET,TEXT("取消控制"));
SetDlgItemText(IDC_BT_CURSET,TEXT("当前设置"));
SetDlgItemText(IDC_BT_EXCUTE,TEXT("执行"));
SetDlgItemText(IDC_BT_CANCEL,TEXT("取消"));
SetDlgItemText(IDC_RADIO_WIN,TEXT("庄家赢"));
SetDlgItemText(IDC_RADIO_LOSE,TEXT("庄家输"));
SetDlgItemText(IDC_RADIO_CT_BANKER,TEXT("庄家控制"));
SetDlgItemText(IDC_RADIO_CT_AREA,TEXT("区域控制"));
SetDlgItemText(IDC_CHECK_TIAN,TEXT("天"));
SetDlgItemText(IDC_CHECK_DI,TEXT("地"));
SetDlgItemText(IDC_CHECK_XUAN,TEXT("玄"));
SetDlgItemText(IDC_CHECK_HUANG,TEXT("黄"));
SetDlgItemText(IDC_STATIC_TIMES ,TEXT("控制次数"));
SetDlgItemText(IDC_STATIC_CHOICE,TEXT("控制选项"));
SetDlgItemText(IDC_STATIC_NOTICE,TEXT("说明"));
SetDlgItemText(IDC_STATIC_NOTICE1,TEXT("1.区域输赢控制比游戏库存控制策略优先。"));
SetDlgItemText(IDC_STATIC_NOTICE2,TEXT("2.区域控制,选中为胜,未选中为输。"));
((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->AddString(TEXT("1"));
((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->AddString(TEXT("2"));
((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->AddString(TEXT("3"));
((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->AddString(TEXT("4"));
((CComboBox*)GetDlgItem(IDC_COMBO_TIMES))->AddString(TEXT("5"));
((CButton*)GetDlgItem(IDC_RADIO_CT_AREA))->SetCheck(1);
OnRadioClick();
return TRUE;// return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void __cdecl CClientControlItemSinkDlg::OnAllowControl(bool bEnable)
{
GetDlgItem(IDC_BT_EXCUTE)->EnableWindow(bEnable);
}
void CClientControlItemSinkDlg::OnTimer(UINT nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
KillTimer(1);
PrintCurStatus();
CDialog::OnTimer(nIDEvent);
}
void CClientControlItemSinkDlg::ResetUserBet()
{
CString strPrint;
memset(m_lAllUserBet,0,sizeof(LONGLONG)*AREA_COUNT);
SetDlgItemText(IDC_ST_AREA1,TEXT("天:-----"));
SetDlgItemText(IDC_ST_AREA2,TEXT("地:-----"));
SetDlgItemText(IDC_ST_AREA3,TEXT("玄:-----"));
SetDlgItemText(IDC_ST_AREA4,TEXT("黄:-----"));
}
void CClientControlItemSinkDlg::SetUserBetScore(BYTE cbArea,LONGLONG lScore)
{
m_lAllUserBet+=lScore;
CString strPrint;
switch(cbArea)
{
case 0: strPrint.Format(TEXT("天:%I64d"),m_lAllUserBet);break;
case 1: strPrint.Format(TEXT("地:%I64d"),m_lAllUserBet);break;
case 2: strPrint.Format(TEXT("玄:%I64d"),m_lAllUserBet);break;
case 3: strPrint.Format(TEXT("黄:%I64d"),m_lAllUserBet);break;
default:false;
}
SetDlgItemText(IDC_ST_AREA1+cbArea,strPrint);
}
void CClientControlItemSinkDlg::SetUserGameScore(BYTE cbArea,LONGLONG lScore)
{
CString strPrint;
switch(cbArea)
{
case 0: strPrint.Format(TEXT("天:%I64d"),lScore);break;
case 1: strPrint.Format(TEXT("地:%I64d"),lScore);break;
case 2: strPrint.Format(TEXT("玄:%I64d"),lScore);break;
case 3: strPrint.Format(TEXT("黄:%I64d"),lScore);break;
default:false;
}
SetDlgItemText(IDC_ST_AREA5+cbArea,strPrint);
}
void CClientControlItemSinkDlg::SetUserNickName(CString strNickName)
{
((CComboBox*)GetDlgItem(IDC_COMBO_GAMEID))->AddString(strNickName);
((CComboBox*)GetDlgItem(IDC_COMBO_GAMEID))->SetCurSel(0);
}
void CClientControlItemSinkDlg::ResetUserNickName()
{
((CComboBox*)GetDlgItem(IDC_COMBO_GAMEID))->ResetContent();
}
页:
[1]