2 Replies - 1410 Views - Last Post: 05 December 2013 - 08:38 AM Rate Topic: -----

#1 Xaos  Icon User is offline

  • D.I.C Regular

Reputation: 63
  • View blog
  • Posts: 354
  • Joined: 20-November 13

When I was young and naive

Posted 05 December 2013 - 08:30 AM

 <?php

include 'players.php';

echo "Player One Health=$p1health<br>";
echo "Player One Striking=$p1punch<br>";
echo "Player One Defense=$p1strikedefense<br>";
echo "Player One Elusiveness=$p1elusiveness<br>";
echo "Player One Kick =$p1kick<br>";
echo "Player One Kick defense=$p1kickdefense<br><br>";

echo "Player Two Health=$p2health<br>";
echo "Player Two Striking=$p2punch<br>";
echo "Player Two Defense=$p2strikedefense<br>";
echo "Player Two Elusiveness=$p2elusiveness<br>";
echo "Player Two Kick =$p2kick<br>";
echo "Player Two Kick defense=$p2kickdefense<br><br>";

function punchroll($punch,$elusiveness,$strikedefense)
{
  $punchroll = rand(1,$punch);
$strikedefenseroll = rand(1,$strikedefense);
$elusivenessroll = rand(1,$elusiveness);
$punchroll-$strikedefenseroll+$elusivenessroll/2;
return array($punchroll);
}
function kickroll($kick,$elusiveness,$kickdefense)
{
    $kickroll = rand(1,$kick);
$kickdefenseroll = rand(1,$kickdefense);
$elusivenessroll = rand(1,$elusiveness);
$kickroll-$kickdefenseroll+$elusivenessroll/2;
    return array($kickroll);
}
function groundpunchroll($groundstriking,$groundstrikedefense,$elusiveness)
{
  $groundpunchroll = rand(1,$groundpunch);
  $groundstrikedefenseroll = rand(1,$groundstrikedefense);
  $elusivenessroll = rand(1,$elusiveness);
  $groundpunchroll-$groundstrikedefenseroll+$elusiveness/2;
  return array ($groundpunchroll);
}

$p1headpunchchance = rand(1-$p1headpunchtendency,$p1headpunchtendency);
$p1bodypunchchance = (100-$p1headpunchtendency);
$p1headkickchance = rand(1-$p1headkicktendency, $p1headkicktendency);
$p1bodykickchance = (100-$p1headkicktendency);
$p1legkickchance = rand(1-$p1legkicktendency,$p1legkicktendency);
$p1takedownroll = rand(1,$p1takedown);
$p1clinchchance = rand(1-$p1clinchtendency,$p1clinchtendency);
$p1clinchroll = rand(1,$p1clinch);
$p2elusivenessroll = rand(1,$p2elusiveness);
$p1standchance= rand(1-$p1standtendency,$p1standtendency);
$p1groundchance = (100-$p1standtendency);
$p1kickchance = rand(1-$p1kicktendency,$p1kicktendency);
$p1punchchance = (100-$p1kicktendency);
$p2kickdefenseroll=rand(1,$p2kickdefense);
$p2strikdefenseroll=rand(1,$p2strikedefense);
$p1groundstrikechance = rand(1-$p1groundstriketendency,$p1groundstriketendency);
$p1groundtransitionchance = (100-$p1groundstriketendency);
$p1clinchstrikechance = rand(1-$p1clinchstriketendency,$p1clinchstriketendency);
$p1clinchtransitionchance = (100-$p1clinchstriketendency);

