Jump to content

Recommended Posts

hey im new to this web site im looking for some help with my code its suppose to be a black jack game

im trying to make an array that can hold the value of the cards once the person presses the hit me button

please help me  i havent fully develop code yet so you can ignore the comments code if you like thanks for looking

at it.

 

<html>
<head>
<title>poker dice</title>
<style type = "text/css">
body {
  background: green;
  color: tan;
}

</style>
</head>

<body>
<center>
<h1>Poker Dice</h1>

<form>

<?
$number = $_REQUEST["number"];
$statue = $_REQUEST["statue"];

$number2 = unserialize(urldecode($number));

//check to see if this is first time on the page.
if ($statue == null){

    if ((!$cash) && (!$card_counter)){

        Print "You will start out with a value of 100 dollars and points of 0.";
  $cash = 100;
  $card_counter = 0;
   
} // end if

Cards($number);
printPage();

}else if($statue == 1){

    Cards2($number);
    printPage();

   // print "this is the second page";
}else if($statue == 2){

    Cards3($number);
    printPage();

   // print "this is the second page";
}else if($statue == 3){

    Cards4($number);
    printPage();

   // print "this is the second page";
}else if($statue == 4){

    Cards5($number);
    printPage();

   // print "this is the second page";
}else if($statue == 5){

    Cards6($number);
    printPage();

   // print "this is the second page";
}else if($statue == 6){

    Cards7($number);
    printPage();

   // print "this is the second page";
}else if($statue == 7){

    Cards8($number);
    printPage();

   // print "this is the second page";
}else{

    Cards9($number);
    printPage();

   // print "this is the second page";
}



//rollDice();



if ($secondRoll == TRUE){
  print "<h2>Second roll</h2>\n";
  $secondRoll = FALSE;
  evaluate();
} else {
  print "<h2>First roll</h2>\n";
  $secondRoll = TRUE;
} // end if

printStuff();


function Cards($number){

    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);
$num2 = rand(1,52);


echo $Cards[$num1];
//echo " ____ ";

echo $Cards[$num2];
  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[0] = $Cards[$num1];
   $cards_array[1] = $Cards[$num2];
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;

      print $cards_array[0];
   print $cards_array[1];


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "1">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;



   // by using the number and requestinh it will store the value of that array.
   //it good using a hidden box for this method.












//if ($Deck[$num1] == TRUE || $Deck[$num2] == TRUE) {


//}

//$CurrentHand = $Deck[$num1];
//$Deck = explode(",",$CurrentHand[0]);
//$Hit = array_shift($Deck);
//$Cards = implode(",",$Deck);
//if (isset($CurrentHand[1]))
//	$PlayersHand = explode("~", $CurrentHand[1]);
//$PlayersHand[] = $Hit;
//$CardCount = 0;
/*$Aces = 0;
for ($i=0; $i<count($PlayersHand); ++$i) {
	if (strpos($PlayersHand[$i], "Ace") !== FALSE)
		++$Aces;
	else if (strpos($PlayersHand[$i], "Two") !== FALSE)
		$CardCount += 2;
	else if (strpos($PlayersHand[$i], "Three") !== FALSE)
		$CardCount += 3;
	else if (strpos($PlayersHand[$i], "Four") !== FALSE)
		$CardCount += 4;
	else if (strpos($PlayersHand[$i], "Five") !== FALSE)
		$CardCount += 5;
	else if (strpos($PlayersHand[$i], "Six") !== FALSE)
		$CardCount += 6;
	else if (strpos($PlayersHand[$i], "Seven") !== FALSE)
		$CardCount += 7;
	else if (strpos($PlayersHand[$i], "Eight") !== FALSE)
		$CardCount += 8;
	else if (strpos($PlayersHand[$i], "Nine") !== FALSE)
		$CardCount += 9;
	else if (strpos($PlayersHand[$i], "Ten") !== FALSE)
		$CardCount += 10;
	else if (strpos($PlayersHand[$i], "Jack") !== FALSE)
		$CardCount += 10;
	else if (strpos($PlayersHand[$i], "Queen") !== FALSE)
		$CardCount += 10;
	else if (strpos($PlayersHand[$i], "King") !== FALSE)
		$CardCount += 10;
}
$Cards = $Cards .implode("~", $PlayersHand);
if ($Aces > 0) {
	for ($i=1; $i<=$Aces;++$i) {
		if ($CardCount+11 <= 21)
			$CardCount += 11;
		else
			$CardCount += 1;
	}
}
if ($CardCount == 21)
	$Cards = $Cards . "\nYou win!";
else if ($CardCount> 21)
	$Cards = $Cards . "\nYou lose!";


//print $Deck;


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "7">
    <center>
    <input type = "submit"
           value = "play hand">
    </center>
    </td>
  </tr>
  </table>

HERE;*/


}//end function


