Make your own free website on Tripod.com

The Church of Universal Love and Music

 
 
 
 

Dice Poker (Yahtzee) Source Code:

 <html>
<head><link rel="stylesheet" type="text/css" href="xpMenu.css">

<TITLE>CULM Dice Poker!!</TITLE>



<script language="javascript">
<!--


var pic=new Array();
pic[0]=new Image();
pic[0].src="ROLL.jpg";
pic[1]= new Image();
pic[1].src="ROLL1.jpg";
pic[2]= new Image();
pic[2].src="ROLL2.jpg";
pic[3]= new Image();
pic[3].src="ROLL3.jpg";


function chButton(name,source){

var picture=eval('document' + '.' + name);
picture.src=source;

}

//-->
</script>
<script language="javascript">
<!--

//////////////////////
//Javascript Yahtzee//
//FenixFire 2006//
////////////////////


var ck=new Array();
var count=0;
var score = new Array();
var pos = new Array();
var x = 0;
var fld= new Array('ones','twos','threes','fours','fives','sixes');
var dice= new Array(6);


dice[0]=new Image();
dice[0].src="dice_one.jpg";
dice[1]= new Image();
dice[1].src="dice_two.jpg";
dice[2]= new Image();
dice[2].src="dice_three.jpg";
dice[3]= new Image();
dice[3].src="dice_four.jpg";
dice[4]= new Image();
dice[4].src="dice_five.jpg";
dice[5]= new Image();
dice[5].src="dice_six.jpg";




function ranNum(){

for(var i = 0; i < dice.length; i++){
var j = Math.floor(Math.random() * dice.length);

return j;
}
}




function roll(){

x++;

if(x > 3){
chButton('roll','ROLL.jpg');
alert("Please Select Where you would like your score.");
chButton('roll','ROLL.jpg');
calc();
return;
}
else{
if(x==1){
chButton('roll','ROLL1.jpg');
}
if(x==2){
chButton('roll','ROLL2.jpg');
}
if(x==3){
chButton('roll','ROLL3.jpg');

}

for(var a = 0;a < document.user.box.length;a++){
if(document.user.box[a].checked == false){
pos[a] = document.user.box[a].value;
}
else{
if(document.user.box[a].checked == true){
pos[a] = "skip";

}
}
}

for(var i = 0; i < pos.length; i++){
var n= eval('document' + '.' + pos[i]);

if(pos[i] == "skip"){
}


else{

var d=ranNum();

score[i] = (d + 1);


n.src=dice[d].src;
}
}


}

}

function calc(){

for(var i=0;i < document.user.box.length;i++){
document.user.box[i].checked=false;

}
var a=score[0];
var b=score[1];
var c=score[2];
var d=score[3];
var e=score[4];
var total=(a+b+c+d+e);
return total;
if(isNaN(total)){
alert("Please Roll the Dice");
}

}



function ckScore(validNum,formFld){
var t=0;

var fldval=eval('document' + '.' + 'user' + '.' + formFld);
for(var i=0;i < score.length;i++){
if(score[i]==validNum){
t++;
}
fldval.value=t*validNum;
}
getTotb();
}




function ckScoreB(times,formFld){
chButton('roll','ROLL.jpg');
x=0;
var fldval=eval('document' + '.' + 'user' + '.' + formFld);
var s=score.toString();
for(var num=0;num <= 6;num++){

var substrings = s.split(num);
var y= substrings.length - 1;

if ((times == 5) && (y >= times)){
fldval.value=50;
}
else{
if(y >= times){
fldval.value=calc();
}
}
}

getTotb();
}



function getchance(name){
var fldval=eval('document' + '.' + 'user' + '.' + name);
fldval.value=calc();
if(isNaN(fldval.value)){
fldval.value=0;
}
getTotb();
}



function fullHouse(three,two,formFld){

var fldval=eval('document' + '.' + 'user' + '.' + formFld);
var s=score.toString();
for(var num=0;num <= 6;num++){

var substrings = s.split(num);
var b= substrings.length - 1;
var y= substrings.length -1;

if((b >= three) && (y >= 2)){

fldval.value=25;
}
}
getTotb();
}


function straight(size){
var fldval=eval('document' + '.' + 'user' + '.' + size);
var order=score.sort();


if(size=='small'){
for(var i=0;i < order.length;i++){
if(order[i]==order[i+1]){
delete order[i];

}
}

var s=order.toString();
var y=s.replace(/,/g,'');


if(((y.match(/1234/)) || (y.match(/2345/)) || (y.match(/3456/) ))){

fldval.value=30;
}
}

if(size=='large'){
var s=order.toString();
var a="1,2,3,4,5";
var b="2,3,4,5,6";

if((s.match(a)) || (s.match(b))){

fldval.value=40;
}
}
getTotb();
}


