Page 1 of 2
PHP Blackjack
Posted: Sat Sep 14, 2002 11:39 pm
by zebrax
I was looking around the net and noticed there where hardly any PHP blackjack projects.
I thought it would be a perfect opportunity to learn object orientation. So the results are
http://blackjack.ordze.com OO PHP blackjack
This is my first time playing around with classes. Have a look and let me know what you think. I still have to add a few things (split and double down functions) and clean up the code a bit. But I think it is working order.
zebrax
Posted: Sat Sep 14, 2002 11:51 pm
by phice
Link doesn't work.
Posted: Sun Sep 15, 2002 3:08 am
by Takuma
The title works but the actual page doesn't show...
I say it's not good

Posted: Sun Sep 15, 2002 12:36 pm
by dusty
it just counted the dealers had of 3,j,a,8,6 as 18.
also isnt it only blackjack when you get 21 in the first 2 cards (ace and a ten card)? it said blackjack when i took a hit and got 21.
Posted: Sun Sep 15, 2002 3:23 pm
by zebrax
dusty wrote:it just counted the dealers had of 3,j,a,8,6 as 18.
also isnt it only blackjack when you get 21 in the first 2 cards (ace and a ten card)? it said blackjack when i took a hit and got 21.
Thanks I figured out why the dealer had 3,j,a,8,6 as 18
if happens when there is an ace. Here was my old code.
Code: Select all
function HandValue()
// determine the numeric value of the player's hand
{
$ace=0;
$total = 0;
for ($i = 0; $i < $this->numCards; $i++)
{
$v=$this->handї$i]->Getval();
if ($v <= 10)
$total += $v;
else if ($v <= 13) // it's a face card
$total += 10;
else { // it's an ace
$total += 11;
$ace=1;}
if($ace==1){
if($total>21){$total-=10;}
}
}
return $total;
}
when an ace shows up it kept taking off 10. Here us the updated code
Code: Select all
function HandValue()
// determine the numeric value of the player's hand
{
$total = 0;
for ($i = 0; $i < $this->numCards; $i++)
{
$ace=0;
$v=$this->handї$i]->Getval();
if ($v <= 10)
$total += $v;
else if ($v <= 13) // it's a face card
$total += 10;
else { // it's an ace
$total += 11;
$ace=1;}
if($ace==1)
{if($total>21){$total-=10;}
}
}
return $total;
}
I didn't have $ace=0; inside the loop.
Thanks
Posted: Sun Sep 15, 2002 6:42 pm
by hob_goblin
That's really nice, kind of slow, not sure if thats the coding or the server. I might make some card games, looks fun.
Posted: Mon Sep 16, 2002 2:36 am
by Takuma
I like it! It's reall cool

Posted: Mon Sep 16, 2002 6:47 am
by jason
Posted: Mon Sep 16, 2002 10:37 am
by JPlush76
leaving my fortune up to a php random number generator? that sounds scary

Posted: Mon Sep 16, 2002 10:47 am
by jason
It's actually very random, and the distrobution of cards is even (trust me, we have done tests).
So as far as randomness is concerned, PHP does it very well.

Posted: Mon Sep 16, 2002 11:09 am
by JPlush76
I actually played once on the old blackjack.com's flash site I won $80 and they actually paid it right onto my credit card.
I like the real cards and all the hotties running around the casino

Posted: Wed Sep 25, 2002 2:37 pm
by Coco
dealer wins on a draw...
Posted: Wed Sep 25, 2002 10:37 pm
by jason
the dealer is supposed to win
Posted: Thu Sep 26, 2002 12:29 am
by JPlush76
dealer isn't supposed to win if its even, its a push
Posted: Thu Sep 26, 2002 4:14 am
by Coco
jason i know

thats what i was trying to say...
(and i just got an avatar from you with REALLY hairy arms

)
but clearly from what jim says it depends on the rule set and the tightness of the casino
