»
Tiếng AnhTiếng PhápTiếng Việt

In - Chơi bài 5 lá - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Trò chơi » Chơi bài » Chơi bài 5 lá
URL: https://www.javascriptbank.com/solitaire-poker.html

Chơi bài 5 lá © JavaScriptBank.comHiệu ứng tạo ra một trò chơi JavaScript bài 5 lá đơn giản mà không dùng hình ảnh trên trang web.

Phiên bản đầy đủ: jsB@nk » Trò chơi » Chơi bài » Chơi bài 5 lá
URL: https://www.javascriptbank.com/solitaire-poker.html



CSS
<STYLE type=text/css>.control {DISPLAY: none; FONT-WEIGHT: bold; FONT-SIZE: 18px; LEFT: 200px; WIDTH: 100px; COLOR: white; POSITION: absolute; TOP: 10px; BACKGROUND-COLOR: black; TEXT-DECORATION: none}DIV {FONT-WEIGHT: bold}</STYLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<SCRIPT language=JavaScript type=text/javascript><!--window.onload=main;function main(){ createCards();}///////////////////////////////////////////////////////////////////////////////var indices=new Array();indices=["A","2","3","4","5","6","7","8","9","10","J","Q","K"];var suits=new Array();suits=(navigator.appName=="Netscape")?[" S"," H"," C"," D"]:["<br />S","<br />H","<br />C","<br />D"];var spades=new Array("","","","","","","","","","","","",""),hearts=new Array("","","","","","","","","","","","",""),clubs=new Array("","","","","","","","","","","","",""),diamonds=new Array("","","","","","","","","","","","","");var deck=new Array();deck=[spades,hearts,clubs,diamonds];///////////////////////////////////////////////////////////////////////////////function createCards(){var gcount=0; while(gcount<4) {  for(var x=0;x<indices.length;x++) { deck[gcount][x]+=indices[x]+suits[gcount]; }  gcount++; }}///////////////////////////////////////////////////////////////////////////////var identify=0;function deal(num){   randI=Math.floor(Math.random()*suits.length);   randS=Math.floor(Math.random()*indices.length); if(deck[randI][randS]!="-") { a=document.createElement('a');   a.id="aid"+identify;  a.href="javascript:discard('"+identify+"')"; a.innerHTML=(navigator.appName=="Netscape")?" --&gt ":"-&gt<br />D<br />-&gt"; with(a.style) {   fontWeight="bold"; textDecoration="none"; color="black"; height=70; }    spans=document.createElement("spans"); spans.id="sid"+identify; spans.className="card"; spans.innerHTML=(navigator.appName=="Netscape")?"<b>"+deck[randI][randS]+"<tt style='color:gray'>|</tt></b>":"<b>"+deck[randI][randS]+"</b>";  with(spans.style)  {    textAlign="center";    width=80;  height=100;    border="3 inset black";  fontSize=40;  } if(spans.innerHTML.indexOf("S")==-1&&spans.innerHTML.indexOf("C")==-1){spans.style.color="red";}else{spans.style.color="black";}  document.body.appendChild(a); document.body.appendChild(spans); deck[randI][randS]="-";  identify++; } else {   redeal(); }}var unique=0;var tcount=0;function dealersHand(){adapt=Math.floor(Math.random()*10);if(adapt<4){}else if (adapt==4){   while(tcount<2)   {    for(var move=0;move<13;move++)    {      if(deck[tcount][move]!="-")    {      deck[tcount][move]="-";    }    }    tcount++;   }}else{   while(tcount<4)   {    for(var move=1;move<=7;move++)    {      if(deck[tcount][move]!="-")    {      deck[tcount][move]="-";    }    }    tcount++;   }}   randI=Math.floor(Math.random()*suits.length);   randS=Math.floor(Math.random()*indices.length); if(deck[randI][randS]!="-") {   old=document.getElementById('dealer'+unique);   spans=document.createElement("spans"); spans.id="sid"+identify; spans.className="card"; spans.innerHTML=(navigator.appName=="Netscape")?"<b>"+deck[randI][randS]+"<tt style='color:gray'>|</tt></b>":"<b>"+deck[randI][randS]+"</b>";  with(spans.style)  {    textAlign="center";    width=50;  height=10;    border="2 inset black";  fontSize=30;  } if(spans.innerHTML.indexOf("S")==-1&&spans.innerHTML.indexOf("C")==-1){spans.style.color="red";}else{spans.style.color="black";} document.body.replaceChild(spans,old);  deck[randI][randS]="-";  unique++; }  else {   redealDealer(); }}function redeal(){ deal();}function redealDealer(){  dealersHand();}function amt(num){ for(var x=0;x<num;x++)  deal();}var dcount=0;function discard(i){document.getElementById('sid'+i).style.display="none";document.getElementById('aid'+i).style.display="none";dcount++;}function draw(){  for(var x=0;x<dcount;x++) deal();  dcount=0;}function dealIn(){  for(var y=0;y<5;y++) dealersHand(); }function hide(i){ document.getElementById('caid'+i).style.display='none';}function show(i){ document.getElementById('caid'+i).style.display="block";}//--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<A class=control id=caid0 style="DISPLAY: block" href="javascript:amt(5);hide(0);show(1)">Deal</A><B style="VISIBILITY: hidden">___</B><A class=control id=caid1 href="javascript:draw();hide(1);show(2)">Draw</A><B style="VISIBILITY: hidden">___</B><A class=control id=caid2 href="javascript:dealIn();hide(2);show(3)">ShowDown</A><B style="VISIBILITY: hidden">___</B><A class=control id=caid3 href="javascript:history.go(0)">Play Again</A> </CENTER><B>Dealer&#39;s Hand: </B><BR><SPAN id=dealer0>* </SPAN><SPAN id=dealer1>* </SPAN><SPAN id=dealer2>* </SPAN><SPAN id=dealer3>* </SPAN><SPAN id=dealer4>* </SPAN><SPAN id=dealer5></SPAN><SPAN id=dealer6></SPAN><SPAN id=dealer7></SPAN><BR><BR><H1>Your Hand:</H1><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->