" : "\n"; $np = ($forWeb == 'true') ? "

" : "\n\n"; // 'Players' choose from this pool $choices = array (0=>"Cock", 1=>"Muff", 2=>"Bumhole"); // Two arrays contain the rules. // First is the concatenation of the selection indices made by the // players, in the order they were made (p1 is 1st digit; p2 is 2nd). // 2nd array is the textual outcome of the match and which player wins $rules = array("01","02","12","10","20","21"); $outcome = array(array("Muff swallows cock",2), array("Cock fucks bumhole",1), array("Bumhole guffs muff",2), array("Muff swallows cock",1), array("Cock fucks bumhole",2), array("Bumhole guffs muff",1)); // Let the game commence... for ($game = 1; $game <= $numRounds; $game++) { $p1Result = 0; $p2Result = 0; $p1Choice = array_rand($choices,1); $p2Choice = array_rand($choices,1); if ($printGame == 'true') { $gameOut .= "Game ".$game.$np; } // Handle a tied game if ($p1Choice == $p2Choice) { $resultStr = "Both players chose ".$choices[$p1Choice].": Round is a draw$np"; if ($allowDraws == 'true') { if ($printGame == 'true') { $gameOut .= $resultStr; } } else { // Draws aren't allowed so have another go if ($printGame == 'true') { $gameOut .= $resultStr; $gameOut .= "Rematch...".$np; } $game--; } } else { $gameConcat = $p1Choice.$p2Choice; $matchingRule = intval(array_search($gameConcat,$rules)); $winPos = $outcome[$matchingRule]; $resultStr = $winPos[0].$nl."Player ".$winPos[1]." wins"; $resultVar = "p".$winPos[1]."Result"; ${$resultVar}++; if ($printGame == 'true') { $gameOut .= sprintf("Player 1 chose: %s, Player 2 chose: %s%s",$choices[$p1Choice],$choices[$p2Choice],$nl); $gameOut .= sprintf("%s%s",$resultStr,$np); } } $numP1Wins += $p1Result; $numP2Wins += $p2Result; } // Results time if (($numP1Wins == $numP2Wins) && $numRounds > 0) { $resultStr = "Game is a draw with ".$numP1Wins." wins each"; $resultVal = 0; } else if ($numP1Wins > $numP2Wins) { $resultStr = "Player 1 wins overall (".$numP1Wins." : ".$numP2Wins.")"; $resultVal = 1; } else if ($numP2Wins > $numP1Wins) { $resultStr = "Player 2 wins overall (".$numP2Wins." : ".$numP1Wins.")"; $resultVal = 2; } else { $resultStr = "Code on fire. Panic."; $resultVal = -1; } if ($printGame == 'true') { $gameOut .= sprintf("%s%s%s",$np,$resultStr,$nl); return array($resultVal, $gameOut); } else { return $resultVal; } } ?>