Javascript : Pontoon Project

Associate
Joined
18 Jan 2006
Posts
8
As the title says im trying to create a Javascript program that allows the user to play pontoon. I have got this far and have got stuck on an error I cant see.

Please keep explinations simple as im very new to java script. :D

Thanks.

<HTML>
<HEAD>
<SCRIPT LANUAGE = "javascript">


function stick_option ()
// This will ask the player if they wish to stick or not

{

var playerans = 0;

playerans = prompt('Do you with to continue?', Y/N?);
if (playerans = Y)
counter = (counter + decounter);




}


function bust_teller ()
//This is a function to tell the player they are bust

{

alert('Your cards have exceded 21 - Your Bust');
counter = (counter + decounter);

}

function main_function ()
//This is a function to add 5 playing cards and add up the total

{



var cardtotal = 0;
var cardout = 0;
var counter = 0;
var decounter = 0;

while (counter < 5)
{

cardtotal = prompt('Enter your five cards -', 0);
counter = counter + 1
decounter = decounter + 5
decounter = decounter - 1
cardout = cardout * 1 + cardtotal * 1;

{if (cardout > 21)
alert('Your cards have exceded 21 - Your Bust');
bust_teller () }


else

if (cardout < 16)
alert('Your hand is high enough to stick on')
stick_option ()



}





alert ('Your hand is ' + cardout);

}


</SCRIPT>
</HEAD>
<BODY>
<FORM NAME = "my form">
<center>

<P>Pontoon</P>
<p>You will be asked to input the cards you have been dealt</p>
<input type = "button" VALUE = "Start"
onClick = "main_function () ;">
</center>

</FORM>
</BODY>
</HTML>
 
Associate
OP
Joined
18 Jan 2006
Posts
8
Thanks that was very helpful.

Im able to to allow the user to stop the loop, but how can I force the loop to start again if the user wants to keep playing?
 
Back
Top Bottom