|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
还有就是总有人问我到底该学习什么语言,什么语言有前途,那么我的回答是不论是C,C++,java,.net,ruby,asp或是其他语言都可以学,编程的关键不是语言,而是思想。jspublicclassDataPoke{
StringpokeFace;//牌面
Stringpokepoint;//点数
StringpokeColor;//花样
StringpokeImgPath;//扑克图片对应地点
booleanuseFlag=false;//是不是利用标志false未利用,true利用中
publicDataPoke(){
}
publicvoidsetuserFlag(booleanflag){
this.useFlag=flag;
}
publicbooleangetuserFlag(){
returnthis.useFlag;
}
publicStringgetPoint(){
returnthis.pokepoint;
}
publicStringgetColor(){
returnthis.pokeColor;
}
publicStringgetImgPath(){
returnthis.pokeImgPath;
}
publicStringgetpokeFace(){
returnthis.pokeFace;
}
}
///////////////////////////////////////////////////////////////////////
importjava.util.*;
publicclasspokeBean{
privateString[]color={"black","red","flower","sequa"};
privateStringpokeImgurl="/m/g/bj/images/";
privateLinkedListpokeList=newLinkedList();//poke链表列表
DataPoke[]dataPoke=newDataPoke[52];
publicpokeBean(){
}
publicvoidinitPokeList(){
for(inti=0;i<=51;i++)
{
dataPoke[i]=newDataPoke();//初始化52个datapoke类变量存储
}
intover=10;
intcount=0;
for(inti=1;i<=13;i++){
for(intj=1;j<=4;j++){
if(i<10)
dataPoke[count].pokepoint=""+i;//点数1-10
else
dataPoke[count].pokepoint=""+over;//点数11-13
dataPoke[count].pokeFace=""+i;//牌面
dataPoke[count].pokeColor=color[j-1];//牌色1-4:黑红梅方
dataPoke[count].pokeImgPath=pokeImgurl+Integer.toString(i)+"/"+Integer.toString(j)+".png";
dataPoke[count].setuserFlag(false);
pokeList.add(count,dataPoke[count]);//将用外部类DataPoke初始化好的52张牌安排于LinkedList中
//System.out.println("afterinsertpoke---------="+count);
count=count+1;
}
}
}
//初始化终了后,举行洗牌//这里临时不必此功效
publicvoidwashPokeList(){
inttemp1=0;
inttemp2=0;
LinkedListpokeListtemp=newLinkedList();
for(inti=0;i<this.pokeList.size();i++){
temp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
while(temp2==temp1)
temp1=(int)(Math.random()*100)%51;//假如呈现反复的随机数,从头取
pokeListtemp.add(i,this.pokeList.get(temp1));//顺次将乱序的pokeData对象拔出
temp2=temp1;
}
setuserLinklist(pokeListtemp);
}
publicLinkedListgetuserLinklist(){
returnthis.pokeList;
}
publicvoidsetuserLinklist(LinkedListpokeListtemp){
this.pokeList=pokeListtemp;
}
publicvoidprintBack(){
LinkedListtemp=getuserLinklist();
for(inti=0;i<temp.size();i++){
DataPoketempDP=(DataPoke)temp.get(i);
System.out.println("********************"+i+"*********************");
System.out.println("------------牌面"+tempDP.pokeFace);
System.out.println("------------点数"+tempDP.pokepoint);
System.out.println("------------花样"+tempDP.pokeColor);
System.out.println("------------地点"+tempDP.pokeImgPath);
System.out.println("------------是不是利用中"+tempDP.useFlag);
}
}
}
/////////////////////////////////////////////////////////////////////////////
publicclasspackageDb{
privateStringuserName;//用户名
privateStringuserPswd;//暗码
privatelongnumuserguid;//用户GUID
privatelongnumsex;//用户性别
privatelongnumage;//用户岁数
privatelongnummoney;//用户点数
privatelongnumwincount;//用户成功局数
privatelongnumlostcount;//用户失利局数
publicpackageDb(){
}
//////////////////////////////////////////numwincount
publiclonggetNumwincount(){
returnthis.numwincount;
}
publicvoidsetNumwincount(longnumwincount){
this.numwincount=numwincount;
}
//////////////////////////////////////////numlostcount
publiclonggetNumlostcount(){
returnthis.numlostcount;
}
publicvoidsetNumlostcount(longnumlostcount){
this.numlostcount=numlostcount;
}
//////////////////////////////////////////numuserguid
publiclonggetNumuserguid(){
returnthis.numuserguid;
}
publicvoidsetNumuserguid(longnumuserguid){
this.numuserguid=numuserguid;
}
///////////////////////////////////////////numsex
publiclonggetNumsex(){
returnthis.numsex;
}
publicvoidsetNumsex(longnumsex){
this.numsex=numsex;
}
////////////////////////////////////////////numage
publiclonggetNumage(){
returnthis.numage;
}
publicvoidsetNumage(longnumage){
this.numage=numage;
}
////////////////////////////////////////////nummoney
publiclonggetNummoney(){
returnthis.nummoney;
}
publicvoidsetNummoney(longnummoney){
this.nummoney=nummoney;
}
////////////////////////////////////////////userName
publicStringgetUserName(){
returnthis.userName;
}
publicvoidsetUserName(StringuserName){
this.userName=userName;
}
////////////////////////////////////////////掏出用户基础信息,需先setUserGuid()
publicvoidgetUserInfo()throwsException{
Stringsql="select*fromUSERwhereNUMUSERGUID="+numuserguid+"";
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
if(DBwork.result.next())
{
setUserName(DBwork.result.getString("VC2USERNAME"));
setNummoney(DBwork.result.getLong("NUMMONEY"));
setNumage(DBwork.result.getLong("NUMAGE"));
setNumsex(DBwork.result.getLong("NUMSEX"));
setNumlostcount(DBwork.result.getLong("NUMLOSTCOUNT"));
setNumwincount(DBwork.result.getLong("NUMWINCOUNT"));
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("getUserInfo掏出用户基础信息堕落"+e);
}
}
/////////////////////////////////////////////反省新用户注册名是不是占用
publicbooleancheckUserInfo(StringuserNameNew)throwsException{
Stringsql="select*fromUSERwhereVC2USERNAME="+userNameNew+"";
//System.out.println("-------------before-sql:"+sql);
booleantemp=true;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
//System.out.println("-------------after-sql:"+sql);
if(DBwork.result.next())
{
temp=true;
}else{
temp=false;
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("checkUserInfo反省新用户注册名是不是占用堕落"+e);
}
returntemp;//用户名已被占用,前往true,不然前往false;
}
/////////////////////////////////////////////拔出新用户注册信息
publicvoidinsertUserNew(StringuserNamenew,Stringpassword,longsex,longage)throwsException{
Stringsql="insertintoUSER(NUMUSERGUID,VC2USERNAME,VC2PASSWORD,NUMSEX,NUMAGE)values(";
sql=sql+"MOBJSEQ.NEXTVAL,";
sql=sql+userNamenew+",";
sql=sql+password+",";
sql=sql+sex+",";
sql=sql+age+")";
//System.out.println("-------------before-sql:"+sql);
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
//System.out.println("------------after--sql:"+sql);
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("insertUserNew拔出新用户注册信息堕落"+e);
}
}
/////////////////////////////////////////////依据用户名失掉用户guid
publiclonggetUserGuid(Stringun)throwsException{
Stringsql="selectNUMUSERGUIDfromUSERwhereVC2USERNAME="+un+"";//
longtemp=0;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
if(DBwork.result.next())
{
temp=DBwork.result.getLong("NUMUSERGUID");
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("getUserGuid依据用户名失掉用户guid堕落"+e);
}
returntemp;
}
/////////////////////////////////////////////反省老用户上岸
publicbooleancheckUserOld(StringuserNameOld,Stringpassword)throwsException{
Stringsql="select*fromUSERwhereVC2USERNAME="+userNameOld+"andVC2PASSWORD="+password+"";
booleantemp=true;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
if(DBwork.result.next())
{
temp=true;
}else{
temp=false;
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("checkUserOld反省老用户上岸堕落"+e);
}
returntemp;//老用户的上岸用户名和暗码准确无误,前往true,不然前往false;
}
/////////////////////////////////////////////更新用户数据
publicvoidupdateUser(longuserGuid,longuserMoney,longwinCount,longlostCount)throwsException{
Stringsql="updateUSERsetNUMMONEY="+userMoney+",NUMWINCOUNT="+winCount+",NUMLOSTCOUNT="+lostCount+"whereNUMUSERGUID="+userGuid;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("updateUser更新用户数据堕落"+e);
}
}
}
///////////////////////////////////////////////////////
importjavax.servlet.http.*;
importjavax.servlet.ServletRequest;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpSession;
importjavax.servlet.jsp.PageContext;
importjava.util.*;//随机数必要利用
importjava.lang.*;
publicclassgamePai{
privateHttpSessionpaiSession;
privatepokeBeanuserPokeBean;
publicgamePai(){
}
//取点数user
publicintgetPointuser(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
intuserValue=0;
//用户点数盘算
for(inti=0;i<pokeLuser.size();i++){
userValue=userValue+Integer.parseInt(((DataPoke)pokeLuser.get(i)).getPoint());
}
returnuserValue;
}
//取点数pc
publicintgetPointpc(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intpcValue=0;
//电脑点数盘算
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
returnpcValue;
}
//判别是不是另有牌//不必作了,由于加了判别标记位
publicbooleangetPaiStatus(PageContextpagecontext)
{
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLall=(LinkedList)session.getAttribute("poketotal");
if(pokeLall.size()<=4)//小于四张牌,就要从头洗牌了
returntrue;
returnfalse;
}
//持续起牌,玩家挪用,每次起牌以后,必要jsp叶面举行判别是不是爆牌,是不是跳转等
publicvoidgetNextPaiuser(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLall=(LinkedList)session.getAttribute("poketotal");
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
inttemp=(int)(Math.random()*100)%51;//取1-52之间的随机数
while(((DataPoke)pokeLall.get(temp)).getuserFlag()){
temp=(int)(Math.random()*100)%51;
}
pokeLuser.add(pokeLall.get(temp));
((DataPoke)pokeLall.get(temp)).setuserFlag(true);
session.setAttribute("pokeuser",pokeLuser);//拔出用户失掉的牌
session.setAttribute("poketotal",pokeLall);//更新总牌
}
//判别电脑的分数是不是低于16点,低于16点,就前往真,必要电脑主动加牌
//这里应当有jsp叶面挪用
publicbooleanjudgeAddPc16(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intpcValue=0;
//用户点数盘算
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
if(pcValue<=16&&pcValue<=21)//满意小于16,然后加了牌以后满意小于21,就再加
returntrue;
returnfalse;
}
//判别电脑的分数是不是高于17点,低于21点,就前往真,必要电脑主动加牌
//这里应当有jsp叶面挪用
publicbooleanjudgeAddPc21(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intpcValue=0;
//用户点数盘算
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
if(pcValue>=17&&pcValue<=21)
returntrue;
returnfalse;
}
//电脑要牌
publicvoidgetNextPaipc(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLall=(LinkedList)session.getAttribute("poketotal");
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
inttemp=(int)(Math.random()*100)%51;//取1-52之间的随机数
while(((DataPoke)pokeLall.get(temp)).getuserFlag()){
temp=(int)(Math.random()*100)%51;
}
pokeLpc.add(pokeLall.get(temp));
((DataPoke)pokeLall.get(temp)).setuserFlag(true);
session.setAttribute("pokepc",pokeLpc);//拔出用户失掉的牌
session.setAttribute("poketotal",pokeLall);//更新总牌
}
//jsp叶面挪用判别user是不是爆牌,true,爆牌,在叶面举行跳转到爆牌叶面
publicbooleanjudgeBusrtuser(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
intuserValue=0;
for(inti=0;i<pokeLuser.size();i++){
userValue=userValue+Integer.parseInt(((DataPoke)pokeLuser.get(i)).getPoint());
if(userValue>21)
returntrue;
}
returnfalse;
}
//判别pc是不是爆牌,true,爆牌
publicbooleanjudgeBusrtpc(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intpcValue=0;
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
if(pcValue>21)
returntrue;
}
returnfalse;
}
//获得扑克牌列表user
publicArrayListgetPaiListUser(PageContextpageContext){
ArrayListtemplistuser=newArrayList();
HttpSessionsession=pageContext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
for(inti=0;i<pokeLuser.size();i++){
templistuser.add(((DataPoke)pokeLuser.get(i)).getImgPath());
}
returntemplistuser;
}
//获得扑克牌列表pc
publicArrayListgetPaiListPc(PageContextpageContext){
ArrayListtemplistpc=newArrayList();
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
for(inti=0;i<pokeLpc.size();i++){
templistpc.add(((DataPoke)pokeLpc.get(i)).getImgPath());
}
returntemplistpc;
}
//开牌形貌封装
publicStringgetKaiPaiDesc(intresultPai){
if(resultPai==2){return"玩家胜!";}
if(resultPai==3){return"农户胜!";}
if(resultPai==4){return"农户BlackJack,农户胜!";}
if(resultPai==5){return"玩家BlackJack,玩家胜!";}
if(resultPai==6){return"玩家爆牌!农户胜!";}
if(resultPai==7){return"农户爆牌!玩家胜!";}
return"";
}
//开牌
publicintkaiPai(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intuserValue=0;
intpcValue=0;
//用户点数盘算
for(inti=0;i<pokeLuser.size();i++){
//DataPokepokeuser=(DataPoke)pokeLuser.get(i);
userValue=userValue+Integer.parseInt(((DataPoke)pokeLuser.get(i)).getPoint());
}
//电脑点数盘算
for(inti=0;i<pokeLpc.size();i++){
//DataPokepokepc=(DataPoke)pokeLpc.get(i);
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
//电脑blackJack,电脑成功
if(pokeLpc.size()==2){
//DataPokepokepcF=(DataPoke)pokeLpc.getFirst();
//DataPokepokepcL=(DataPoke)pokeLpc.getLast();
if(((DataPoke)pokeLpc.getFirst()).getpokeFace().equals("1")&&((DataPoke)pokeLpc.getLast()).getpokeFace().equals("11")||
((DataPoke)pokeLpc.getFirst()).getpokeFace().equals("1")&&((DataPoke)pokeLpc.getLast()).getpokeFace().equals("11")){
return4;//电脑blackJack,电脑成功
}
}
//玩家blackJack,玩家成功,分数更加
if(pokeLuser.size()==2){
//DataPokepokeuserF=(DataPoke)pokeLuser.getFirst();
//DataPokepokeuserL=(DataPoke)pokeLuser.getLast();
if(((DataPoke)pokeLuser.getFirst()).getpokeFace().equals("1")&&((DataPoke)pokeLuser.getLast()).getpokeFace().equals("11")||
((DataPoke)pokeLuser.getLast()).getpokeFace().equals("1")&&((DataPoke)pokeLuser.getFirst()).getpokeFace().equals("11")){
return5;//玩家blackJack,玩家成功,分数更加
}
}
if(userValue>pcValue)
return2;//2为玩家成功
if(userValue<=pcValue&&pcValue<=21)
return3;//3为电脑成功
if(userValue>21)
return6;//玩家爆牌
if(pcValue>21&&userValue<=21)
return7;//电脑爆牌
return0;
}
publicvoidinitPai(PageContextpagecontext)
{
userPokeBean=newpokeBean();
paiSession=pagecontext.getSession();//初始化失掉session
userPokeBean.initPokeList();//初始化52扑克
LinkedListpokelistAll=userPokeBean.getuserLinklist();
LinkedListpokelistuser=newLinkedList();
LinkedListpokelistpc=newLinkedList();
//userPokeBean.washPokeList();//初始化以后洗扑克,有成绩,不克不及洗牌
paiSession.setAttribute("poketotal",pokelistAll);//将初始化并洗好的扑克安排于该玩家session中
paiSession.setAttribute("pokeuser",pokelistuser);//初始化用户扑克数据
paiSession.setAttribute("pokepc",pokelistpc);//初始化电脑扑克数据
//userPokeBean.printBack();//打出牌看看
}
//年夜印出来检测一下
publicvoidprintPai()
{
userPokeBean.printBack();
}
//每次从头残局,都要将52张扑克牌的利用标记置为false,未利用
publicvoidresetPai(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeList=(LinkedList)session.getAttribute("poketotal");
for(inti=0;i<pokeList.size();i++){
((DataPoke)pokeList.get(i)).setuserFlag(false);//一切的牌置为false,未利用
}
session.setAttribute("poketotal",pokeList);//更新总牌
}
//第一次起牌,在扑克牌中随机抽取四张,分离派给玩家和电脑
publicvoidgetFirstPaiuser(PageContextpagecontext)
{
HttpSessionsession=pagecontext.getSession();
//先获得用户的数据
LinkedListpokeListtempuser=(LinkedList)session.getAttribute("pokeuser");
pokeListtempuser.clear();//清空用户扑克数据列表
//LinkedListpokeListtempPC=newLinkedList();
//先从52张点数牌中随机抽取4张,分离为玩家的两张和农户的两张
intinttemp1=0;
intinttemp2=0;
//先将总牌掏出
//paiSession
LinkedListpokeListtempall1=(LinkedList)session.getAttribute("poketotal");
//给玩家的牌
//for(inti=0;i<2;i++){//从两头取2张牌给玩家
//inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
//inttemp2=(int)(Math.random()*100)%51;
while(inttemp1==inttemp2){
inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
inttemp2=(int)(Math.random()*100)%51;
}
pokeListtempuser.add(pokeListtempall1.get(inttemp1));
pokeListtempuser.add(pokeListtempall1.get(inttemp2));
((DataPoke)pokeListtempall1.get(inttemp1)).setuserFlag(true);
((DataPoke)pokeListtempall1.get(inttemp2)).setuserFlag(true);
//while(inttemp2==inttemp1&&(((DataPoke)pokeListtempall1.get(inttemp1)).getuserFlag()))//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp1=(int)(Math.random()*100)%51;
//pokeListtempuser.add(pokeListtempall1.get(inttemp1));
//System.out.println("给玩家的牌的地点:"+((DataPoke)pokeListtempall1.get(inttemp1)).getImgPath());
//System.out.println("给玩家的牌的牌面点数:"+((DataPoke)pokeListtempall1.get(inttemp1)).getpokeFace());
//System.out.println("******************************************************");
//pokeListtempuser.a
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall1.get(inttemp1)).setuserFlag(true);
//inttemp2=inttemp1;
//}
session.setAttribute("pokeuser",pokeListtempuser);//拔出用户失掉的牌到用户的session中
session.setAttribute("poketotal",pokeListtempall1);//更新总牌
//从取后的牌中再取2张给电脑
//intinttemp3=0;
//intinttemp4=0;
//再将总牌掏出
//LinkedListpokeListtempall2=(LinkedList)session.getAttribute("poketotal");
//for(inti=0;i<2;i++){//从取后的总牌中再取2张牌给电脑
//inttemp3=(int)(Math.random()*100)%51;//取1-52之间的随机数1
//while(inttemp4==inttemp3&&(((DataPoke)pokeListtempall2.get(inttemp3)).getuserFlag()))//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp3=(int)(Math.random()*100)%51;
//pokeListtempPC.add(i,pokeListtempall2.get(inttemp3));
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall2.get(inttemp3)).setuserFlag(true);
//inttemp4=inttemp3;
//}
//session.setAttribute("pokepc",pokeListtempPC);//拔出电脑失掉的牌到用户的session中
//session.setAttribute("poketotal",pokeListtempall2);//更新总牌
try{
Thread.sleep(30);
}catch(Exceptionex){
ex.printStackTrace();
}
}
publicvoidgetFirstPaipc(PageContextpagecontext)
{
HttpSessionsession=pagecontext.getSession();
//LinkedListpokeListtempuser=newLinkedList();
LinkedListpokeListtempPC=(LinkedList)session.getAttribute("pokepc");
pokeListtempPC.clear();
//先从52张点数牌中随机抽取4张,分离为玩家的两张和农户的两张
//intinttemp1=0;
//intinttemp2=0;
//先将总牌掏出
//paiSession
//LinkedListpokeListtempall1=(LinkedList)session.getAttribute("poketotal");
//给玩家的牌
//for(inti=0;i<2;i++){//从两头取2张牌给玩家
//inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数1
//while(inttemp2==inttemp1&&(((DataPoke)pokeListtempall1.get(inttemp1)).getuserFlag()))//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp1=(int)(Math.random()*100)%51;
//pokeListtempuser.add(i,pokeListtempall1.get(inttemp1));
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall1.get(inttemp1)).setuserFlag(true);
//inttemp2=inttemp1;
//}
//session.setAttribute("pokeuser",pokeListtempuser);//拔出用户失掉的牌到用户的session中
//session.setAttribute("poketotal",pokeListtempall1);//更新总牌
//再将总牌掏出
LinkedListpokeListtempall=(LinkedList)session.getAttribute("poketotal");
intinttemp1=0;
intinttemp2=0;
while(inttemp1==inttemp2||
((DataPoke)pokeListtempall.get(inttemp1)).getuserFlag()==true||
((DataPoke)pokeListtempall.get(inttemp2)).getuserFlag()==true)
{
inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
inttemp2=(int)(Math.random()*100)%51;
}
pokeListtempPC.add(pokeListtempall.get(inttemp1));
pokeListtempPC.add(pokeListtempall.get(inttemp2));
((DataPoke)pokeListtempall.get(inttemp1)).setuserFlag(true);
((DataPoke)pokeListtempall.get(inttemp2)).setuserFlag(true);
//从取后的牌中再取2张给电脑
//for(inti=0;i<2;i++){//从取后的总牌中再取2张牌给电脑
//inttemp3=(int)(Math.random()*100)%51;//取1-52之间的随机数1
//while(inttemp4==inttemp3&&(((DataPoke)pokeListtempall2.get(inttemp3)).getuserFlag())==true)//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp3=(int)(Math.random()*100)%51;
//pokeListtempPC.add(pokeListtempall2.get(inttemp3));
//System.out.println("给电脑的牌的地点:"+((DataPoke)pokeListtempall2.get(inttemp3)).getImgPath());
//System.out.println("给电脑的牌的牌面点数:"+((DataPoke)pokeListtempall2.get(inttemp3)).getpokeFace());
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall2.get(inttemp3)).setuserFlag(true);
//inttemp4=inttemp3;
//}
session.setAttribute("pokepc",pokeListtempPC);//拔出电脑失掉的牌到用户的session中
session.setAttribute("poketotal",pokeListtempall);//更新总牌
try{
Thread.sleep(30);
}catch(Exceptionex){
ex.printStackTrace();
}
}
}
但是我同意你的观点,对于大型项目来说,应该是采用框架的一部分,根据功能的不同而改进,欢迎你能再提出些宝贵意见,我会多多学习的。说到jbuilder,我可能是个人感觉,用的时候确实没有vs爽,我最喜欢的IDE是netbeans,谢谢。 |
|