Jump to content
MakeWebGames

installed black jack and cant see card


thebobby

Recommended Posts

<?php

require "globals.php";

global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
print "<h3>Black Jack</h3>";

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;
 }

 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 "<table><tr><td>Player </td> <td> Dealer</td></tr>";

 if ($_SESSION['total_cards'] > $comp_total_cards){ $rows = $_SESSION['total_cards'];  }
 else { $rows = $comp_total_cards; }

 for($i = 1; $i < ($rows + 1); $i++) { 
 $c = $i + 12;
 echo "<tr><td>";
 if ($_SESSION['total_cards'] >= $i){ display_card( $card[$i] ); }
 echo "</td><td>"; 
 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 "</td></tr>";

 }
 echo "</table>";

}

echo "<table><tr>";
if ($_SESSION['bj'] == 1){
?>
<td>[url="blackjack.php?hit"]Hit[/url]</td><td>[url="blackjack.php?stand"]Stand[/url]</td>
<?
} else {
print "

[url='blackjack.php?start']Bet[/url]</table>";
}


function display_card( $card ){
 //Type
 if ($card < 13){ $type = "s"; }
 else if ($card < 25){ $type = "c"; }
 else if ($card < 37){ $type = "h"; }
 else { $type = "d"; }
 //Numer
 if ($card == 8 OR $card == 16 OR $card == 24 OR $card == 32){$card = '14'; }
 else if ($card == 12 OR $card == 24 OR $card == 36 OR $card == 48){$card = '13'; }
 else if ($card == 11 OR $card == 23 OR $card == 35 OR $card == 47){$card = '12'; }
 else if ($card == 10 OR $card == 22 OR $card == 34 OR $card == 46){$card = '11'; }
 else if ($card == 9 OR $card == 21 OR $card == 33 OR $card == 45){$card = '10'; }
 else if ($card == 8 OR $card == 20 OR $card == 32 OR $card == 44){$card = '9'; }
 else if ($card == 7 OR $card == 19 OR $card == 31 OR $card == 43){$card = '8'; }
 else if ($card == 6 OR $card == 18 OR $card == 30 OR $card == 42){$card = '7'; }
 else if ($card == 5 OR $card == 17 OR $card == 29 OR $card == 41){$card = '6'; }
 else if ($card == 4 OR $card == 16 OR $card == 28 OR $card == 40){$card = '5'; }
 else if ($card == 3 OR $card == 15 OR $card == 27 OR $card == 39){$card = '4'; }
 else if ($card == 2 OR $card == 14 OR $card == 26 OR $card == 38){$card = '3'; }
 else if ($card == 1 OR $card == 13 OR $card == 25 OR $card == 37){$card = '2'; }


 echo "[img=img/" . $type . $card . ".gif]";


}


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

 echo "
You lose"; 

unset($_SESSION['bj']);
unset($_SESSION['card']);
unset($_SESSION['totalcards']);
}
else if ($_SESSION['bj'] == 3){


 echo "
You Win!!"; 



unset($_SESSION['bj']);
unset($_SESSION['card']);
unset($_SESSION['totalcards']);
}


else if ($_SESSION['bj'] == 4){


 echo "
You lose"; 

unset($_SESSION['bj']);
unset($_SESSION['card']);
unset($_SESSION['totalcards']);
}
else if ($_SESSION['bj'] == 5){
 //lose
 echo "
Push!"; 
unset($_SESSION['bj']);
unset($_SESSION['card']);
unset($_SESSION['totalcards']);
}
else if ($_SESSION['bj'] == 6){


echo "
Black Jack!!"; 


}
$h->endpage();
?>
Link to comment
Share on other sites

Hi there,

 

From what i see you need to have a folder called img.

echo "[img=img/" . $type . $card . ".gif]"; 

As seen here the images should be in there or you need to create them yourself also need to have back.gif created too.

 

Don't worry about the tags i did them for you

Link to comment
Share on other sites

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...