Click to See Complete Forum and Search --> : big trouble....
Greelmo
06-24-2003, 12:47 AM
I'm trying to program a game of poker using purely javascript (a follow-up on my blackjack idea which i finished). I have each randomly generated card in a seraprate <div>. Then, the user picks what cards to drop and hits "deal". It deals the user new cards where he specifies (randomly generated) and then takes the number value of each card and puts it in an array (jacks=11, queens=12, kings=13, aces=14). I have gotten that far. Now the problem is checking to see what type of hand the user has. I need to see how often each element of the array repeats within the array. Is that possible? Could someone give me a sample code possible?
The link to what i have so far is www31.brinkster.com/dexweiss/ASP/poker.html
THANKS!!!
Greelmo
06-24-2003, 11:50 AM
but if you have a set value for a pair, two of a kind, three of a kind, etc., if the cards have different values, then they will add up to be different numbers which i haven't defined. I was thinking that there is a way to check for occurances in an array...
I have the array with the value of (Example: 2, 5, 7, 2, 14) which would be a 2, a 5, a 7, a 2, and an ace. Isn't there a way to see that 2 appears twice?
Greelmo
06-24-2003, 09:46 PM
I'm not following what you mean by a tally array. I could find someway to change the order the the string and check to see if the same numbers of each array are the same.
but that would take a whole lot of code. could you just explain to me a bit more about how i should do it? Thanks for the help!
Greelmo
06-25-2003, 07:53 PM
I solved it by created an array with 14 elements... on for each card. All the elements were set to 0. It then checked for the number of each of the five cards and put a one, two, three, or four and put that number into the array for the corresponding card. Thanks for seeing me through it!