index.php (rename page as u like)
Games Rules /Informations
Code:
<?php /*Coder- HaWK ENTERPRISES shared by:- Vishal */ session_start(); $default = false; $round1 = false; $round2 = false; if(!isset($_POST['mode'])){ $default = true; }else{ if($_POST['mode'] == 'round1' && isset($_POST['bet'])) $round1 = true; if($_POST['mode'] == 'round2' && isset($_POST['submit'])) $round2 = true; } if($default){ ?> <form action="" method="post"> <input type="hidden" name="mode" value="round1"> Bet <input type="text" size="2" name="bet"><input type="submit" name="submit" value="bet"> </form> <? } if($round1){ $card_points = array(2,3,4,5,6,7,8,9,10,10,10,10,1); $card_values = array(2,3,4,5,6,7,8,9,10,'J','Q','K','A'); $card_order = array(2,3,4,5,6,7,8,9,10,11,12,13,1); $card_suits = array('H','S','C','D'); $card_html = array("H"=>'♥',"S"=>'♠',"C"=>'♣',"D"=>'♦'); $bet = preg_replace('/[0-9]/','',$_POST['bet']); $deck = array(); foreach($card_suits as $idx=>$suit){ foreach($card_values as $idxv=>$value){ $deck[] = array('points' => $card_points[$idxv],'suit'=>$suit,'value'=>$value,'order'=>$card_order[$idxv],'str'=>$card_html[$suit].$value); } } shuffle($deck); $dealer[] = array_pop($deck); $dealer[] = array_pop($deck); $dealer[] = array_pop($deck); foreach($dealer as $vs) $sortAux[] = $vs['order']; array_multisort($sortAux, SORT_ASC, $dealer); $player[] = array_pop($deck); $player[] = array_pop($deck); $player[] = array_pop($deck); $sortAux = null; foreach($player as $vs) $sortAux[] = $vs['order']; array_multisort($sortAux, SORT_ASC, $player); display($dealer,true); echo ' '; display($player); $_SESSION['p'] = serialize($player); $_SESSION['d'] = serialize($dealer); $_SESSION['b'] = serialize($bet); ?> <form action="" method="post"> <input type="hidden" name="mode" value="round2"> <input type="submit" name="submit" value="fold"> <input type="submit" name="submit" value="raise"> </form> <? } if($round2){ if($fold){ header('Location:?'); exit; } // other functions $dealer = unserialize($_SESSION['d']); $player = unserialize($_SESSION['p']); $bet = unserialize($_SESSION['b']); $bonusbet = 0; $dealer_score = display($dealer); echo ' '; $player_score = display($player); if($dealer_score > 20 && $dealer_score > $player_score){ echo 'Dealer does not qualify'; echo 'You get your money back'; }else{ echo 'You lose your money'; } if($dealer_score > $player_score){ echo 'You win. '; if($player_score == 0){ $bonusbet = $bet * 25; }elseif($player_score > 0 && $player_score <= 6){ $bonusbet = $bet * 4; }elseif($player_score > 6 && $player_score <= 10){ $bonusbet = $bet; }elseif($player_score > 10 && $player_score <= 12){ $bonusbet = $bet*4; } if($player_score == 0){ $bet = $bonusbet + ($bet * 4); }elseif($player_score > 0 && $player_score <= 5){ $bet = $bonusbet + ($bet * 2); }elseif($player_score > 5 && $player_score <= 19){ $bet = $bonusbet + $bet; } echo 'Your Score:'.$bet; } echo ' [url="?"]New[/url]'; } function display($hand,$isDealer = false){ $score = null; for($i=0;$i<3;$i++){ if($isDealer) echo '<div style="border:1px solid black;width:50px;display:inline;padding:2px;"></div>'; else echo '<div style="border:1px solid black;width:38px;display:inline;padding:2px;">'.$hand[$i]['str'].'</div>'; } if($isDealer == false) $score = calculate_score($hand); if($score != null) echo $score; return $score; } function calculate_score($hand){ $card2suit = false; $card2suitb = false; $card3suit = false; $pairA = false; $pairB = false; $triple = false; //suited run check if($hand[0]['suit'] == $hand[1]['suit']){ $diff = $hand[1]['order'] - $hand[0]['order']; if($diff == 1){ $card2suit = true; } } if($hand[1]['suit'] == $hand[2]['suit']){ $diff = $hand[2]['order'] - $hand[1]['order']; if($diff == 1){ $card2suitb = true; } } if($card2suit && $card2suitb) $card3suit = true; if($hand[0]['value'] == $hand[1]['value']) $pairA = true; if($hand[1]['value'] == $hand[2]['value']) $pairB = true; if($pairA && $pairB) $triple = true; if($card3suit || $triple) return 0; if($card2suit || $pairA) return $hand[2]['points']; if($card2suitb || $pairB) return $hand[0]['points']; return $hand[0]['points']+$hand[1]['points']+$hand[2]['points']; } ?>
Games Rules /Informations
Code:
Description and Objective The game of Vegas Three Card Rummy is played between the Dealer and the Player with a 52-card deck. The Player is dealt three cards face up and the Dealer is dealt three cards face down. The goal of Vegas Three Card Rummy is to get fewer points than the Dealer. The Dealer's hand must have 20 points or less to qualify. If the Dealer does not qualify, the Player wins even money on the Ante and the Raise is returned. The payout for the Bonus Bet is determined independently from the Dealer's hand. Vegas Three Card Rummy Rules: * Cards are dealt from a single deck. * Both Dealer and Player receive three cards. The Dealer's cards are dealt face down. * The Bonus Bet is paid based on the pay table located below. * Cards are shuffled after every hand. Card Values Cards 2 through 10 = face value Jack, Queen, King = 10 points Aces = 1 point Any Pair = 0 points Any Triple = 0 points Two-card Suited Run = 0 points Three-card Suited Run = 0 points Note - Ace, King is not a suited run Important - When a hand can be scored as either a pair or a two-card suited run and neither leads to a lower score, the two-card suited run will always be used to determine the score. When a hand can be scored as either a pair or a two-card suited run, the two-cards that will be chosen will result in the lowest possible score for a given hand. The Ante Wager After placing an Ante wager the Player is dealt 3 cards face up and the Dealer receives 3 cards face down. If the Player does not believe their hand can beat the Dealer, the Player can fold the hand and forfeit the Ante wager. If the Player believes the hand can beat the Dealer's hand, the Player must Raise with a wager equal to the Ante amount. After Raising, the Dealer's cards will be revealed. To qualify the Dealer's hand must contain 20 points or less. If qualified, the Dealer's hand will be compared to the Player's hand, the winner having the lowest point total in their hand. If the Dealer has the lowest point total the Player loses both the Ante and Raise bets. If the Dealer does not qualify, the Player wins even money on the Ante and the Raise wager is returned. If the Player has the lowest point total the Ante is paid 1:1 and the Raise wager is paid according to the pay-table (see below). The Bonus Bet The Bonus Bet is won if the Player's hand contains 12 points or less. The Bonus Bet wager is a not measured against the Dealer's hand, it is paid out based on the point total of the hand dealt, (see pay-table below). If the Player wagers on the Ante and folds the hand the Bonus Bet wager is also forfeited. Bonus Bet Payouts A-2-3 Suited Run 100:1 0 25:1 1-6 2:1 7-10 1:1 11-12 4:1 Payouts - Raise Bet Winner Score Payouts Player 0 4:1 Player 1-5 2:1 Player 6-19 1:1 Player/Dealer Tie Any Push The Player can win if: * Ante- If the Player 3-card point total is less than the Dealer. Or if the Player Raises and the Dealer does not qualify with 20 points or less. * Raise - If the Player's 3-card point total is less than the Dealer's point total and the Dealer qualifies by having 20 points or less. * Bonus Bet - If the Player is dealt 12 points or less. The Player loses if: * Ante - If the Player folds or if the Dealer has a lower point total than the Player * Raise - If the Dealer has a lower point total than the Player. * Bonus Bet - If the Player does not receive a point total of 12 points or less. Player Actions/Button Descriptions: Bet - To place an Ante wager, the Player must click on the Ante circle and then the chip value that they wish to wager. To place a Bonus Bet wager the Player must click on the Bonus Bet diamond and then on the desired chip value they wish to wager. Deal - Press Deal to begin the game once the wagers have been placed. The Player is dealt three cards face up and the Dealer is dealt three cards face down. Raise - If the Player feels they can beat the Dealer, click Raise to continue. The Raise amount will be equal to the Ante. The Dealer's cards are then revealed and compared to the Player's hand to determine a winner. Fold - Clicking on the Fold button ends the current game and forfeits the Ante and Bonus Bet wagers.
Comment