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/