Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //include()
- if (isset($_POST['Submit'])) {
- //Post Variables
- //Your Stuff
- $yatkaction = trim(str_replace(',','',$_POST['yatkaction']));
- $yatkunits = trim(str_replace(',','',$_POST['yatkunits']));
- $yunitpower = $yatkaction / $yatkunits;
- //Targets Stuff
- $tdefaction = trim(str_replace(',','',$_POST['tdefaction']));
- $tdefunits = trim(str_replace(',','',$_POST['tdefunits']));
- $tunitpower = $tdefaction / $tdefunits;
- //Adjustment
- $adjust = $tdefaction / $yatkaction;
- $adjustment = sqrt($adjust);
- //Assault
- $assaultatk = .05;
- $assaultdef = .04;
- //Formulas
- //Attacker
- //Temp stats
- $tempatkaction = trim(str_replace(',','',$_POST['yatkaction']));
- $tempatkunits = trim(str_replace(',','',$_POST['yatkunits']));
- $tempatkunitpower = $tempatkaction / $tempatkunits;
- $atklosses = ($tempatkunits * $assaultatk) * $adjustment;
- $tempatkunitsleft = $tempatkunits - $atklosses; //# of left over units
- $tempatkactionleft = $tempatkunitsleft * $tempatkunitpower; //Left over Attack action
- //Defender
- //Temp stats
- $tempdefaction = trim(str_replace(',','',$_POST['ydefaction']));
- $tempdefunits = trim(str_replace(',','',$_POST['ydefunits']));
- $tempdefunitpower = $tempdefaction / $tempdefunits;
- $deflosses = ($tempdefunits * $assaultdef) * $adjustment;
- $tempdefunitsleft = $tempdefunits - $deflosses; //# of left over units
- $tempdefactionleft = $tempdefunitsleft * $tempdefunitpower; //Left over Attack action
- ?>
- <html>
- <head>
- <title>Assault Calculator</title>
- </head>
- <body>
- <table border="1">
- <tr>
- <th>Number</th>
- <th>Defense Action</th>
- <th>Defense Units</th>
- <th>Defense Losses</th>
- <th>Defense Power</td>
- <th>Attack Action</th>
- <th>Attack Units</th>
- <th>Attack Losses</th>
- <th>Attack Power</th>
- </tr>
- <?
- for ($i=0; $i < 20; $i++){
- $num = $i+1;
- echo ' <tr align="center">';
- echo ' <td>'.$num.'</td>'."\n";
- echo ' <td>'.$tempdefaction.'</td>'."\n";
- echo ' <td>'.$tempdefunits.'</td>'."\n";
- echo ' <td>'.$deflosses.'</td>'."\n";
- echo ' <td>'.$tempdefunitpower.'</td>'."\n";
- echo ' <td>'.$tempatkaction.'</td>'."\n";
- echo ' <td>'.$tempatkunits.'</td>'."\n";
- echo ' <td>'.$atklosses.'</td>'."\n";
- echo ' <td>'.$tempatkunitpower.'</td>'."\n";
- echo ' </tr>'."\n";
- //your stuff agian
- $tempatkaction = $tempatkunitpower; //sets atk action to new value
- $tempatkunits = $tempatkunitsleft; // sets new number of units
- $tempatkunitpower = $tempatkaction / $tempatkunits;
- $atklosses = ($tempatkunits * $assaultatk) * $adjustment;
- $tempatkunitsleft = $tempatkunits - $atklosses; //# of left over units
- $tempatkactionleft = $tempatkunitsleft * $tempatkunitpower; //Left over Attack action
- //target stuff again
- $tempdefaction = $tempdefactionleft; //sets def action to new value
- $tempdefunits = $tempdefunitsleft; // sets new number of units
- $tempdefunitpower = $tempdefaction / $tempdefunits;
- $deflosses = ($tempdefunits * $assaultdef) * $adjustment;
- $tempdefunitsleft = $tempdefunits - $deflosses; //# of left over units
- $tempdefactionleft = $tempdefunitsleft * $tempdefunitpower; //Left over Attack action
- ?>
- </table>
- <table border="1">
- <?
- }?>
- </table>
- </body>
- </html>
- <?}else{?>
- <html>
- <head>
- <title>Assault Calculator</title>
- </head>
- <body>
- <form method="post" action="<?php echo $PHP_SELF;?>">
- <table>
- <tr>
- <td>Your Action:</td>
- <td><input type="text" name="yatkaction" /></td>
- </tr>
- <tr>
- <td>Your Units:</td>
- <td><input type="text" name="yatkunits" /></td>
- </tr>
- <tr>
- <td>Target Action:</td>
- <td><input type="text" name="tdefaction" /></td>
- </tr>
- <tr>
- <td>Target Units:</td>
- <td><input type="text" name="tdefunits" /></td>
- </tr>
- </table>
- <input type="Submit" value="Submit" />
- </form>
- </body>
- </html>
- <?}?>
Add Comment
Please, Sign In to add comment