»
EnglishFrenchVietnamese

Print - Dice Poker - JavaScriptBank.com

Full version: jsB@nk » Game » Poker » Dice Poker
URL: https://www.javascriptbank.com/dice-poker.html

Dice Poker © JavaScriptBank.comClick [ROLL] to roll five dice. You win points by getting special combinations of dice, such as four of a kind, etc. Dice are shown but no image files are used! Changeable colors as well! IE only.

Full version: jsB@nk » Game » Poker » Dice Poker
URL: https://www.javascriptbank.com/dice-poker.html



CSS
<style>.n2{background-color: red;color: black;border: 0pt solid; **dot}.n1{backgroud-color: black;color: black;border: 0pt solid;}</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"><!-- Begin// Andy Lad (mandy.beams@virgin.net)char1="&nbsp;"char2=unescape("%u2022")numbers=new Array();times=1;function roll(a,b,c,d,e){toroll=new Array(a,b,c,d,e);towrite=""towrite+='<form name="dgame"><table cellpadding=\"30\" class=\"n1\"><tr>';for(j=0;j<5;j++){if((j!=0)&&(j/5==Math.floor(j/5))){ towrite+="</tr><tr>" }if((!toroll[j])&&(times==2)){number=numbers[j];}else if((toroll[j])||(times==1)){number=Math.floor(Math.random()*10 % 6)number++;}towrite+="<td>";switch(number){// char1 = space; char2 = dotcase 1: holes=new Array(char1,char1,char1,char1,char2,char1,char1,char1,char1);break;case 2: holes=new Array(char2,char1,char1,char1,char1,char1,char1,char1,char2);break;case 3: holes=new Array(char2,char1,char1,char1,char2,char1,char1,char1,char2);break;case 4: holes=new Array(char2,char1,char2,char1,char1,char1,char2,char1,char2);break;case 5: holes=new Array(char2,char1,char2,char1,char2,char1,char2,char1,char2);break;case 6: holes=new Array(char2,char1,char2,char2,char1,char2,char2,char1,char2);break;case 7: holes=new Array(char2,char1,char1,char1,char1,char1,char1,char1,char1);break;}towrite+='<table class="n2" border="0" cellpadding="0" cellspacing="0"><tr>';for(i=0;i<3;i++){towrite+='<td>&nbsp;'+holes[i]+'&nbsp;</td>\n'}towrite+='</tr><tr>';for(i=3;i<6;i++){towrite+='<td>&nbsp;'+holes[i]+'&nbsp;</td>\n'}towrite+='</tr><tr>';for(i=6;i<9;i++){towrite+='<td>&nbsp;'+holes[i]+'&nbsp;</td>\n'}towrite+='</tr></table>'if(times==1){towrite+='<input type="checkbox" name="hold'+j+'"> Hold';}else{if(!toroll[j]){ towrite+='Held' }else if(toroll[j]){ towrite+='&nbsp;' }}numbers[j]=number;towrite+='</td>'}if(times==1){ times++; }else{ times--; }if(dice>1) towrite+='</tr></table></form>';document.all.dice.innerHTML=towrite;return numbers;}function clickbutton(){points=0;win="nothing";alpha=new Array("a","b","c","d","e");types=new Array("ones","twos","threes","fours","fives","sixes");if(times==1){x=roll(1,1,1,1,1)}else{a=(document.dgame.hold0.checked)?0:1b=(document.dgame.hold1.checked)?0:1c=(document.dgame.hold2.checked)?0:1d=(document.dgame.hold3.checked)?0:1e=(document.dgame.hold4.checked)?0:1x=roll(a,b,c,d,e);ones=0twos=0threes=0fours=0fives=0sixes=0//win checker//counts how many of each number there isfor(k=0;k<5;k++){if(x[k]==1) ones++;if(x[k]==2) twos++;if(x[k]==3) threes++;if(x[k]==4) fours++;if(x[k]==5) fives++;if(x[k]==6) sixes++;}//alert(eval(types[0])+" ones\n"+eval(types[1])+" twos\n"+eval(types[2])+" threes\n"+eval(types[3])+" fours\n"+eval(types[4])+" fives\n"+eval(types[5])+" sixes\n");for(l=0;l<6;l++){if(eval(types[l])==3){points=1; win="Three of a kind";for(m=0;m<6;m++){if((eval(types[m])==2)&&(m!=l)){points=3; win="Full House (3 + 2 of a kind)";}}}if(eval(types[l])==4){ points=4; win="Four of a kind"; }if(eval(types[l])==5){ points=10; win="Five of a kind"; }//checks for one of every number except 6if((eval(types[0])==1)&&(eval(types[1])==1)&&(eval(types[2])==1)&&(eval(types[3])==1)&&(eval(types[4])==1)){win="Low Straight"; points="5"}//checks for one of every number except 1if((eval(types[1])==1)&&(eval(types[2])==1)&&(eval(types[3])==1)&&(eval(types[4])==1)&&(eval(types[5])==1)){win="High Straight"; points="6"}}alert("You got "+win+"!\n\nThat's "+points+" points!");total=parseInt(document.score.total.value);total+=parseInt(points);document.score.total.value=total;}}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<input type="button" value="Roll"onClick="clickbutton();"><p><span id="dice">Scoring:<br>3 of a kind: 2 points<br>4 of a kind: 4 points<br>5 of a kind: 10 points<br>Full House (3 + 2 of a kind): 3 points<br>Low Straight (1,2,3,4,5): 5 points<br>High Straight (2,3,4,5,6): 6 points<p>Click ROLL to start</span><br><form name="score">Score: <input type="text" size="3"name="total" onFocus="this.blur()" value="0"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->