470,616 Members | 2,300 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,616 developers. It's quick & easy.

card game javascript

Has anyone got a script to run a higher or lower card game on a web page.

Like the game show play you cards right.
Jul 20 '05 #1
1 2549
Gary Camblin wrote:
Has anyone got a script to run a higher or lower card game on a web
page.

Like the game show play you cards right.


<tongueincheek>
function Bruce_CardType(intCard) {
switch (intCard) {
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
case 8 : return intCard + 1;
case 9 : return "Jack";
case 10 : return "Queen";
case 11 : return "King";
case 12 : return "Ace";
default : null;
}
}
function Bruce(intCurrentCard) {
var intNewCard = Math.ceil(Math.random() * 12);
var strNewCard = Bruce_CardType(intNewCard);
if (typeof intCurrentCard != "number") {
alert("Nice to see you, to see you, nice");
alert("First card is a " + strNewCard);
}
else {
var intHigherOrLower = Math.round(Math.random());
var strCurrentCard = Bruce_CardType(intCurrentCard);
if (intHigherOrLower == 0) {
alert((intCurrentCard > 2 ? "Lower" : "Higher") + " than a " +
strCurrentCard + "?");
}
else {
alert((intCurrentCard < 12 ? "Higher" : "Lower") + " than a " +
strCurrentCard + "?");
}
if (intNewCard > intCurrentCard) {
if (intHigherOrLower == 0) {
alert("Ohh! A " + strNewCard + ", it's higher! What a shame!");
return;
}
else {
alert("Yes! A " + strNewCard + "!");
}
}
else {
if (intNewCard == intCurrentCard) {
alert("Lucky! Another " + strNewCard + "!");
}
else if (intHigherOrLower == 0) {
alert("Yes! A " + strNewCard + "!");
}
else {
alert("Ohh! A " + strNewCard + ", it's lower! What a shame!");
return;
}
}
}

setTimeout("Bruce(" + intNewCard + ")", 1000);
}
Bruce();

</tongueincheek>
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: www.andrewu.co.uk/about/contact/
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sam | last post: by
reply views Thread by Paul | last post: by
1 post views Thread by Geoff | last post: by
1 post views Thread by Olmar | last post: by
3 posts views Thread by Fiona1200 | last post: by
reply views Thread by hini | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.