Jump to content
MakeWebGames

[mccode v1] Black Jack


-Genocide-

Recommended Posts

this is a simple black jack game that i converted to work with mccodes, i didnt add any querys for betting, i cant do all the work for you :P

blackjack.php

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Black Jack

";

if ($_SESSION['bj'] != ''){
for($i = 1; $i < 25; $i++) {
$card[$i] = $_SESSION['card' . $i];
}
}

if (isset($_GET['start'])) {
if ($_SESSION['bj'] != 1){

$i = 1;
while ($i < 24){
$t = 0;
$card[$i] = rand(1,48);
for($a = 1; $a < 25; $a++) {
if ($card[$i] != $card[$a]){ $t++; }
}
if ($t == 23) { $i++; }
}

$_SESSION['total_cards'] = 2;
$_SESSION['bj'] = 1;

for($i = 1; $i < 25; $i++) {
$_SESSION['card' . $i] = $card[$i];
}
}
}

if ($_SESSION['bj'] == 1){

if (isset($_GET['hit'])) {

$_SESSION['total_cards'] = $_SESSION['total_cards'] + 1;
}


$total_cards = $_SESSION['total_cards'];
for($i = 1; $i < ($total_cards + 1); $i++) {
if ($card[$i] == 8 OR $card[$i] == 16 OR $card[$i] == 24 OR $card[$i] == 32){ $value = '11'; }
else if ($card[$i] == 12 OR $card[$i] == 24 OR $card[$i] == 36 OR $card[$i] == 48){$value = '10'; }
else if ($card[$i] == 11 OR $card[$i] == 23 OR $card[$i] == 35 OR $card[$i] == 47){$value = '10'; }
else if ($card[$i] == 10 OR $card[$i] == 22 OR $card[$i] == 34 OR $card[$i] == 46){$value = '10'; }
else if ($card[$i] == 9 OR $card[$i] == 21 OR $card[$i] == 33 OR $card[$i] == 45){$value = '10'; }
else if ($card[$i] == 8 OR $card[$i] == 20 OR $card[$i] == 32 OR $card[$i] == 44){$value = '9'; }
else if ($card[$i] == 7 OR $card[$i] == 19 OR $card[$i] == 31 OR $card[$i] == 43){$value = '8'; }
else if ($card[$i] == 6 OR $card[$i] == 18 OR $card[$i] == 30 OR $card[$i] == 42){$value = '7'; }
else if ($card[$i] == 5 OR $card[$i] == 17 OR $card[$i] == 29 OR $card[$i] == 41){$value = '6'; }
else if ($card[$i] == 4 OR $card[$i] == 16 OR $card[$i] == 28 OR $card[$i] == 40){$value = '5'; }
else if ($card[$i] == 3 OR $card[$i] == 15 OR $card[$i] == 27 OR $card[$i] == 39){$value = '4'; }
else if ($card[$i] == 2 OR $card[$i] == 14 OR $card[$i] == 26 OR $card[$i] == 38){$value = '3'; }
else if ($card[$i] == 1 OR $card[$i] == 13 OR $card[$i] == 25 OR $card[$i] == 37){$value = '2'; }
$total_value = $total_value + $value;
}

echo $total_value;

if ($total_value > 21){
for($i = 1; $i < ($total_cards + 1); $i++) {
if ($card[$i] == 8 OR $card[$i] == 16 OR $card[$i] == 24 OR $card[$i] == 32){ $ace = $ace + 1; }
}
while ($total_value > 21 AND $ace > 0){
$ace = $ace - 1;
$total_value = $total_value - 10;
}
}

if ($total_cards == 2 AND $total_value == 21){ $_SESSION['bj'] = 6; }
if ($total_value > 21){ $_SESSION['bj'] = 2; }

if (isset($_GET['stand'])) {

while ($comp_total_value < 17){
$ace = 0;
$comp_total_cards = $comp_total_cards + 1;
$i = $comp_total_cards + 12;
if ($card[$i] == 8 OR $card[$i] == 16 OR $card[$i] == 24 OR $card[$i] == 32){ $value = '11'; }
else if ($card[$i] == 12 OR $card[$i] == 24 OR $card[$i] == 36 OR $card[$i] == 48){$value = '10'; }
else if ($card[$i] == 11 OR $card[$i] == 23 OR $card[$i] == 35 OR $card[$i] == 47){$value = '10'; }
else if ($card[$i] == 10 OR $card[$i] == 22 OR $card[$i] == 34 OR $card[$i] == 46){$value = '10'; }
else if ($card[$i] == 9 OR $card[$i] == 21 OR $card[$i] == 33 OR $card[$i] == 45){$value = '10'; }
else if ($card[$i] == 8 OR $card[$i] == 20 OR $card[$i] == 32 OR $card[$i] == 44){$value = '9'; }
else if ($card[$i] == 7 OR $card[$i] == 19 OR $card[$i] == 31 OR $card[$i] == 43){$value = '8'; }
else if ($card[$i] == 6 OR $card[$i] == 18 OR $card[$i] == 30 OR $card[$i] == 42){$value = '7'; }
else if ($card[$i] == 5 OR $card[$i] == 17 OR $card[$i] == 29 OR $card[$i] == 41){$value = '6'; }
else if ($card[$i] == 4 OR $card[$i] == 16 OR $card[$i] == 28 OR $card[$i] == 40){$value = '5'; }
else if ($card[$i] == 3 OR $card[$i] == 15 OR $card[$i] == 27 OR $card[$i] == 39){$value = '4'; }
else if ($card[$i] == 2 OR $card[$i] == 14 OR $card[$i] == 26 OR $card[$i] == 38){$value = '3'; }
else if ($card[$i] == 1 OR $card[$i] == 13 OR $card[$i] == 25 OR $card[$i] == 37){$value = '2'; }

$comp_total_value = $comp_total_value + $value;

if ($comp_total_value > 21){
for($i = 13; $i < ($comp_total_cards + 13); $i++) {
if ($card[$i] == 8 OR $card[$i] == 16 OR $card[$i] == 24 OR $card[$i] == 32){ $ace = $ace + 1; }
}
while ($comp_total_value > 21 AND $ace > 0){
$ace = $ace - 1;
$comp_total_value = $comp_total_value - 10;
}
}

}
echo "Player: $total_value Bank: $comp_total_value";

if ($total_value == $comp_total_value){ $_SESSION['bj'] = 5; }
if ($total_value < $comp_total_value ){ $_SESSION['bj'] = 4; }
if ($total_value > $comp_total_value OR $comp_total_value > 21){ $_SESSION['bj'] = 3; } //win

} else { $comp_total_cards = 1; }

echo "
Player Dealer
";
if ($_SESSION['total_cards'] >= $i){ display_card( $card[$i] ); }
echo "
";
if (isset($_GET['stand'])) {
if ($comp_total_cards >= $i){ display_card( $card[$c] ); }
} else {
$p++;
if($p == 1){ display_card( $card['13'] ); }
else if ($p == 2){
if ($_SESSION['bj'] == 6){
display_card( $card['14'] );
} else {
echo "[img=img/back.gif]";
}
}

}
echo "
";

}

