Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('blackjack.class.php');
- $data = new BlackJack();
- if(isset($_POST['start'])) {
- $playercards = $data->FirstDraw();
- $_SESSION['cardset'] = 1;
- $_SESSION['showform'] = 1;
- $_SESSION['bet'] = $_POST['bet'];
- }
- if($_SESSION['cardset'] == 1) {
- if($_SESSION['showform'] == 1) {
- echo '<form method="POST">';
- echo '<input type="submit" name="draw" value="Trek een kaart">';
- echo '<input type="submit" name="stop" value="stop">';
- echo '</form>';
- }
- else {
- echo '<form method="POST">';
- echo '<select name="bet"><option value="2.5">2.5</option></select>';
- echo '<input type="submit" name="start" value="start">';
- echo '</form>';
- }
- if(isset($_POST['draw'])) {
- $playercards[] = Draw();
- }
- echo 'Er is '.$_SESSION['bet'].' ingezet. <br />';
- echo 'Uw twee eerste kaarten zijn:<br />';
- $toreplace = array('10','11','12','13','1');
- $replaceby = array('t','j','q','k','a');
- foreach($playercards as $card) {
- $str = str_replace($toreplace, $replaceby, $card);
- echo '<img src="cards/'.$str.'h.gif" />';
- }
- if(isset($_POST['stop']) || $data->CardCount($playercards) >= 21) {
- $computercards = $data->ComputerDraw($data->CardCount($playercards));
- $_SESSION['showform'] = false;
- echo '<br /><br /><br />De computer trekt: ';
- foreach($computercards as $card) {
- $str = str_replace($toreplace, $replaceby, $card);
- echo '<img src="cards/'.$str.'h.gif" />';
- }
- echo '<br /><br /><br />';
- $result = $data->ShowResults($playercards, $computercards);
- echo $result[1];
- if($result[2] == 0) {
- $price = $_SESSION['bet'] * 2;
- echo 'U krijgt '.$price.' van ons.';
- }
- elseif($result[2] == 1) {
- $price = $_SESSION['bet'];
- echo 'U verliest '.$price.'.';
- }
- else {
- $price = $_SESSION['bet'];
- echo 'U krijgt '.$price.' van ons terug.';
- }
- }
- }
- else {
- echo '<form method="POST">';
- echo '<select name="bet"><option value="2.5">2.5</option></select>';
- echo '<input type="submit" name="start" value="start">';
- echo '</form>';
- }
- ?>
Add Comment
Please, Sign In to add comment