function Cards2($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);



echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[2] = $Cards[$num1];
   
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;

   print $cards_array[0];
   print $cards_array[1];
    print $cards_array[2];


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "2">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;


}


function Cards3($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);



echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[3] = $Cards[$num1];
  
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;

      print $cards_array[0];
   print $cards_array[1];
      print $cards_array[2];
   print $cards_array[3];

print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "3">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;

}

function Cards4($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);



echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[4] = $Cards[$num1];
   
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "4">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;


}

function Cards5($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);
$num2 = rand(1,52);


echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[5] = $Cards[$num1];

   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "5">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;


}

function Cards6($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);



echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[6] = $Cards[$num1];
  
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "6">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;


}

function Cards7($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);
$num2 = rand(1,52);


echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[7] = $Cards[$num1];
   
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "7">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;


}

function Cards8($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);



echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[8] = $Cards[$num1];
   
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "8">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;

}

function Cards9($number){
    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);



echo $Cards[$num1];
//echo " ____ ";


  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[9] = $Cards[$num1];
  
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;


// print <<<HERE
// </tr></td>
// <tr>
   // <td colspan = "5">
   // <center>
    //<form methods = "post"
    //      action = "PokerFinal.php">
    //<input type = "submit"
      //    value = "Hit Me">
      //  <input type = "hidden"
        //   name = "number"
        //  value = "$serialCards">
            //  <input type ="hidden"
                  //   name ="statue"
               //      value = "9">
              //</form>
    //</center>
   // </td>
//  </tr>
//  </table>

//HERE;
print "No more HIT ME button";

   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;


}

function printPage(){




}//end functon




//function rollDice(){
// global $die, $secondRoll, $keepIt;

  //print "<table border = 1><td><tr>";

  //for ($i = 0; $i < 5; $i++){
  	//if ($keepIt[$i] == ""){
      //$die[$i] = rand(1, 6);
  	//} else {
      //$die[$i] = $keepIt[$i];
  	//} // end if
    //$theFile = "die" . $die[$i] . ".jpg";

    //print out dice images
  //  print <<<HERE
   // <td>
   // <img src = "$theFile"
    //     height = 50
    //     width = 50><br>

//HERE;
    //print out a checkbox on first roll only
  //  if ($secondRoll == FALSE){
  //    print <<<HERE
   // <input type = "checkbox"
          // name = "keepIt[$i]"
           //value = $die[$i]>
    //</td>

//HERE;

  //  } // end if
// } // end for loop

  //print out submit button and end of table
  //print <<<HERE
  //</tr></td>
  //<tr>
   // <td colspan = "5">
   // <center>
    //<input type = "submit"
     //      value = "roll again">
    //</center>
   // </td>
  //</tr>
  //</table>

//HERE;
  	
//} // end rollDice

