473,785 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2690
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.


<tongueinchee k>
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(intCurren tCard) {
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 intHigherOrLowe r = Math.round(Math .random());
var strCurrentCard = Bruce_CardType( intCurrentCard) ;
if (intHigherOrLow er == 0) {
alert((intCurre ntCard > 2 ? "Lower" : "Higher") + " than a " +
strCurrentCard + "?");
}
else {
alert((intCurre ntCard < 12 ? "Higher" : "Lower") + " than a " +
strCurrentCard + "?");
}
if (intNewCard > intCurrentCard) {
if (intHigherOrLow er == 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 (intHigherOrLow er == 0) {
alert("Yes! A " + strNewCard + "!");
}
else {
alert("Ohh! A " + strNewCard + ", it's lower! What a shame!");
return;
}
}
}

setTimeout("Bru ce(" + 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2630
by: Sam | last post by:
Hey all, I want to create a computerised version of this game, though I'm not really sure how to go about it. For those who don't know how the game works, here's my attempt at a brief description: It is very similar to the card game Uno, though played with a standard deck of cards. An initial card is played off the top of the deck, and then each player has to play a card of the same suit, or the same face value in another suit....
0
3013
by: Limpor | last post by:
Hello, I am new to learning java, and i am trying to build the class for a calculation card game, unfortunately i can't get the public Card top() and Card takeTop() method in the Stock class. Can someone helps me. Thanks!! ----------------------------------------------------------------------- The code for the Stock class: ----------------------------------------------------------------------- public class Stock { private Deck deck = new...
0
3718
by: Paul | last post by:
Greetings: I have been trying to find source code for a Baccarat card game (C++ or Basic, but preferably the former). My reason for this is wanting to experiment with possible Baccarat card counting methodologies, which is a controversial subject but I'd like to try out some ideas. However, I know very little C++ and am having real trouble even just setting up an 8 deck card shoe. Also, I can't find source code for Baccarat anywhere...
1
1643
by: Geoff | last post by:
Hi all, I've been making a card game in VB and am trying to get it work over a network. I think I've got all the card game pretty much planned out ready to make it, but need to find a way to get 2 computers to talk to each other over a network. I can't save files to anywhere both computers can access on the network though. I was thinking this would be solvable with IP's and stuff like that, I'd appreciate it if anyone can give me some code for...
6
1891
by: JNeko | last post by:
Hello all, awesome site! I guess I am technically not a beginner in JAVA, but from my code you would not realize it! I don’t expect anyone to help me with this, but I figure I might as well as try and ask. Any help is really appreciated; this should be a piece of cake…driving me crazy. I am writing a simple program (from a book for fun) that creates a deck of cards, shuffles them, gives the user a card, and asks if the next card will be...
1
4577
by: Olmar | last post by:
Hi, I am trying to write a version of the Hears card game. I can't figue out what is the best way to detect clicks on the cards. Using the cards.dll interface as described in tutorials like http://www.publicjoe.f9.co.uk/csharp/card00.html . Can anyone give me suggestions how to detect which card is clicked and how to redraw it at the center of the sceen. For now all i know is that I have to detect the X and Y coordinates of the mouse....
3
2307
by: Fiona1200 | last post by:
Please help me..i have to write a code in java for a card game as follows. there are 4 players each with 4 decks of cards. each deck has four zeros - four seven as follows (0000,1111,2222,3333,4444,5555,6666,7777). each pack is then shuffled player 1 deals player 2 four of his cards, player 2 deals player 3, 4 of his cards and so on. when each player has four cards, player 1 will pull a card from his deck (the object is to get four of the same...
0
2773
by: hini | last post by:
Hi all, I am considering creating a multiplayer card game to play with my friends over internet, and I want to do it in java, I am not pro in java so I read a little about sockets, serialization, RMI, servlets, EJB etc.. but I am still not sure what are the best technologies or architecture to use for communication between players and server. of course it will be client server architecture with an applet on the client for example and some...
1
4982
by: blazinhieu | last post by:
I want to double the score if the cards have the same suit or value and if two cards have the same both suit and value, the score get tripled. And the 2 of clubs is a 20 points. i already wrote the basics of the program which it adds two random cards together and whoever get the higher score win.: class Card{ GetCards gc = new GetCards(); public static void main(String args){ new Card(); } public Card(){ int c1, c2, c3, c4=0;...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.