asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML lang=en xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>金扑克游戏</title>
<SCRIPT type=text/javascript>
/*
by river
http://www.rednetcn.com
2006-3-26
*/
var cards="0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,"; //整个扑克牌数组,抽取牌后自动减小a1-13,b1-b13,c1-c13,d1-d13
var fen,zhu,ju;
ju=1;
fen=10000;
//取得一张扑克牌
function markcard(){
var rnd=Math.floor(Math.random() * 13)+1;
var rcard=""; //=new card(pkey,"",rnd,"my");//"";
//pkey++;
var r=Math.floor(Math.random() * 4)+1;
if (r==1)rcard="a"+rnd; //黑桃
else if(r==2)rcard="b"+rnd;//红桃
else if(r==3)rcard="c"+rnd;//梅花
else if(r==4)rcard="d"+rnd;//方块


var oldlen=cards.length;
cards = cards.replace(rcard+",","");    // 更新剩余牌数组
if (oldlen==cards.length)return(markcard());
return(rcard);
}

//]]></SCRIPT>
<STYLE id=cardStyles type=text/css>
body{font-size: 12px;}
.pk {
 background-image: url(fb.gif);
 border-color: #808080 #000000 #000000 #808080;
 border-width: 1px;
 border-style: solid;
 font-size: 20pt;
 width: 3.75em;
 height: 5em;
 float:left;
 margin: 10px;
}

.card {
 BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #808080 1px solid; FONT-SIZE: 20pt; BACKGROUND-IMAGE: url(cardback.gif); BORDER-LEFT: #808080 1px solid; WIDTH: 3.75em; BORDER-BOTTOM: #000000 1px solid; POSITION: absolute; HEIGHT: 5em
}
.back{ background-image: url(fb.gif); /* 背景图片 */}
.front {
 WIDTH: 100%; COLOR: #000000; POSITION: absolute; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff
}
.red {
 COLOR: #ff0000
}
.hearts{COLOR: #ff0000}
.diams{COLOR: #ff0000}
.spades{COLOR: #000000}
.clubs{COLOR: #000000}

.index {
 FONT-WEIGHT: bold; FONT-SIZE: 50%; LEFT: 0.25em; POSITION: absolute; TOP: 0.25em; TEXT-ALIGN: center
}
.ace {
 FONT-SIZE: 300%; LEFT: 0.31em; POSITION: absolute; TOP: 0.25em
}
.face {
 BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; LEFT: 0.5em; BORDER-LEFT: #000000 1px solid; WIDTH: 2.6em; BORDER-BOTTOM: #000000 1px solid; POSITION: absolute; TOP: 0.45em; HEIGHT: 4em
}
.spotA1 {
 LEFT: 0.6em; POSITION: absolute; TOP: 0.5em
}
.spotA2 {
 LEFT: 0.6em; POSITION: absolute; TOP: 1.5em
}
.spotA3 {
 LEFT: 0.6em; POSITION: absolute; TOP: 2em
}
.spotA4 {
 LEFT: 0.6em; POSITION: absolute; TOP: 2.5em
}
.spotA5 {
 LEFT: 0.6em; POSITION: absolute; TOP: 3.5em
}
.spotB1 {
 LEFT: 1.55em; POSITION: absolute; TOP: 0.5em
}
.spotB2 {
 LEFT: 1.55em; POSITION: absolute; TOP: 1em
}
.spotB3 {
 LEFT: 1.55em; POSITION: absolute; TOP: 2em
}
.spotB4 {
 LEFT: 1.55em; POSITION: absolute; TOP: 3em
}
.spotB5 {
 LEFT: 1.55em; POSITION: absolute; TOP: 3.5em
}
.spotC1 {
 LEFT: 2.5em; POSITION: absolute; TOP: 0.5em
}
.spotC2 {
 LEFT: 2.5em; POSITION: absolute; TOP: 1.5em
}
.spotC3 {
 LEFT: 2.5em; POSITION: absolute; TOP: 2em
}
.spotC4 {
 LEFT: 2.5em; POSITION: absolute; TOP: 2.5em
}
.spotC5 {
 LEFT: 2.5em; POSITION: absolute; TOP: 3.5em
}
BODY {
 BACKGROUND-COLOR: #40a040;
 background-image:url(bg.gif)
}
#showinput {
 position:absolute;
 width:243px;
 height:29px;
 z-index:1;
 left: 376px;
 top: 210px;
 background-color: #FFFFFF;
 padding: 10px;
 border: 1px dotted #000000;
 vertical-align: middle;
}
#showinfo {
 position:absolute;
 width:200px;
 z-index:2;
 top: 397px;
 background-color: #007D00;
 border: 1px solid #000000;
 padding: 10px;
 font-size: 18px;
 font-weight: bold;
 color: #FFFFFF;
 left: 398px;
}
#fenshu{
 border: 1px none #FFFFFF;
}
#help{
float:left}
</STYLE>