if ($p1standchance >=$p1groundchance) {
  echo "Player one stands<br>";

if ($p1kickchance >= $p1punchchance) {

list($kickroll) = kickroll($p1kick,$p2kickdefense,$p2elusiveness);
       $kickdamage=$kickroll-$p2kickdefenseroll;
          if ($kickroll >=$p2elusivenessroll){
             if ($p1headkickchance >= $p1bodykickchance){
                echo "Kick to the head<br>";
             }
             elseif ($p1bodykickchance >= $p1legkickchance){
                echo "Kick to the body<br>";
              }else {
                echo "Kick to the leg<br>";
              }

              if (0 >= $kickdamage){
  echo "Kick bounces off the defense!<br>";
  $kickdamage = 0;
}
    echo "Damage from the kick is $kickdamage<br>";
    echo "Player 2 health is now " . $p2health=$p2health-$kickdamage;
}

 else{
    echo "Kick misses<br>";
 }
 }


  else if ($p1kickchance <=$p1punchchance){
      list($punchroll) = punchroll($p1punch,$p1strikedefense,$p1elusiveness);

$punchdamage=$punchroll-$p2strikdefenseroll;

if ($punchroll >=$p2elusivenessroll){

if ($p1headpunchchance >= $p1bodypunchchance){
echo "Punch to the head<br>";
}else{
  echo "Punch to the body<br>";
}
if (0 >= $punchdamage){
  echo "Punch bounces off the defense!<br>";
  $punchdamage = 0;
}
echo "Damage from the punch is $punchdamage<br>";
echo "Player 2 health is now " . $p2health=$p2health-$punchdamage . "<br>";
}else{
echo "Punch Misses<br>";
}
}
}else{
  if ($p1groundchance >= $p1clinchchance){
    echo "Player attempts a takedown<br>";
  if ($p1takedownroll >= $p2takedowndefense){
    echo "Takedown sucessful!<br>";

    if ($p1groundstrikechance >= $p1groundtransitionchance){
   echo "Player goes for strike!";
  }else{
    echo "Player tries to transition!";
  }
   }else{
   echo "Takedown Failed!<br>";
   }


  }else{
    echo "Player attempts a clinch<br>";
    if ($p1clinchroll >= $p2clinchdefense){
    echo "Clinch succesful!<br>";
   $position = 'double underhooks';
   if ($position == 'double underhooks'){
     echo "Players now in double underhooks<br>";
        if ($p1clinchstrikechance >= $p1clinchtransitionchance){

   if ($p1kickchance >= $p1punchchance) {

list($kickroll) = kickroll($p1kick,$p2kickdefense,$p2elusiveness);
       $kickdamage=($kickroll-$p2kickdefenseroll)/2;
          if ($kickroll >=$p2elusivenessroll){
                echo "Kick to the leg<br>";
                if (0 >= $kickdamage){
  echo "Kick bounces off the defense!<br>";
  $kickdamage = 0;
}else
    echo "Damage from the kick is $kickdamage<br>";
    echo "Player 2 health is now " . $p2health=$p2health-$kickdamage;
}
  else echo"Kick misses<br>;";
          }
 }elseif ($p1clinchtransitionchance >= $p1clinchstrikechance);

     ; $position = array ("overunderhook","backclinch","doubleunderhooks");
        function random($array, $counter){
    shuffle($array);
    for($i=0;$i<$counter;$i++){
        $newarray[$i]=$array[$i];
    }
    return $newarray;
    list ($position) = random("overunderhook","backclinch");


}
$newarray;
list ($position) = random("overunderhook","backclinch");
echo $position;
}elseif($p1kickchance <=$p1punchchance){
      list($punchroll) = punchroll($p1punch,$p1strikedefense,$p1elusiveness);

$punchdamage=$punchroll-$p2strikdefenseroll;

if ($punchroll >=$p2elusivenessroll){

if ($p1headpunchchance >= $p1bodypunchchance){
echo "Punch to the head<br>";
}else{
  echo "Punch to the body<br>";
}

if (0 >= $punchdamage){
  echo "Punch bounces off the defense!<br>";
  $punchdamage = 0;
}
echo "Damage from the punch is $punchdamage<br>";
echo "Player 2 health is now " . $p2health=$p2health-$punchdamage . "<br>";
}else{
echo "Punch Misses<br>";
}
}
  }else{
      echo "Clinch failed!<br>";
    }
}
  }






?>


It works and whatnot, but dear god. I wasn't exactly sure on functions......and this was only a year ago. My god. Btw, it isn't finished. Because I figured out exactly how to use functions .

Is This A Good Question/Topic? 1
  • +

Replies To: When I was young and naive

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5365
  • View blog
  • Posts: 27,329
  • Joined: 10-May 07

Re: When I was young and naive

Posted 05 December 2013 - 08:32 AM

Holy 'echo' intro batman...
Was This Post Helpful? 0
  • +
  • -

#3 Xaos  Icon User is offline

  • D.I.C Regular

Reputation: 63
  • View blog
  • Posts: 354
  • Joined: 20-November 13

Re: When I was young and naive

Posted 05 December 2013 - 08:38 AM

View Postno2pencil, on 05 December 2013 - 08:32 AM, said:

Holy 'echo' intro batman...


Yeah.....I think that was mostly just for my purposes in testing, but yeah.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1