function getTot(){

var a=parseInt(document.user.elements['ones'].value);
var b=parseInt(document.user.elements['twos'].value);
var c=parseInt(document.user.elements['threes'].value);
var d=parseInt(document.user.elements['fours'].value);
var e=parseInt(document.user.elements['fives'].value);
var f=parseInt(document.user.elements['sixes'].value);

var bonus=document.user.elements['bonus'];
var total=document.user.elements['totalTop'];
var sub=(a+b+c+d+e+f);

document.user.elements['subTotal'].value=sub;
if(sub >= 63){
bonus.value=35;
var adval=parseInt(bonus.value);
total.value=sub+adval;
return total.value;
}
else{
total.value=sub;
return total.value;
}

}


function getTotb(){
x=0;
chButton('roll','ROLL.jpg');
for(var i=0;i < document.user.box.length;i++){
document.user.box[i].checked=false;

}
var a=parseInt(document.user.elements['threek'].value);
var b=parseInt(document.user.elements['fourk'].value);
var c=parseInt(document.user.elements['fivek'].value);
var d=parseInt(document.user.elements['small'].value);
var e=parseInt(document.user.elements['large'].value);
var f=parseInt(document.user.elements['chance'].value);
var g=parseInt(document.user.elements['full'].value);
var gt=document.user.elements['grandTotal'];
var subT=document.user.elements['subB'];
var sub=(a+b+c+d+e+f+g);
subT.value=sub;
var tt=getTot();
gt.value=parseInt(tt)+sub;

clearDice();
}


function clearDice(){

var n=new Array("one","two","three","four","five");

for(var i=0;i < n.length;i++){
var p=eval('document' + '.' + n[i]);

p.src="dice.jpg";
delete ck[i];

}

ckFrmState();
}


function ckFrmState(){
count=0;
var fm=document.user.select;

for(var i = 0;i < fm.length;i++){
if(fm[i].checked==true){
count++;
ck[count]=i;
}
}


if(ck.length-1==fm.length){
var msg="Game Over!" + "\n" + "Your Final Score is" + " " + document.user.elements['grandTotal'].value + "\n" + "Would you like to play again?";
if(confirm(msg)){
newGame();
}
else{
window.location.href="index.html";
}
}
}


function newGame(){
ck.length=0;
chButton('roll','ROLL.jpg');
x=0;
count=0;
document.user.reset();
}


//-->
</script>
<title>CULM YAHTZEE</title>
</head>

<BODY bgcolor="#FFFFFF"style="text-align: center"onload="javascript:x=0;">
<center>
<TABLE cellSpacing=0 cellPadding=0 width="82%" border=0 align:"center">
<TR>
<TD width="100%" align="center">
<p align="center">
<img border="0" src="images/churchlogo.jpg" width="125" height="125">
</p>
</TD>
</TR>
</TABLE></center>
<p align="center"><FONT face=Ravie color=#ff0000 size=5>The Church of Universal Love and
Music</FONT>
<FONT FACE="Tahoma"><br> </FONT></p>
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td valign="top" width="245"> <table width="215" border="0" cellspacing="0" cellpadding="0">
<tr> <td colspan="3" height="28" background="images/menuup.gif"> <div align="center">
&nbsp;</div></td></tr> <tr> <td width="9" height="76" background="images/menuleft.gif">&nbsp;</td><td width="194" height="76">
<FONT FACE="Tahoma"><br><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Quick Links</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="frontdoor.htm">Home</a></span><br>
<span class="subItem1"><a href="calendar.htm">Goings On</a></span><br>
<span class="subItem1"><a href="churchinfo.htm">Church Info</a></span><br>
<span class="subItem1"><a href="past-events.htm">Past Events</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Mission</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="mission.htm">Mission Statement</a></span><br>
<span class="subItem1"><a href="comser.htm">Community Service</a></span><br>
<span class="subItem1"><a href="projects.htm">Projects</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Support</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="donate.htm">Donations</a></span><br>
<span class="subItem1"><a href="support.htm">Support</a></span><br>
<span class="subItem1"><a href="products.htm">Products &amp; Services</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Fun Stuff</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="fungames.htm">Fun & Games</a></span><br>
<span class="subItem1"><a href="educate.htm">Self Education</a></span><br>
<span class="subItem1"><a href="contact.htm">Contact Us</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><br>
</div></FONT></td><td width="12" height="76" background="images/menuright.gif">&nbsp;</td></tr>
<tr> <td colspan="3" height="28" background="images/menudown.gif">&nbsp;</td></tr> </table>
<p><FONT FACE="Tahoma"><br>
</FONT></td><td width="455" valign="top">
<table width="455" border="0" cellspacing="0" cellpadding="0" background="images/longmenu.gif" height="34">
<tr> <td><font size="4" face="Arial">CULM Dice Poker!!</font></td></tr> </table>
<p align="right"><FONT FACE="Tahoma">&nbsp;</FONT></p><p align="right">
<form name="user">
<p align="center"><a href="javascript:newGame()"><img src="reset.jpg"></a></p>