<script language="JavaScript">
var p = new Array("","","","","","","","","","","","","","");//扑克数组
p[1]="<DIV class=card><DIV class='front beta'><DIV class=index>A<BR>&beta;</DIV><DIV class=ace>&beta;</DIV></DIV></DIV>";
p[2]="<DIV class=card><DIV class='front beta'><DIV class=index>2<BR>&beta;</DIV><DIV class=spotB1>&beta;</DIV><DIV class=spotB5>&beta;</DIV></DIV></DIV>";
p[3]="<DIV class=card><DIV class='front beta'><DIV class=index>3<BR>&beta;</DIV><DIV class=spotB1>&beta;</DIV><DIV class=spotB3>&beta;</DIV><DIV class=spotB5>&beta;</DIV></DIV></DIV>";
p[4]="<DIV class=card><DIV class='front beta'><DIV class=index>4<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[5]="<DIV class=card><DIV class='front beta'><DIV class=index>5<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotB3>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[6]="<DIV class=card><DIV class='front beta'><DIV class=index>6<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA3>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC3>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[7]="<DIV class=card><DIV class='front beta'><DIV class=index>7<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA3>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotB3>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC3>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[8]="<DIV class=card><DIV class='front beta'><DIV class=index>8<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA3>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotB2>&beta;</DIV><DIV class=spotB4>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC3>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[9]="<DIV class=card><DIV class='front beta'><DIV class=index>9<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA2>&beta;</DIV><DIV class=spotA4>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotB3>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC2>&beta;</DIV><DIV class=spotC4>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[10]="<DIV style='POSITION: relative'><DIV class=card><DIV class='front beta'><DIV class=index>10<BR>&beta;</DIV><DIV class=spotA1>&beta;</DIV><DIV class=spotA2>&beta;</DIV><DIV class=spotA4>&beta;</DIV><DIV class=spotA5>&beta;</DIV><DIV class=spotB2>&beta;</DIV><DIV class=spotB4>&beta;</DIV><DIV class=spotC1>&beta;</DIV><DIV class=spotC2>&beta;</DIV><DIV class=spotC4>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[11]="<DIV class=card><DIV class='front beta'><DIV class=index>J<BR>&beta;</DIV><IMG class=face height=130 alt='' src='jack.gif' width=80> <DIV class=spotA1>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[12]="<DIV class=card><DIV class='front beta'><DIV class=index>Q<BR>&beta;</DIV><IMG class=face height=130 alt='' src='queen.gif' width=80> <DIV class=spotA1>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
p[13]="<DIV class=card><DIV class='front beta'><DIV class=index>K<BR>&beta;</DIV><IMG class=face height=130 alt='' src='king.gif' width=80> <DIV class=spotA1>&beta;</DIV><DIV class=spotC5>&beta;</DIV></DIV></DIV>";
//var numarr(); //数组
var numarr = new Array(0,0,0,0,0,0);//数字
var harr = new Array("","","","","","");//花色
var old= new Array("","","","","","");//翻牌前代码
var h,num;

//}

 

function mkpk(){
//发牌
for (i=1;i<6;i++){
var getcard=markcard();
var number=getcard.substring(1,getcard.length);
var color=getcard.substring(0,1);
if (color=='a')color="spades";//"a"+rnd; //黑桃
else if(color=='b')color="hearts";//"b"+rnd;//红桃
else if(color=='c')color="clubs";//"c"+rnd;//梅花
else if(color=='d')color="diams";//"d"+rnd;//方块
numarr[i]=number;
harr[i]=color;

eval("document.getElementById('n"+i+"').innerHTML=p[number].replace(/beta/g,color);");

}
}

function f(id){
eval("if (document.getElementById('n"+id+"').innerHTML=='')document.getElementById('n"+id+"').innerHTML=old["+id+"];else {old["+id+"]=document.getElementById('n"+id+"').innerHTML;document.getElementById('n"+id+"').innerHTML='';}");
}