function evaluate(){
  global $die, $cash;
  //set up payoff
  $payoff = 0;

  //subtract some money for this roll
  $cash -= 2;

  //count the dice
  for ($theVal = 1; $theVal <= 6; $theVal++){
  	for ($dieNum = 0; $dieNum < 5; $dieNum++){
  	  if ($die[$dieNum] == $theVal){
  	    $numVals[$theVal]++;
  	  } // end if
  	} // end dieNum for loop
  } // end theVal for loop

  //print out results
  //  for ($i = 1; $i <= 6; $i++){
  //  	print "$i:  $numVals[$i]<br>\n";
  //  } // end for loop

  //count how many pairs, threes, fours, fives
  $numPairs = 0;
  $numThrees = 0;
  $numFours = 0;
  $numFives = 0;

  for ($i = 1; $i <= 6; $i++){
    switch ($numVals[$i]){
      case 2:
        $numPairs++;
        break;
      case 3:
        $numThrees++;
        break;
      case 4:
        $numFours++;
        break;
      case 5:
        $numFives++;
        break;
    } // end switch
  } // end for loop

  //check for two pairs
  if ($numPairs == 2){
    print "You have two pairs!<br>\n";
    $payoff = 1;
  } // end if

  //check for three of a kind and full house
  if ($numThrees == 1){
    if ($numPairs == 1){
      //three of a kind and a pair is a full house
      print "You have a full house!<br>\n";
      $payoff = 5;
    } else {
      print "You have three of a kind!<br>\n";
      $payoff = 2;
    } // end 'pair' if
  } // end 'three' if

  //check for four of a kind
  if ($numFours == 1){
    print "You have four of a kind!<br>\n";
    $payoff = 5;
  } // end if

  //check for five of a kind
  if ($numFives == 1){
    print "You got five of a kind!<br>\n";
    $payoff = 10;
  } // end if

  //check for flushes
  if (($numVals[1] == 1)
    && ($numVals[2] == 1)
    && ($numVals[3] == 1)
    && ($numVals[4] == 1)
    && ($numVals[5] == 1)){
    print "You have a flush!<br>\n";
    $payoff = 10;
  } // end if

  if (($numVals[2] == 1)
    && ($numVals[3] == 1)
    && ($numVals[4] == 1)
    && ($numVals[5] == 1)
    && ($numVals[6] == 1)){
    print "You have a flush!<br>\n";
    $payoff = 10;

  } // end if
  print "You bet 2<br>\n";
  print "Payoff is $payoff<br>\n";
  $cash += $payoff;

} // end evaluate

function printStuff(){
  global $cash, $secondRoll;

  print "Cash: $cash\n";

  //store variables in hidden fields
  print <<<HERE
  <input type = "hidden"
         name = "secondRoll"
         value = "$secondRoll">

  <input type = "hidden"
         name = "cash"
         value = "$cash">

HERE;
} // end printStuff

?>

</form>
</center>
</html>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/237572-black-jack-game-help/
Share on other sites

OK, that's a lot of code to go through, which I highly doubt people are going to be willing to do.  You need to first figure out what the problem is, then try and isolate it.  What happens, what's supposed to happen?  Do you get errors?  Are you stuck on a particular part of the code/logic?  We need more information...

Agree with the above

 

You can save a LOT of code by populating your decks like this:

<?php

$cards = array('Ace'=>11,'Two'=>2,'Three'=>3,'Four'=>4,'Five'=>5,
'Six'=>6,'Seven'=>7,'Eight'=>8,'Nine'=>9,'Ten'=>10, 'Jack'=>10,
'Queen'=>10, 'King'=>10);
$suits = array('Spades','Diamonds','Clubs','Hearts');

$deck = array();
foreach( $suits as $suit )
$deck[$suit] = $cards;

print_r( $deck );

?>

 

 

sorry about that long line of codes guys, what i was trying to say is that there a submit button in every the function that i made in each if statement so when the user hit the hit me button for the game its suppose to add more cards to the array to then it hit it should still display

card that was displayed on the first and the othere turns when to user hit the button im trying to find a way to store that value so the user will be able to see the cards on the with the same value once the button is hit im not sure how it should be done please help if you can please the rule im try to make for the can is that when the user first enter the web site it will display 2 cards and when the person hits the submit button it will display another addition to the same 2 cards just to clarify it.

 


$number = $_REQUEST["number"];
$statue = $_REQUEST["statue"];

$number2 = unserialize(urldecode($number));

