Poker
Money: $100
Bet $
?
10
20
30
40
50
Replace
Replace
Replace
Replace
Replace
Hand Type
Bet Multiplier
Royal Straight Flush
x 60
Straight Flush
x 30
Four of a Kind
x 20
Full House
x 15
Flush
x 10
Straight
x 7
Three of a Kind
x 3
Two Pair
x 2
One Pair
x 1
Installation Instructions:
1: Copy and paste the following style declaration in the HEAD section of your page:
Select all...
<style type="text/css"> td { font-size:10pt; font-family:sans-serif; color: white; font-weight:bold; } </style>
2: Copy and paste the following script in the HEAD section of your page:
Select all...
<script language="javascript"> var w3c=(document.getElementById)?true:false; var ns4=(document.layers)?true:false; var ie4=(document.all && !w3c)?true:false; var ie5=(document.all && w3c)?true:false; var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false; var oktobet=true, oktoreplace=false, havebet=false; var dollars=0, money=100; var txtarea; var deckcntr=0, fontcolor='black'; var handsuit=new Array(); var handnumb=new Array(); var tmpn; function getid(id){ if(ns4) return document.layers[id]; else if(ie4)return document.all[id]; else return document.getElementById(id); } function writelayer(id,text){ if(ns4){ id.document.open(); id.document.write('
'+text+'
'); id.document.close(); } else id.innerHTML=text; } //PRECACHE ALL IMAGES var imagz=new Array(); for(i=1;i<=4;i++){ imagz[i]=new Image(); imagz[i].src='s'+i+'.gif'; } for(i=1;i<=13;i++){ imagz[i+4]=new Image(); imagz[i+4].src='n'+i+'.gif'; } //BUILDS A DECK OF CARDS var deck=new Array(); for(s=1;s<=4;s++){ for(num=1;num<=13;num++)deck[s*13-13+num]=''+s+num; } //SHUFFLES THE DECK function shuffle(){ var x,y,xd,yd; for(i=0;i<=300;i++){ x=Math.floor(Math.random()*52+1); xd=deck[x]; y=Math.floor(Math.random()*52+1); yd=deck[y]; deck[y]=xd; deck[x]=yd; }} //WHEN PAGE LOADS function init(){ shuffle(); d=document.images; txtarea=getid('txtarea'); alert('INSTRUCTIONS\n\n- This is a 1 player poker game.\n- Follow prompts in upper corner.\n- Amount you gain or lose depends on your hand and your bet.\n\nPress "Ok" to continue...'); writelayer(txtarea,'
Money: $'+money+'
Place bet...
'); document.f.betamnt.selectedIndex=0; } //NEW HAND function startover(){ document.f.ok.value=" Replace Selected Cards... "; handsuit=new Array(); handnumb=new Array(); deckcntr=0; dollars=0; document.f.betamnt.selectedIndex=0; fontcolor=(money<0)?'red': 'black'; writelayer(txtarea,'
Money: $
'+money+'
Place bet...
'); oktoreplace=false; oktobet=true; havebet=false; for(i=1;i<=5;i++){ document.images['s'+i].src='faceupbot.gif'; document.images['n'+i].src='faceuptop.gif'; document.f['c'+i+'b'].checked=false; } shuffle(); } //REPLACES X CARDS FROM ONES REMAINING IN DECK function replace(){ if(havebet&&oktoreplace){ var repl=''; for(i=1;i<=5;i++){ if(document.f[('c'+i+'b')].checked==true){ repl+=i+','; }} repl=repl.substring(0,repl.length-1); eval('deal('+repl+')'); testcards(); }else alert('You must place a bet first...'); } //NEXT FEW FUNCTIONS TEST REPETITIOUS CARD POSSIBILITIES function testflush(){ return ( (handsuit[1]==handsuit[2])&&(handsuit[1]==handsuit[3])&&(handsuit[1]==handsuit[4])&&(handsuit[1]==handsuit[5]) ); } function testface(){ return ( ((handnumb[1]>=10)||(handnumb[1]==1))&&((handnumb[2]>=10)||(handnumb[2]==1))&&((handnumb[3]>=10)||(handnumb[3]==1))&&((handnumb[4]>=10)||(handnumb[4]==1))&&((handnumb[5]>=10)||(handnumb[5]==1)) ) } function teststraight(){ var x=( (tmpn[1]+4==tmpn[5]) && (tmpn[2]+3==tmpn[5]) && (tmpn[3]+2==tmpn[5]) && (tmpn[4]+1==tmpn[5]) ); for(i=1;i<=5;i++){ if(tmpn[i]==1)tmpn[i]=14; } tmpn=new Array(); tmpn[0]=0; for(i=1;i<=5;i++)tmpn[i]=handnumb[i]; tmpn.sort(sortnumbs); var y=( (tmpn[1]+4==tmpn[5]) && (tmpn[2]+3==tmpn[5]) && (tmpn[3]+2==tmpn[5]) && (tmpn[4]+1==tmpn[5]) ); return x||y; } //SUB-FUNCTION FOR THE "SORT()" METHOD function sortnumbs(a,b){ return a-b; } //FUNCTION TO TEST ALL CARD POSSIBILITIES function testcards(){ tmpn=new Array(); tmpn[0]=0; for(i=1;i<=5;i++)tmpn[i]=handnumb[i]; tmpn.sort(sortnumbs); var wtype='Nothing.'; var wamount=0; // 2 OF A KIND if( (tmpn[1]==tmpn[2])||(tmpn[2]==tmpn[3])||(tmpn[3]==tmpn[4])||(tmpn[4]==tmpn[5]) ){ wtype='a Pair'; wamount=dollars*1; } // 2 PAIR if( ((tmpn[1]==tmpn[2])&&(tmpn[3]==tmpn[4]))||((tmpn[1]==tmpn[2])&&(tmpn[4]==tmpn[5]))||((tmpn[2]==tmpn[3])&&(tmpn[4]==tmpn[5])) ){ wtype='Two Pair.'; wamount=dollars*2; } // 3 OF A KIND if( ((tmpn[1]==tmpn[2])&&(tmpn[1]==tmpn[3]))||((tmpn[2]==tmpn[3])&&(tmpn[2]==tmpn[4]))||((tmpn[3]==tmpn[4])&&(tmpn[3]==tmpn[5])) ){ wtype='3 of a Kind.'; wamount=dollars*3; } // STRAIGHT if( teststraight() ){ wtype='a Straight.'; wamount=dollars*7; } // FLUSH if( testflush() ){ wtype='a Flush.'; wamount=dollars*10; } // FULL HOUSE if( ((tmpn[1]==tmpn[2])&&(tmpn[3]==tmpn[4])&&(tmpn[3]==tmpn[5])&&(tmpn[1]!=tmpn[3]))||((tmpn[4]==tmpn[5])&&(tmpn[1]==tmpn[2])&&(tmpn[1]==tmpn[3])&&(tmpn[4]!=tmpn[1])) ){ wtype='a Full House.'; wamount=dollars*15; } // 4 OF A KIND if( ((tmpn[1]==tmpn[2])&&(tmpn[1]==tmpn[3])&&(tmpn[1]==tmpn[4]))||((tmpn[2]==tmpn[3])&&(tmpn[2]==tmpn[4])&&(tmpn[2]==tmpn[5])) ){ wtype='4 of a Kind.'; wamount=dollars*20; } // STRAIGHT FLUSH if(testflush() && teststraight()){ wtype='a Straight Flush.'; wamount=dollars*30; } // ROYAL STRAIGHT FLUSH if(teststraight() && testface() && testflush()){ wtype='a Royal Straight Flush.'; wamount=dollars*60; } money+=wamount; oktobet=false; oktoreplace=false; document.f.ok.value=" Ok "; writelayer(txtarea, '
You got '+wtype+'
Press "Ok" to continue'); } //DEALS THE CARDS function deal(){ for(i=0;i
Money: $
'+money+'
/ Current bet: $'+dollars+'
Select cards to replace...'); oktoreplace=true; havebet=true; deal(1,2,3,4,5); }} window.onload=init; window.onunload=function(){ if(money<0)alert('Hey, don\'t leave until you pay up!'); } </script>
3: Copy and paste the following HTML in the BODY section of your page:
Select all...
Money: $100
Bet $
?
10
20
30
40
50
Replace
Replace
Replace
Replace
Replace
Hand Type
Bet Multiplier
Royal Straight Flush
x 60
Straight Flush
x 30
Four of a Kind
x 20
Full House
x 15
Flush
x 10
Straight
x 7
Three of a Kind
x 3
Two Pair
x 2
One Pair
x 1