function find_winner($userid) { global $db, $ir; $pscore = calc_playerscore($userid); $dscore = calc_dealerscore($userid); if ($pscore == $dscore) { return -1; //push } if ($pscore > $dscore && $pscore <= 21) { if ($pscore == 21) { return 2; //blackjack, 3 to 2 payout } else { return 1; //no blackjack, 1 to 1 payout } } if ($dscore > 21) { return 1; //1 to 1 payout } }
} else { $wtxt = "You lost to the dealer!"; $winamt = 0; } } } print "<div id=\"finaltext\" style=\"visibility:hidden\">{$wtxt} <br /><b>\$" . number_format($winamt) . "</b> was added to your wallet!<br /><br /></div>"; $db->query("DELETE FROM blackjack WHERE userid='{$userid}'"); print "<form method=post action='blackjack.php?act=deal'><input type=hidden name=betamount value={$oldbet}>\n\t\t\t<input type=submit id='end1' disabled=true value='New Game Same Bet'></form>\n\t\t\t <form method=post action='blackjack.php'><input type=submit id='end2' disabled=true value='New Game Change Bet'></form>"; } } else { 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);