Guest User

Untitled

a guest
Nov 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. <?php
  2. //include()
  3.  
  4. if (isset($_POST[&#039;Submit&#039;])) {
  5. //Post Variables
  6. //Your Stuff
  7. $yatkaction = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;yatkaction&#039;]));
  8. $yatkunits = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;yatkunits&#039;]));
  9. $yunitpower = $yatkaction / $yatkunits;
  10.  
  11. //Targets Stuff
  12. $tdefaction = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;tdefaction&#039;]));
  13. $tdefunits = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;tdefunits&#039;]));
  14. $tunitpower = $tdefaction / $tdefunits;
  15. //Adjustment
  16. $adjust = $tdefaction / $yatkaction;
  17. $adjustment = sqrt($adjust);
  18.  
  19. //Assault
  20. $assaultatk = .05;
  21. $assaultdef = .04;
  22.  
  23. //Formulas
  24. //Attacker
  25. //Temp stats
  26. $tempatkaction = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;yatkaction&#039;]));
  27. $tempatkunits = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;yatkunits&#039;]));
  28. $tempatkunitpower = $tempatkaction / $tempatkunits;
  29.  
  30. $atklosses = ($tempatkunits * $assaultatk) * $adjustment;
  31. $tempatkunitsleft = $tempatkunits - $atklosses; //# of left over units
  32. $tempatkactionleft = $tempatkunitsleft * $tempatkunitpower; //Left over Attack action
  33.  
  34. //Defender
  35. //Temp stats
  36. $tempdefaction = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;ydefaction&#039;]));
  37. $tempdefunits = trim(str_replace(&#039;,&#039;,&#039;&#039;,$_POST[&#039;ydefunits&#039;]));
  38. $tempdefunitpower = $tempdefaction / $tempdefunits;
  39.  
  40. $deflosses = ($tempdefunits * $assaultdef) * $adjustment;
  41. $tempdefunitsleft = $tempdefunits - $deflosses; //# of left over units
  42. $tempdefactionleft = $tempdefunitsleft * $tempdefunitpower; //Left over Attack action
  43. ?>
  44. <html>
  45. <head>
  46. <title>Assault Calculator</title>
  47. </head>
  48. <body>
  49. <table border="1">
  50. <tr>
  51. <th>Number</th>
  52. <th>Defense Action</th>
  53. <th>Defense Units</th>
  54. <th>Defense Losses</th>
  55. <th>Defense Power</td>
  56. <th>Attack Action</th>
  57. <th>Attack Units</th>
  58. <th>Attack Losses</th>
  59. <th>Attack Power</th>
  60. </tr>
  61. <?
  62. for ($i=0; $i < 20; $i++){
  63. $num = $i+1;
  64. echo &#039; <tr align="center">&#039;;
  65. echo &#039; <td>&#039;.$num.&#039;</td>&#039;."\n";
  66. echo &#039; <td>&#039;.$tempdefaction.&#039;</td>&#039;."\n";
  67. echo &#039; <td>&#039;.$tempdefunits.&#039;</td>&#039;."\n";
  68. echo &#039; <td>&#039;.$deflosses.&#039;</td>&#039;."\n";
  69. echo &#039; <td>&#039;.$tempdefunitpower.&#039;</td>&#039;."\n";
  70. echo &#039; <td>&#039;.$tempatkaction.&#039;</td>&#039;."\n";
  71. echo &#039; <td>&#039;.$tempatkunits.&#039;</td>&#039;."\n";
  72. echo &#039; <td>&#039;.$atklosses.&#039;</td>&#039;."\n";
  73. echo &#039; <td>&#039;.$tempatkunitpower.&#039;</td>&#039;."\n";
  74. echo &#039; </tr>&#039;."\n";
  75.  
  76.  
  77. //your stuff agian
  78. $tempatkaction = $tempatkunitpower; //sets atk action to new value
  79. $tempatkunits = $tempatkunitsleft; // sets new number of units
  80. $tempatkunitpower = $tempatkaction / $tempatkunits;
  81.  
  82. $atklosses = ($tempatkunits * $assaultatk) * $adjustment;
  83. $tempatkunitsleft = $tempatkunits - $atklosses; //# of left over units
  84. $tempatkactionleft = $tempatkunitsleft * $tempatkunitpower; //Left over Attack action
  85.  
  86. //target stuff again
  87. $tempdefaction = $tempdefactionleft; //sets def action to new value
  88. $tempdefunits = $tempdefunitsleft; // sets new number of units
  89. $tempdefunitpower = $tempdefaction / $tempdefunits;
  90.  
  91. $deflosses = ($tempdefunits * $assaultdef) * $adjustment;
  92. $tempdefunitsleft = $tempdefunits - $deflosses; //# of left over units
  93. $tempdefactionleft = $tempdefunitsleft * $tempdefunitpower; //Left over Attack action
  94. ?>
  95. </table>
  96. <table border="1">
  97. <?
  98. }?>
  99. </table>
  100. </body>
  101. </html>
  102. <?}else{?>
  103. <html>
  104. <head>
  105. <title>Assault Calculator</title>
  106. </head>
  107. <body>
  108. <form method="post" action="<?php echo $PHP_SELF;?>">
  109. <table>
  110. <tr>
  111. <td>Your Action:</td>
  112. <td><input type="text" name="yatkaction" /></td>
  113. </tr>
  114. <tr>
  115. <td>Your Units:</td>
  116. <td><input type="text" name="yatkunits" /></td>
  117. </tr>
  118. <tr>
  119. <td>Target Action:</td>
  120. <td><input type="text" name="tdefaction" /></td>
  121. </tr>
  122. <tr>
  123. <td>Target Units:</td>
  124. <td><input type="text" name="tdefunits" /></td>
  125. </tr>
  126. </table>
  127. <input type="Submit" value="Submit" />
  128. </form>
  129. </body>
  130. </html>
  131. <?}?>
Add Comment
Please, Sign In to add comment