VC++ 2008开发网络百家乐街机游戏(下)
2009-02-27 20:03:11 来源:WEB开发网4.2.3 系统管理功能组
系统管理功能组是后台服务端软件的核心部分,由【场局生成控制】、【游戏路单打印】、【历史营业记录】、【营业利润统计】及【营业日报打印】等几个模块组成。【场局生成控制】负责每场百家乐游戏的场局生成及开局操作;【游戏路单打印】在本场百家乐游戏开局后由游戏管理人员以密闭信封打印出来置于箱中,以便游戏结束后由玩家核对的确保游戏公平;其余三个模块是游戏运营的数据分析,可以根据运营商的需求以各种方式统计出游戏的运行效益。
4.2.3.1 场局生成控制
场局生成控制负责每一场百家乐游戏的路单生成,开局之后游戏根据此模块生成的路单运行每一局游戏,本游戏设计每场百家乐为一百八十局,因此做如下的界面设计:
场局生成控制中关键是根据百家乐游戏的规则设计出发牌函数,由计算机模拟发牌由此生成本场百家乐的全部发牌记录表与庄闲记录表。根据百家乐游戏的规则,计算机模拟百家乐发牌由闲家开始,再发庄家,
庄家与闲家各发两张牌后,分计出庄闲两家的牌点数再根据补牌规则表计算出第三张补牌,共模拟一百八十局场次,计算函数如下:
void CTH_ROUND_INIView::OnBnClickedScButton()
{
// TODO: 在此添加控件通知处理程序代码
……
//以循环方式发牌18行代表18轮
for(int i=0;i<18;i++)
{
CString* string_lpjl=new CString[10];
CString* string_fpjl=new CString[10];
//每局发牌每轮10场
for(int j=0;j<10;j++)
{
//庄家变量
int int_bankerindex1,int_bankerindex2,int_bankerindex3;
//闲家变量
int int_playindex1,int_playindex2,int_playindex3;
//庄家与闲家点数
int int_banker_sumpoint,int_play_sumpoint;
CString string_banker_sumpoint,string_play_sumpoint;
//计算机模拟随机抽牌,按先闲家后庄家的规则顺序,庄闲各发两张牌
int_playindex1=rand()%52+1;
int_bankerindex1=rand()%52+1;
int_playindex2=rand()%52+1;
int_bankerindex2=rand()%52+1;
//计算出合计的点数
int_banker_sumpoint=Return_resultpoint(Return_puckpoint(int_bankerindex1)+Return_puckpoint(int_bankerindex2));
int_play_sumpoint=Return_resultpoint(Return_puckpoint(int_playindex1)+Return_puckpoint(int_playindex2));
//根据百家乐第三张牌的发牌规则表,计算第三张发牌
if(int_banker_sumpoint>=8||int_play_sumpoint>=8)
{
string_lpjl[j]=Return_ysstring(int_banker_sumpoint,int_play_sumpoint);
string_banker_sumpoint.Format("%d|%d",int_bankerindex1,int_bankerindex2);
string_play_sumpoint.Format("%d|%d",int_playindex1,int_playindex2);
string_fpjl[j]=string_banker_sumpoint+"="+string_play_sumpoint;
}
else
{
int_playindex3=rand()%52+1;
int_bankerindex3=rand()%52+1;
, ; if(int_play_sumpoint==6||int_play_sumpoint==7)
{
, ; if(int_banker_sumpoint<=5)
{
int_banker_sumpoint=Return_resultpoint(int_banker_sumpoint+Return_puckpoint(int_bankerindex3));
string_lpjl[j]=Return_ysstring(int_banker_sumpoint,int_play_sumpoint);
string_banker_sumpoint.Format("%d|%d|%d",int_bankerindex1,int_bankerindex2,int_bankerindex3);
string_play_sumpoint.Format("%d|%d",int_playindex1,int_playindex2);
string_fpjl[j]=string_banker_sumpoint+"="+string_play_sumpoint;
}
else
{
string_lpjl[j]=Return_ysstring(int_banker_sumpoint,int_play_sumpoint);
string_banker_sumpoint.Format("%d|%d",int_bankerindex1,int_bankerindex2);
string_play_sumpoint.Format("%d|%d",int_playindex1,int_playindex2);
string_fpjl[j]=string_banker_sumpoint+"="+string_play_sumpoint;
}
}
else
{
int int_play3=Return_puckpoint(int_playindex3);
int_play_sumpoint=Return_resultpoint(int_play_sumpoint+int_play3);
if((int_banker_sumpoint==7)||(int_banker_sumpoint==6&&(int_play3==0||int_play3==1||int_play3==2||int_play3==3||int_play3==4||
int_play3==5||int_play3==8||int_play3==9)) ||(int_banker_sumpoint==5&&(int_play3==0||int_play3==1||int_play3==2||int_play3==3||int_play3==8||int_play3==9))
||(int_banker_sumpoint==4&&(int_play3==0||int_play3==1||int_play3==8||int_play3==9))
||(int_banker_sumpoint==3&&int_play3==8))
{
string_lpjl[j]=Return_ysstring(int_banker_sumpoint,int_play_sumpoint);
string_banker_sumpoint.Format("%d|%d",int_bankerindex1,int_bankerindex2);
string_play_sumpoint.Format("%d|%d|%d",int_playindex1,int_playindex2,int_playindex3);
string_fpjl[j]=string_banker_sumpoint+"="+string_play_sumpoint;
}
else
{ int_banker_sumpoint=Return_resultpoint(int_banker_sumpoint+Return_puckpoint(int_bankerindex3));
string_lpjl[j]=Return_ysstring(int_banker_sumpoint,int_play_sumpoint);
string_banker_sumpoint.Format("%d|%d|%d",int_bankerindex1,int_bankerindex2,int_bankerindex3);
string_play_sumpoint.Format("%d|%d|%d",int_playindex1,int_playindex2,int_playindex3);
string_fpjl[j]=string_banker_sumpoint+"="+string_play_sumpoint;
}
}
}
}
//将记录载入百家乐路单记录表
CString sql_lpjl="insert into th_round_lpjl(A,B,C,D,E,F,G,H,I,J) values('";
sql_lpjl+=string_lpjl[0];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[1];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[2];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[3];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[4];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[5];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[6];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[7];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[8];
sql_lpjl+="','";
sql_lpjl+=string_lpjl[9];
sql_lpjl+="')";
m_datado.Exec(sql_lpjl);
//将记录载入百家乐发牌记录表(注:每场的发牌记录与路单记录是一一对应的)
CString sql_fpjl="insert into th_round_fpjl(A,B,C,D,E,F,G,H,I,J) values('";
sql_fpjl+=string_fpjl[0];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[1];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[2];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[3];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[4];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[5];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[6];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[7];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[8];
sql_fpjl+="','";
sql_fpjl+=string_fpjl[9];
sql_fpjl+="')";
m_datado.Exec(sql_fpjl);
delete [] string_fpjl;
delete [] string_lpjl;
}
//数据库记录备份
CString sql_bak="insert into th_round_lpjl_bak select * from th_round_lpjl";
m_datado.Exec(sql_bak);
m_datado.Close();
}
catch(...)
{
MessageBox("数据错误!");
}
//刷新显示的记录表
Update_data();
}
else
{
MessageBox("请清空场局后再随机生成!","提示",MB_ICONINFORMATION);
}
更多精彩
赞助商链接