<table align="center">

<tr>
<td bgcolor="#000000"><img name="one" src="dice.jpg"></td>
<td bgcolor="#000000"><img name="two" src="dice.jpg"></td>
<td bgcolor="#000000"><img name="three" src="dice.jpg"></td>
<td bgcolor="#000000"><img name="four" src="dice.jpg"></td>
<td bgcolor="#000000"><img name="five" src="dice.jpg"></td>

</tr>


<tr>
<td bgcolor="#000000"><input type="checkbox" name="box" value="one" ></td>
<td bgcolor="#000000"><input type="checkbox" name="box" value="two" ></td>
<td bgcolor="#000000"><input type="checkbox" name="box" value="three" ></td>
<td bgcolor="#000000"><input type="checkbox" name="box" value="four" ></td>
<td bgcolor="#000000"><input type="checkbox" name="box" value="five" ></td>
</tr>
<tr>
<td bgcolor="#000000" align="center"><b><font color="#FFFFFF">hold</font></b></td>
<td bgcolor="#000000" align="center"><b><font color="#FFFFFF">hold</font></b></td>
<td bgcolor="#000000" align="center"><b><font color="#FFFFFF">hold</font></b></td>
<td bgcolor="#000000" align="center"><b><font color="#FFFFFF">hold</font></b></td>
<td bgcolor="#000000" align="center"><b><font color="#FFFFFF">hold</font></b></td>
</tr>
</table>

<table align="center">

<tr>
<td bgcolor="#000000"><a href="javascript:roll()"><img src="ROLL.jpg" name="roll" ></a></td>



</table>
<table align="center">
<tr>
<td bgcolor="#000000">




<table align="center">
<tr>
<td align="center"><font color="#FFFFFF">ONES</font></td>
<td><input type="checkbox" name="select" onclick="ckScore(1,'ones')"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><input type="text" name="ones" value=0 disabled size="5"></td>

</tr>
<tr>
<td align="center" ><font color="#FFFFFF">TWOS</font></td>
<td><input type="checkbox" name="select" onclick="ckScore(2,'twos')"></td>
<td ><img src="dice_two.jpg"></td>
<td><img src="dice_two.jpg"></td>
<td ><img src="dice_two.jpg"></td>
<td ><input type="text" name="twos" value=0 disabled size="5"></td>

</tr>
<tr>
<td align="center" ><font color="#FFFFFF">THREES</font></td>
<td><input type="checkbox" name="select" onclick="ckScore(3,'threes')"></td>
<td ><img src="dice_three.jpg"></td>
<td ><img src="dice_three.jpg"></td>
<td ><img src="dice_three.jpg"></td>
<td><input type="text" name="threes" value=0 disabled size="5">
</td>
</tr>
<tr>
<td align="center" ><font color="#FFFFFF">FOURS</font></td>
<td><input type="checkbox" name="select" onclick="ckScore(4,'fours')"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><input type="text" name="fours" value=0 disabled size="5">
</td>
</tr>
<tr>
<td align="center" ><font color="#FFFFFF">FIVES</font></td>
<td><input type="checkbox" name="select" onclick="ckScore(5,'fives')"></td>
<td><img src="dice_five.jpg"></td>
<td><img src="dice_five.jpg"></td>
<td><img src="dice_five.jpg"></td>
<td><input type="text" name="fives" value=0 disabled size="5">
</td>
</tr>
<tr>
<td align="center" ><font color="#FFFFFF">SIXES</font></td>
<td><input type="checkbox" name="select" onclick="ckScore(6,'sixes')"></td>
<td ><img src="dice_six.jpg"></td>
<td ><img src="dice_six.jpg"></td>
<td ><img src="dice_six.jpg"></td>
<td ><input type="text" name="sixes" value=0 disabled size="5">
</td>
</tr>
</table>
<table>
<tr>

<td></td>