//check to see if this is first time on the page.
if ($statue == null){

    if ((!$cash) && (!$card_counter)){

        Print "You will start out with a value of 100 dollars and points of 0.";
  $cash = 100;
  $card_counter = 0;
   
} // end if

Cards($number);
printPage();

}else if($statue == 1){

    Cards2($number);
    printPage();

   // print "this is the second page";
}else if($statue == 2){

    Cards3($number);
    printPage();

   // print "this is the second page";
}else if($statue == 3){

    Cards4($number);
    printPage();

   // print "this is the second page";
}else if($statue == 4){

    Cards5($number);
    printPage();

   // print "this is the second page";
}else if($statue == 5){

    Cards6($number);
    printPage();

   // print "this is the second page";
}else if($statue == 6){

    Cards7($number);
    printPage();

   // print "this is the second page";
}else if($statue == 7){

    Cards8($number);
    printPage();

   // print "this is the second page";
}else{

    Cards9($number);
    printPage();

   // print "this is the second page";
}



//rollDice();



if ($secondRoll == TRUE){
  print "<h2>Second roll</h2>\n";
  $secondRoll = FALSE;
  evaluate();
} else {
  print "<h2>First roll</h2>\n";
  $secondRoll = TRUE;
} // end if

printStuff();


function Cards($number){

    $Diamonds = array(
"Ace of Diamonds",
"Two of Diamonds",
"Three of Diamonds",
"Four of Diamonds",
"Five of Diamonds",
"Six of Diamonds",
"Seven of Diamonds",
"Eight of Diamonds",
"Nine of Diamonds",
"Ten of Diamonds",
"Jack of Diamonds",
"Queen of Diamonds",
"King of Diamonds");
$Clubs = array(
"Ace of Clubs",
"Two of Clubs",
"Three of Clubs",
"Four of Clubs",
"Five of Clubs",
"Six of Clubs",
"Seven of Clubs",
"Eight of Clubs",
"Nine of Clubs",
"Ten of Clubs",
"Jack of Clubs",
"Queen of Clubs",
"King of Clubs");
$Hearts = array(
"Ace of Hearts",
"Two of Hearts",
"Three of Hearts",
"Four of Hearts",
"Five of Hearts",
"Six of Hearts",
"Seven of Hearts",
"Eight of Hearts",
"Nine of Hearts",
"Ten of Hearts",
"Jack of Hearts",
"Queen of Hearts",
"King of Hearts");
$Spades = array(
"Ace of Spades",
"Two of Spades",
"Three of Spades",
"Four of Spades",
"Five of Spades",
"Six of Spades",
"Seven of Spades",
"Eight of Spades",
"Nine of Spades",
"Ten of Spades",
"Jack of Spades",
"Queen of Spades",
"King of Spades");
$Cards = array_merge($Diamonds, $Clubs);
$Cards = array_merge($Cards, $Hearts);
$Cards = array_merge($Cards, $Spades);
//$Deck = shuffle($Cards);

$num1 = rand(1,52);
$num2 = rand(1,52);


echo $Cards[$num1];
//echo " ____ ";

echo $Cards[$num2];
  // }else{
   //    echo "There is no cards being displayed.";
//  }//close second if statement

//  }//close first if statement



   $cards_array[0] = $Cards[$num1];
   $cards_array[1] = $Cards[$num2];
   //it take the object of a string and pass it as a array.

   $serialCards = urlencode(serialize($cards_array));

   print_r($cards_array);
   print "<br>";
   print $serialCards;

      print $cards_array[0];
   print $cards_array[1];


print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <form methods = "post"
          action = "PokerFinal.php">
    <input type = "submit"
          value = "Hit Me">
        <input type = "hidden"
           name = "number"
          value = "$serialCards">
              <input type ="hidden"
                     name ="statue"
                     value = "1">
              </form>
    </center>
    </td>
  </tr>
  </table>

HERE;


   print <<<HERE
  </tr></td>
  <tr>
    <td colspan = "5">
    <center>
    <input type = "submit"
          value = "roll again">
    </center>
    </td>
  </tr>
  </table>

HERE;



}





i have another question do you guys know how to sort images inside of arrays, and how i can store or keep the value of that image if someone hit the submit button any advice will be helpful. thanks

I don't know how your images are stored or what you system looks like, but normally you would store the path of the image while storing the physical images on your server so you can just reference them.  Then you would sort the array like any normal array.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.