PHP Blackjack
Moderator: General Moderators
PHP Blackjack
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
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
Last edited by zebrax on Sun Sep 15, 2002 12:06 am, edited 1 time in total.
Thanks I figured out why the dealer had 3,j,a,8,6 as 18dusty 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.
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;
}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;
}Thanks
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