function fan(){
for (i=1;i<6;i++){
eval("var getcard=markcard();var color=getcard.substring(0,1);");
  if (color=='a')color="spades";//"a"+rnd; //黑桃
  else if(color=='b')color="hearts";//"b"+rnd;//红桃
  else if(color=='c')color="clubs";//"c"+rnd;//梅花
  else if(color=='d')color="diams";//"d"+rnd;//方块
eval("var number=getcard.substring(1,getcard.length);if (document.getElementById('n"+i+"').innerHTML==''){numarr["+i+"]=number;harr["+i+"]=color;document.getElementById('n"+i+"').innerHTML=p[number].replace(/beta/g,color);}");
}
var zhu=document.getElementById("put").value;

 
//至尊宝1:500
if(zhizunbao()&&tonghua())
eval("alert('恭喜你。至尊宝,赢了 "+zhu*500+"!');upfen("+zhu*500+");reju();")
//同花顺
else if(shunzi()&&tonghua())eval("alert('恭喜你。同花顺,赢了 "+zhu*100+"!');upfen("+zhu*100+");reju();")
//四条
else if(sitiao())eval("alert('恭喜你。四条,赢了 "+zhu*50+"!');upfen("+zhu*50+");reju();")
//同花
else if(tonghua())eval("alert('恭喜你。同花,赢了 "+zhu*16+"!');upfen("+zhu*16+");reju();")
//顺子
else if(shunzi())eval("alert('恭喜你。顺子,赢了 "+zhu*14+"!');upfen("+zhu*14+");reju();")
//三条1:5
else if(santiao())eval("alert('恭喜你。三条,赢了 "+zhu*5+"!');upfen("+zhu*5+");reju();")
//两对1:3
else if(liangdui())eval("alert('恭喜你。两对,赢了 "+zhu*3+"!');upfen("+zhu*3+");reju();")
//单对1:1
else if (dandui())eval("alert('恭喜你。单对,赢了 "+zhu+"!');upfen("+zhu+");reju();");
else eval("alert('对不起。你输了 "+zhu+"!');upfen("+(0-zhu)+");reju();");

}

//判断是否为单对1:1
function dandui(){
for (i=1;i<6;i++){
 for (j=1;j<i;j++)
  if ((numarr[i]==numarr[j])&&(numarr[j]==1||numarr[j]>10))return(true);
 }
}

//判断是否为两对1:3
function liangdui(){
var num1=-1;
for (i=1;i<6;i++){
 for (j=1;j<i;j++)
  if ((numarr[i]==numarr[j])&&(num1!=-1)&&(num1!=numarr[j]))return(true);
  else if(numarr[i]==numarr[j])num1=numarr[j];
 }
}

//判断是否为三条1:5
function santiao(){
var num1=-1;
for (i=1;i<6;i++){
 for (j=1;j<i;j++)
  if ((numarr[i]==numarr[j])&&(num1!=-1)&&(num1==numarr[j]))return(true);
  else if(numarr[i]==numarr[j])num1=numarr[j];
 }
}

//判断是否为顺子1:14
function shunzi(){
var temparr = new Array(0,numarr[1],numarr[2],numarr[3],numarr[4],numarr[5]);//排序用
for (i=1;i<6;i++){
 for (j=1;j<i;j++)
  if (temparr[i]<temparr[j]){
  var ti=temparr[i];
  temparr[i]=temparr[j];
  temparr[j]=ti;
  }
  //document.getElementById('debug').innerHTML+=temparr[i]+"<br>"
 }

for (i=1;i<5;i++){
 if(temparr[1]==1&&temparr[2]==10&&temparr[3]==11&&temparr[4]==12&&temparr[5]==13)return(true);
 else if((temparr[i]+1)!=temparr[i+1])return(false);
 else if(i==4)return(true);
 }
}


//判断是否为同花1:16
function tonghua(){
for (i=1;i<5;i++){
 if(harr[i]!=harr[i+1])return(false);
 else if(i==4)return(true);
 }
}

//判断是否为四条1:50
function sitiao(){
for (i=1;i<6;i++){
var n=0
 for(j=i;j<6;j++)
 if (numarr[i]==numarr[j])n++;
 if (n==4)return(true);
 }
}

//判断是否为至尊宝1:500
function zhizunbao(){
var temparr = new Array(0,numarr[1],numarr[2],numarr[3],numarr[4],numarr[5]);//排序用
for (i=1;i<6;i++){
 for (j=1;j<i;j++)
  if (temparr[i]<temparr[j]){
  var ti=temparr[i];
  temparr[i]=temparr[j];
  temparr[j]=ti;
  }
  //document.getElementById('debug').innerHTML+=temparr[i]+"<br>"
 }

for (i=1;i<5;i++){
 if(temparr[1]==1&&temparr[2]==10&&temparr[3]==11&&temparr[4]==12&&temparr[5]==13)return(true);
 }
}