echo "
[url="blackjack.php?hit"]Hit[/url] [url="blackjack.php?stand"]Stand[/url]

 

download the card graphics from here:

http://notoriousonline.net/img.zip

if you use this, and add querys to it, let me know, i would like to see it....

Link to comment
Share on other sites

Re: Black Jack

Haha, it logs you out when you finish a round, it unsets the session.

Also, if I try and add queries I get told it's not a proper mysql result resource thing, which I tried to fix by adding the global $c,$userid crap but yeah, LMFAO.

 

Well, I'll muck about with it and see what comes of it. :)

Link to comment
Share on other sites

Re: Black Jack

I had a 9 and a 6.  I hit Stay.  The dealer had a Queen.

The dealer beat me with a score of 17.  The catch?  Here is the cards the dealer showed:  Queen, 3, Ace, Queen, Jack, 3.

I'm not that great at math but I think that is 37.

EDIT:  Okay.  It happened a second time. Me:  6, 3, 5, Stand.

Dealer: 10, 5, Ace, 8, 10, 2, K, 8, J, 2, 7. 

I Lose.

The only common thread is the Ace as the third card.  The only time it doesnt error is when that 3rd Ace gives 21.

Edit X2: 

Here's an interesting one.  Dealer:  4, Ace, 7, Queen, 7

Game thinks dealer has 19:  Here's some cariable counts after each card:  The comp_total_value actually drops with the 7.

$comp_total_value      $total_value           $value

0   8  2

4  8  4

15  8  11

12  8  7

12  8  10

Link to comment
Share on other sites

Re: Black Jack

The problem is in the three large blocks of code that assign values and images to the card numbers.

The Aces are all jacked up and that gets all your other numbers off count. In the display pic portion, you also need to make changes to the Type code where it assigns suits. Took me about 20 minutes to make neccessary changes.

Link to comment
Share on other sites

Re: Black Jack

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Link to comment
Share on other sites

Re: Black Jack

That code helped a lot but there is still a problem somewhere.

My dealer currently shows: 8, 7, Ace, Queen, 2

And thinks the dealer has 18. It completely skiipped counting the Queen.

Just so everyone knows.

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Re: [mccode] Black Jack

 

is this for the v1 or v2 codes lol i love everyone posting these :-P just not many state what version it is for lol

If a code has this in it:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Then it is v1

That can also be found in generalpage.php

If it has

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

instead of all that then it is v2!

Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...
  • 4 weeks later...
  • 3 weeks later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...