Topic awaiting preservation: PHP Card Game... (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Kansas City, MO , USA |
posted 09-28-2005 08:38
I am working on an online card game. Problem is that it is only suppose to be a 1 deck game, I thought I had it figured out, but guess I don't... code: $usedcards = array(); $cards = array( "blackjack/cards/h2.gif" , "blackjack/cards/h3.gif" , "blackjack/cards/h4.gif" , "blackjack/cards/h5.gif" , "blackjack/cards/h6.gif" , "blackjack/cards/h7.gif" , "blackjack/cards/h8.gif" , "blackjack/cards/h9.gif" , "blackjack/cards/h10.gif" , "blackjack/cards/h11.gif" , "blackjack/cards/h12.gif" , "blackjack/cards/h13.gif" , "blackjack/cards/h14.gif" , "blackjack/cards/s2.gif" , "blackjack/cards/s3.gif" , "blackjack/cards/s4.gif" , "blackjack/cards/s5.gif" , "blackjack/cards/s6.gif" , "blackjack/cards/s7.gif" , "blackjack/cards/s8.gif" , "blackjack/cards/s9.gif" , "blackjack/cards/s10.gif" , "blackjack/cards/s11.gif" , "blackjack/cards/s12.gif" , "blackjack/cards/s13.gif" , "blackjack/cards/s14.gif" , "blackjack/cards/d2.gif" , "blackjack/cards/d3.gif" , "blackjack/cards/d4.gif" , "blackjack/cards/d5.gif" , "blackjack/cards/d6.gif" , "blackjack/cards/d7.gif" , "blackjack/cards/d8.gif" , "blackjack/cards/d9.gif" , "blackjack/cards/d10.gif" , "blackjack/cards/d11.gif" , "blackjack/cards/d12.gif" , "blackjack/cards/d13.gif" , "blackjack/cards/d14.gif" , "blackjack/cards/c2.gif" , "blackjack/cards/c3.gif" , "blackjack/cards/c4.gif" , "blackjack/cards/c5.gif" , "blackjack/cards/c6.gif" , "blackjack/cards/c7.gif" , "blackjack/cards/c8.gif" , "blackjack/cards/c9.gif" , "blackjack/cards/c10.gif" , "blackjack/cards/c11.gif" , "blackjack/cards/c12.gif" , "blackjack/cards/c13.gif" , "blackjack/cards/c14.gif" , "blackjack/cards/joker.gif"); $values = array( "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "10" , "10" , "10" , "11" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "10" , "10" , "10" , "11" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "10" , "10" , "10" , "11" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "10" , "10" , "10" , "11" , "11" ); $aces = array(12,25,38,51,52);
code: session_unregister("usercard"); $usercard = array(); $total = ""; for ($i = 0; $i < 2; $i++) { $num = rand(1000,9999); mt_srand ((double) microtime() * 9999999); $card = mt_rand (0,52); do { mt_srand ((double) microtime() * 9999999); $card = mt_rand (0,52); } while (in_array($card,$usedcards)); array_push($usedcards,$card); $usercard[$i] = $card; } $total = getTotal($usercard); session_register("usercard"); print showCards($dealercard,"dealershand","<strong>Dealers Hand :</strong> Don't you wish..."); print showCards($usercard,"yourhand","<strong>Your Hand</strong> : $total"); print showChoices(); print showScore(); }
|
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 09-28-2005 11:30
a) You'r not keeping the image and the card value together... that's prone to cause a bit of trouble when you're shuffling. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 09-28-2005 18:08
I'd make one array of small "card" data objects. (PHP 5 syntax) |