<td align="center"></td>
<td align="center" ><b><font color="#FFFFFF">Subtotal</font></b></td>
<td><input type="text" name="subTotal" value=0 disabled size="5"></td></tr>
<tr>
<td></td>
<td align="center">
<b><font color="#FFFFFF">35 point bonus<br> if Subtotal equals 63+
</font></b>
</td>
</tr>
<tr>
<td></td>
<td align="center"></td>
<td align="center" ><b><font color="#FFFFFF">Bonus</font></b></td>
<td><input type="text" value=0 name="bonus" disabled size="5">
</td>
</tr>
<tr>
<td></td>
<td align="center"></td>
<td align="center" ><b><font color="#FFFFFF">Total</font></b></td>
<td><input type="text" name="totalTop" value=0 disabled size="5"></td>
</tr>
</table>
</td>
<td bgcolor="#000000">
<table>
<tr>
<td align="center">
<b><font color="#FFFFFF">3 OF A KIND</font></b></td>
<td><input type="checkbox" name="select" onclick="ckScoreB(3,'threek')"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice.jpg"></td>
<td><img src="dice.jpg"></td>

<td><input type="text" name="threek" disabled size="5" value=0>
</td>
</tr>
<tr>
<td align="center">
<b><font color="#FFFFFF">4 OF A KIND</font></b></td>
<td><input type="checkbox" name="select" onclick="ckScoreB(4,'fourk')"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice.jpg"></td>
<td><input type="text" name="fourk" disabled size="5" value=0>
</td>
<td></td>
</tr>
<tr>
<td align="center">
<b><font color="#FFFFFF">FULL HOUSE</font></b></td>
<td><input type="checkbox" name="select" onclick="fullHouse(3,2,'full')"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_two.jpg"></td>
<td><img src="dice_two.jpg"></td>
<td><input type="text" name="full" disabled size="5" value=0>
</td>
<td></td>
</tr>
<tr>
<td align="center">
<b><font color="#FFFFFF">SM. STRAIGHT</font></b></td>
<td><input type="checkbox" name="select" onclick="straight('small')"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_two.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice.jpg"></td>
<td><input type="text" name="small" disabled size="5" value=0>
</td>
</tr>
<tr>
<td align="center">
<b><font color="#FFFFFF">LG STRAIGHT</font></b></td>
<td><input type="checkbox" name="select" onclick="straight('large')"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_two.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_four.jpg"></td>
<td><img src="dice_five.jpg"></td>
<td><input type="text" name="large" disabled size="5" value=0></td>
</td>
<td></td>
</tr>
<tr>
<td align="center">
<b><font color="#FFFFFF">YAHTZEE</font></b></td>
<td><input type="checkbox" name="select" onclick="ckScoreB(5,'fivek')"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><input type="text" name="fivek" disabled size="5" value=0>
</td>
<td></td>
</tr>
<tr>
<td align="center">
<b><font color="#FFFFFF">CHANCE</font></b></td>
<td><input type="checkbox" name="select" onclick="getchance('chance')"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_three.jpg"></td>
<td><img src="dice_one.jpg"></td>
<td><img src="dice_five.jpg"></td>
<td><img src="dice_two.jpg"></td>
<td><input type="text" name="chance" disabled size="5" value=0>
</td>
<td></td>
</tr>
<tr>


<td align="center"><b><font color="#FFFFFF">Subtotal</font></b></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><input type="text" name="subB" value=0 disabled size=5></td>
</tr>
<tr>


<td align="center"><b><font color="#FFFFFF">GrandTotal</font></b></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>

<td><input type="text" name="grandTotal" value=0 disabled size=5></td>
</table>

</td>
</tr>
</table>
</p></td></tr> </table><FONT FACE="Tahoma"><br> </FONT><table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td> <div align="left"></div><DIV ALIGN="CENTER"><FONT SIZE="2" FACE="Tahoma">Copyright
2006 The Church of Universal Love and Music. All Rights Reserved</FONT></DIV><TABLE WIDTH="700" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="20" ALIGN="center">
<TR BGCOLOR="#000000"> <TD BGCOLOR="#336666"><DIV ALIGN="center">&nbsp;</DIV></TD></TR> </TABLE></td></tr>
</table>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-676573-1";
urchinTracker();
</script><script type="text/javascript" src="xpMenu.js"></script></body>
</html><center>
<span style="width: 100%; font-family: helvetica; font-size: 6px; Filter: Alpha(Opacity=0,FinishOpacity=0, Style=1);">
&nbsp;</span></center><br><br>

 


Copyright 2006 The Church of Universal Love and Music. All Rights Reserved