print $error; } } else { if ($_GET['act'] == 'stand') { $playerhas = calc_playerscore($userid); if ($playerhas > 21) { $error = "You went bust."; $db->query("DELETE FROM blackjack WHERE userid='{$userid}'"); } if (!$playingbj) { $error = "You do not have an active blackjack game. Begin a new one <a href=blackjack.php>HERE</a>."; } if (!$error) { print "You bet: <b>\$" . number_format($bb['betAmount']) . "</b>.<br /><br />"; dealer_play($userid); $dscore = calc_dealerscore($userid); $cards = show_cards($userid, 2); print "<button name='dealersbutton' id='dealersbutton' onClick=\"rotateImage('dealer1')\">Click to begin dealer's turn</button><br />"; print "{$cards}<br />"; $win = find_winner($userid); if ($win == -1) { $winamt = $bb['betAmount']; $wtxt = "You and the dealer tied. You received your bet amount back."; $db->query("UPDATE users SET money=money+{$winamt} WHERE userid='{$userid}'"); } else { if ($win == 1) { $winamt = $bb['betAmount'] * 2; $wtxt = "Your hand beat the dealer's!"; $db->query("UPDATE users SET money=money+{$winamt} WHERE userid='{$userid}'"); } else { if ($win == 2) {
function dealer_play($userid) { global $db, $ir; $i = 0; $dscore = calc_dealerscore($userid); while ($dscore < 17 && $i <= 3) { $i++; $db->query("UPDATE blackjack SET dNumHits=dNumHits+1 WHERE userid='{$userid}'"); $dscore = calc_dealerscore($userid); } }