Guest User

Untitled

a guest
May 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.05 KB | None | 0 0
  1. <?php
  2.  
  3. include('blackjack.class.php');
  4.  
  5. $data = new BlackJack();
  6.  
  7. if(isset($_POST['start'])) {
  8.     $playercards = $data->FirstDraw();
  9.     $_SESSION['cardset'] = 1;
  10.     $_SESSION['showform'] = 1;
  11.     $_SESSION['bet'] = $_POST['bet'];
  12. }
  13. if($_SESSION['cardset'] == 1) {
  14.     if($_SESSION['showform'] == 1) {
  15.         echo '<form method="POST">';
  16.         echo '<input type="submit" name="draw" value="Trek een kaart">';
  17.         echo '<input type="submit" name="stop" value="stop">';
  18.         echo '</form>';
  19.     }
  20.     else {
  21.         echo '<form method="POST">';
  22.         echo '<select name="bet"><option value="2.5">2.5</option></select>';
  23.         echo '<input type="submit" name="start" value="start">';
  24.         echo '</form>';
  25.     }
  26.     if(isset($_POST['draw'])) {
  27.         $playercards[] = Draw();
  28.     }
  29.    
  30.    
  31.     echo 'Er is '.$_SESSION['bet'].' ingezet. <br />';
  32.    
  33.     echo 'Uw twee eerste kaarten zijn:<br />';
  34.    
  35.     $toreplace = array('10','11','12','13','1');
  36.     $replaceby = array('t','j','q','k','a');
  37.        
  38.     foreach($playercards as $card) {       
  39.         $str = str_replace($toreplace, $replaceby, $card);
  40.         echo '<img src="cards/'.$str.'h.gif" />';
  41.     }
  42.    
  43.     if(isset($_POST['stop']) || $data->CardCount($playercards) >= 21) {
  44.         $computercards = $data->ComputerDraw($data->CardCount($playercards));
  45.        
  46.         $_SESSION['showform'] = false;
  47.        
  48.         echo '<br /><br /><br />De computer trekt: ';
  49.         foreach($computercards as $card) {
  50.             $str = str_replace($toreplace, $replaceby, $card);     
  51.         echo '<img src="cards/'.$str.'h.gif" />';
  52.         }  
  53.        
  54.         echo '<br /><br /><br />';
  55.         $result = $data->ShowResults($playercards, $computercards);
  56.        
  57.         echo $result[1];
  58.        
  59.         if($result[2] == 0) {
  60.             $price = $_SESSION['bet'] * 2;
  61.             echo 'U krijgt '.$price.' van ons.';
  62.         }
  63.         elseif($result[2] == 1) {
  64.             $price = $_SESSION['bet'];
  65.             echo 'U verliest '.$price.'.';
  66.         }
  67.         else {
  68.             $price = $_SESSION['bet'];
  69.             echo 'U krijgt '.$price.' van ons terug.';
  70.         }
  71.     }  
  72.    
  73. }
  74. else { 
  75.     echo '<form method="POST">';
  76.     echo '<select name="bet"><option value="2.5">2.5</option></select>';
  77.     echo '<input type="submit" name="start" value="start">';
  78.     echo '</form>';
  79. }
  80.    
  81. ?>
Add Comment
Please, Sign In to add comment