Join 300,365 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,437 people online right now. Registration is fast and FREE... Join Now!
Like always - it would be really helpful if you posted your code. You say that you have defense and health but if it is a 50/50 chance then you must not be taking into account these elements in your equation.
div class="mid_box"> <div class="mid_box_title">Your Pokemon</div> <?php // show the user their pokemon include_once('pokemon_level.php'); // end file include ?> </div>
<?php if (isset($_POST['passalong']) && ($_SESSION['level_aquired'] == 2)) {
switch (Battle_Generator()) { case 1: $_SESSION['Battle_Comment'] = 'You have lost the battle.'; echo ('<meta http-equiv="refresh" content="0;url=http:/Gyms.php">'); die; break;
case 0: $_SESSION['Battle_Comment'] = "You have won the battle,<br/> addiontally your pokemon has gained 2 levels,<br/> you have gained 300 exp you have also won £10."; echo ('<meta http-equiv="refresh" content="0;url=http:/Gyms.php">'); die; break; }
// Gets number of all set '1s' and '0s' $probability = $probability['attack'] + $probability['defense'] + $probability['health'] + $probability['magic'];
if($probability >= count($items)) { echo "You have a stronger chance of winning"; }
else { echo "You will probably loose"; }
Like I said it is simple, because you would then take that final number into another equation I think, but I'm not a mathematician. Hope that helps.
--
Greg
This post has been edited by gregwhitworth: 30 Jun, 2009 - 10:01 AM
Well exactly, I basically did away with the $y = 0,
but basically it takes each number and compares them and gives it a 1 or 0 if it is or isn't larger. Then it counts the array of items and if it is greater or equal to them all then they win.
It would make it hard to win because they would have to beat them in every category, you may want to say:
CODE
$grace = 1; $count = count($items) - $grace; if($probability >= $count) { echo "You have a stronger chance of winning"; }
// Gets number of all set '1s' and '0s' $prob = rand($probability);
if ($prob == 1) { echo "You win";}
else { echo "You loose";}
Earlier I was making it too difficult, basically for each one you will get a 1 or a 0 based on your initial values. Then you have php do a random search of the array, so your basic probabilities remain, and it will be much more realistic because you could still loose even if you beat the villian in 3 of the 4 areas, your probability is 1/4 but there still is a chance.