window.onload=isload;
function isload(){
SetCookie("ju",1);
SetCookie("fen",10000);
document.getElementById("fenshu").value=10000;
}

function upfen(upfen){
var ju=parseInt(GetCookie("ju"));
var fen=parseInt(GetCookie("fen"));
SetCookie("fen",upfen+fen);
document.getElementById("fenshu").value=upfen+fen;
document.getElementById("showinfo").innerHTML = "下注:"+document.getElementById("put").value+"<br>分数:"+fen+"<br>操作:第 "+ju+" 局 ";//ss;

}

function upinfo(upfen){
var ju=parseInt(GetCookie("ju"));
var fen=parseInt(GetCookie("fen"));
SetCookie("ju",ju+1);
//SetCookie("fen",upfen+fen);


  if(document.getElementById("put").value<100)alert('最少下注100金币!');
  else if(document.getElementById("put").value>100000)alert('最多下注100000金币!');
  else if((document.getElementById("fenshu").value<=0)||(document.getElementById("fenshu").value<document.getElementById("put").value))alert('你哪有那么多金币呀!');
  else {
  mkpk();
  document.getElementById("fenshu").value=upfen+fen;
  document.getElementById("showinfo").innerHTML = "下注:"+document.getElementById("put").value+"<br>分数:"+fen+"<br>操作:第 "+ju+" 局 ";//ss;
  document.getElementById('showbotton').style.visibility='visible';
  document.getElementById('showinput').style.visibility='hidden';
  }

}

function reju(){
document.all.n1.innerHTML='';
document.all.n2.innerHTML='';
document.all.n3.innerHTML='';
document.all.n4.innerHTML='';
document.all.n5.innerHTML='';
document.getElementById('showinput').style.visibility='visible';
document.getElementById('showbotton').style.visibility='hidden';

old=new Array("","","","","","");//初始化翻牌前代码
cards="0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,"; //初始化整个扑克牌数组,防止为空

}

//设置Cookie的函数
function SetCookie(name,value){
     var argv=SetCookie.arguments;
     var argc=SetCookie.arguments.length;
     var expires=(2<argc)?argv[2]:null;
     var path=(3<argc)?argv[3]:null;
     var domain=(4<argc)?argv[4]:null;
     var secure=(5<argc)?argv[5]:false;
     document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}

//读取Cookie的函数
function GetCookie(Name) {
     var search = Name + "=";
     var returnvalue = "";
     if (document.cookie.length > 0) {
           offset = document.cookie.indexOf(search);
           if (offset != -1) {     
                 offset += search.length;
                 end = document.cookie.indexOf(";", offset);                       
                 if (end == -1)
                       end = document.cookie.length;
                 returnvalue=unescape(document.cookie.substring(offset,end));
           }
     }
     return returnvalue;
}

</script>
</head>

<body>
<div id="n1" class="pk back" onClick="f(1)"></div>
<div id="n2" class="pk back" onClick="f(2)"></div>
<div id="n3" class="pk back" onClick="f(3)"></div>
<div id="n4" class="pk back" onClick="f(4)"></div>
<div id="n5" class="pk back" onClick="f(5)"></div>
<div id="help">游戏说明:<br>
游戏开始前,输入赌注金币额度。按“下注”按钮开始游戏,游戏开始后,鼠标单击可以换牌,按“换牌”按钮确认操作。<br>
赔率:<br>
单对1:1&nbsp;&nbsp;
两对1:3<br>
三条1:5&nbsp;&nbsp;
顺子1:14<br>
同花1:16&nbsp;&nbsp;
四条1:50<br>
同花顺1:100&nbsp;&nbsp;
至尊宝1:500<br>
其中单对时对子必须是J,Q,K,A才算赔率。
<div id="showbotton" style="visibility:hidden"><input type="button" onClick="fan();" value="换牌"></div>
</div>
<div id="showinput">
你现在拥有金币数:
    <input name="fenshu" type="text" id="fenshu" size="10" readonly="">
  <p>请下注:
    <input name="put" type="text" id="put" value="1000" size="18">
    <label for="Submit" style=" visibility:visible"></label>
    <input type="button" name="Submit" value="下注" id="Submit" onClick="upinfo(0);">
  </p>
</div>
<div id="show"></div>
  <div id="showinfo" align='left' style='padding:20px 10px 20px 50px'>
下注:0<br>
分数:10000<br>
操作:第 0 局
</div>
</body>
</html>

posted on 2006-03-29 14:29 汪杰 阅读(505) 评论(0)  编辑 收藏 引用 所属分类: javascript
只有注册用户登录后才能发表评论。

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 466814
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