Location: PHPKode > scripts > PHP Poker Engine > php-poker-engine/aPokerGameEngineTestv3.php
<?php
	// includes class that creates a deck of cards with shuffle methods
	include("pokerDeck3.php");
	include("phpPokerEngineV3.1.php");
		
	//creates new deck object and then shuffles it
	$aDeck = new Deck();
	$aDeck->mixThem();
	print"<p>This is the shuffled deck: </p>";
	print_r($aDeck);
	print"<p>\n</p>";
		
	$playnum=8; //sets the number of players
	$cardcounter; //used to iterate the first card value
	$secondcard=($playnum+1);//iterates the second value
	$allhands = array();//master array holding all hands
	//loop that sets values of cards and pushes them into master array
	for($cardcounter=0;$cardcounter<=$playnum;$cardcounter++)
		{
		//set Card1 and set Card2 in the loop
				$c1=$aDeck->deck[$cardcounter];//these values should be cards from the deck
				$c2=$aDeck->deck[$secondcard];//these values should be cards from the deck
				$hand = array ($c1,$c2);//defines a hand as the values of cards 1 & 2
				array_push($allhands, $hand);//pushes the hands into the master array
				$secondcard++;//icrements the second card values - since it is not in
				//the for loop
		}//end for loop
		print"<p>This is the array for all pocket hands: </p>";
		print_r($allhands);
		print"<p>\n</p>";
		print"<p>\n</p>";
		print"<p>\n</p>";	
		//create the flop
		$flop=array();//creates the array to store all flop cards
		$flopStart=($playnum*2)+2;//start position for flop cards
		$x;//start variable for the for loop
		$flopCards=8;//defines how many cards in flop inclusive of burns
		for($x=0;$x<=$flopCards;$x++)//loop to populate the flop
		{
			$c3=$aDeck->deck[$flopStart];
			array_push($flop, $c3);
			$flopStart++;
		}
		print"<p>This is the Flop (including burn cards): </p>";
		print_r($flop);
		//print"<p>$flopStart</p>"; //debug code
		print"<p>\n</p>";
		print"<p>This is the actual flop</p>";	
		print_r($flop[1]." ");
		print_r($flop[2]." ");
		print_r($flop[3]." ");
		print_r($flop[5]." ");
		print_r($flop[7]." ");
		
		
		//create new hands that include the flop cards
		$flopPlayCards=array($flop[1],$flop[2],$flop[3],$flop[5],$flop[7]);
		$finalHandCounter1;
		$finalHands=array();
		$z=0;
		//$zz=($z+1);
		for($finalHandCounter1=0;$finalHandCounter1<=$playnum;$finalHandCounter1++)
		{
				array_push($allhands[$z], $flopPlayCards);
				$z++;
		}//end for loop
		print"<p>\n</p>";
		print"<p>This shows each players hands with the flop - the allhand array: </p>";
		print_r($allhands);
		print"<p>\n</p>";
		print"<p>\n</p>";
		print"<p>all players hands: </p>";
		$var1;
		$var2=2;
		$var3=0;
		$var4=($var1+1);
		$var5;

		for($var1=0;$var1<=$playnum;$var1++){
		print"<p>This is player: $var1 </p>";
		//prints the first two cards
		print_r($allhands[$var1][$var3]." ".$allhands[$var1][$var4]." ");
		//prints the next cards from the flop
		print_r($allhands[$var1][$var2][$var3]." ".$allhands[$var1][$var2][($var3+1)]." ".$allhands[$var1][$var2][($var3+2)]." ".$allhands[$var1][$var2][($var3+3)]." ".$allhands[$var1][$var2][($var3+4)]);
		
		//creates a string of the hands to test against for patterns		
		$evaluateString = ($allhands[$var1][$var3].$allhands[$var1][$var4].$allhands[$var1][$var2][$var3].$allhands[$var1][$var2][($var3+1)].$allhands[$var1][$var2][($var3+2)].$allhands[$var1][$var2][($var3+3)].$allhands[$var1][$var2][($var3+4)]);
		//this will be used to capture the elements in each hand for the evaluate class - requires an array
		$evaluateArray = array($allhands[$var1][$var3],$allhands[$var1][$var4],$allhands[$var1][$var2][$var3],$allhands[$var1][$var2][($var3+1)],$allhands[$var1][$var2][($var3+2)],$allhands[$var1][$var2][($var3+3)],$allhands[$var1][$var2][($var3+4)]); 
		print"<p>\n</p>";
		print"<p>Lets test this hand</p>";	
		print"<p>\n</p>";
		//this code counts the characters in the string -- page 223
		$chart = count_chars($evaluateString,1);
		$chartArray = array($chart);
		print"<p>\n</p>";
		//DBUG CODE print_r($chartArray);
		print"<p>\n</p>";
		//creates a new object of switchIt class for hand testing
		$switchIt = new pokerEngine();
		//calls the handtest method from switchIt object and takes $chartArray & $evaluateArray
		$switchIt->handTest($chartArray,$evaluateArray);
		echo $switchIt->getText();
		print"<p>\n</p>";
		$pts = $switchIt->getTotalPoints();
		print"<p>Points: $pts</p>";
		
		}	//end for loop 
				
?>
Return current item: PHP Poker Engine