Advertisement
ElooEminem

Untitled

Jul 27th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>The REAL Warcraft3</title>
  4. <style>
  5. table {
  6. width:100%;
  7. }
  8. table, th, td {
  9. border: 1px solid black;
  10. border-collapse: collapse;
  11. }
  12. th, td {
  13. padding: 15px;
  14. text-align: center;
  15. }
  16. table#t01 tr:nth-child(even) {
  17. background-color: #eee;
  18. }
  19. table#t01 tr:nth-child(odd) {
  20. background-color: #fff;
  21. }
  22. table#t01 th {
  23. background-color: black;
  24. color: white;
  25. }
  26. </style>
  27. </head>
  28. <body background="http://2.bp.blogspot.com/-Bc2I9zJFyhA/VAmyrCl0eQI/AAAAAAAARyc/bhwBThcQwNU/s1600/tumblr_mmaeaivjW41s6z39yo9_r1_1280.jpg">
  29.  
  30. <center><br>
  31. <form action="index.php" method="get">
  32.  
  33. <br><label><img src="https://d1u5p3l4wpay3k.cloudfront.net/wowpedia/6/66/BTNFootman.png?version=fa73678fd8c5504751fe7e40ce081191" width="5%" height="10%">
  34. <br><input type="radio" name="option" value="footman" checked="">New footman</label><br><br>
  35.  
  36. <br><label><img src="https://vignette.wikia.nocookie.net/wowwiki/images/9/95/BTNGhoul.png/revision/latest?cb=20090112004332" width="5%" height="10%">
  37. <br><input type="radio" name="option" value="ghoul">New ghoul</label><br><br>
  38.  
  39. <br><label><input type="radio" name="option" value="spell">Cast a spell</label><br><br>
  40.  
  41.  
  42. <br>Id of spell target <input type="text" name="cast_id"><br><br>
  43.  
  44. <br><label><img src="https://lh3.googleusercontent.com/-D_XgsF3CcNE/UdWCi5gNPvI/AAAAAAAAAEU/5vYoWFnmt6E/w530-h530-n/deathcoil_copy.gif" width="5%" height="10%">
  45. <input type="radio" name="cast_spell" value="death_coil" checked="">Death coil</label><br><br>
  46.  
  47. <br><label><img src="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/c4/c4c7969eb7c3c44d067d46c3f54d6403d47d6735_full.jpg" width="5%" height="10%">
  48. <input type="radio" name="cast_spell" value="holy_light">Cast a spell</label><br><br>
  49.  
  50. <input type="submit" value="Execute"><br>
  51. </form>
  52.  
  53. <?php
  54.  
  55. class unit{
  56. public $id;
  57. public $name;
  58. public $hp;
  59. public $armour;
  60. public $race;
  61. public $maxhp;
  62. public function set_hp($new_hp){
  63. echo "<br>$this->name, $this->id: hp change from $this->hp to ";
  64. $this->hp=$new_hp;
  65. if($this->hp>$this->maxhp){
  66. $this->hp=$this->maxhp;
  67. echo "$this->hp.";
  68. }
  69. if($this->hp<=0){
  70. $this->hp=0;
  71. echo "$this->hp.";
  72. echo "<br>The unit died.";
  73. }
  74. }
  75. public function death_coil(){
  76. echo "<br>$this->name, $this->id got hit by a death coil.";
  77. if($this->race=="ud") $this->set_hp($this->hp+200);
  78. else if($this->race=="hum") $this->set_hp($this->hp-100);
  79. }
  80. public function holy_light(){
  81. echo "<br>$this->name, $this->id got holy lighted.";
  82. if($this->race=="hum") $this->set_hp($this->hp+200);
  83. else if($this->race=="ud") $this->set_hp($this->hp-100);
  84. }
  85. }
  86.  
  87. class ghoul extends unit{
  88. public function __construct($id){
  89. $this->id=$id;
  90. $this->name="Ghoul";
  91. $this->maxhp=340;
  92. $this->hp=$this->maxhp;
  93. $this->armour=0;
  94. $this->race="ud";
  95. echo "<br>New $this->name, $this->id created.";
  96. }
  97. }
  98.  
  99. class footman extends unit{
  100. public function __construct($id){
  101. $this->id=$id;
  102. $this->name="Footman";
  103. $this->maxhp=420;
  104. $this->hp=$this->maxhp;
  105. $this->armour=2;
  106. $this->race="hum";
  107. echo "<br>New $this->name, $this->id created.";
  108. }
  109. }
  110.  
  111. function coil($obj){
  112. $obj->death_coil();
  113. if($obj->hp==0) $obj=null;
  114. return $obj;
  115. }
  116.  
  117. function light($obj){
  118. $obj->holy_light();
  119. if($obj->hp==0) $obj=null;
  120. return $obj;
  121. }
  122.  
  123. session_start();
  124.  
  125. if(isset($_GET['option'])){
  126. $id=$_SESSION['id'];
  127. if(isset($_SESSION['tab'])) $tab=$_SESSION['tab'];
  128. if($_GET['option']=='footman'){
  129. $tab[$id]=new footman($id);
  130. }
  131. else if($_GET['option']=='ghoul'){
  132. $tab[$id]=new ghoul($id);
  133. }
  134. else{
  135. if($_GET['cast_spell']=='death_coil'){
  136. $tab[$_GET['cast_id']]=coil($tab[$_GET['cast_id']]);
  137. }
  138. else{
  139. $tab[$_GET['cast_id']]=light($tab[$_GET['cast_id']]);
  140. }
  141. }
  142. $id++;
  143. }
  144. else{
  145. $id=0;
  146.  
  147. }
  148. echo '
  149. <table style="height: 160px;" width="403"><caption>Existing units</caption>
  150. <tr>
  151. <td>Id</td>
  152. <td>Name</td>
  153. <td>Hp</td>
  154. </tr>
  155. ';
  156.  
  157. foreach($tab as $unit){
  158. echo '<tr><td>'. $unit->id . '</td><td>' . $unit->name . '</td><td>' . $unit->hp . '</td></tr>';
  159.  
  160. }
  161.  
  162. echo '</table>';
  163. $_SESSION['tab']=$tab;
  164. $_SESSION['id']=$id;
  165.  
  166.  
  167. ?>
  168. </center>
  169. </body>
  170.  
  171. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement