Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>The REAL Warcraft3</title>
- <style>
- table {
- width:100%;
- }
- table, th, td {
- border: 1px solid black;
- border-collapse: collapse;
- }
- th, td {
- padding: 15px;
- text-align: center;
- }
- table#t01 tr:nth-child(even) {
- background-color: #eee;
- }
- table#t01 tr:nth-child(odd) {
- background-color: #fff;
- }
- table#t01 th {
- background-color: black;
- color: white;
- }
- </style>
- </head>
- <body background="http://2.bp.blogspot.com/-Bc2I9zJFyhA/VAmyrCl0eQI/AAAAAAAARyc/bhwBThcQwNU/s1600/tumblr_mmaeaivjW41s6z39yo9_r1_1280.jpg">
- <center><br>
- <form action="index.php" method="get">
- <br><label><img src="https://d1u5p3l4wpay3k.cloudfront.net/wowpedia/6/66/BTNFootman.png?version=fa73678fd8c5504751fe7e40ce081191" width="5%" height="10%">
- <br><input type="radio" name="option" value="footman" checked="">New footman</label><br><br>
- <br><label><img src="https://vignette.wikia.nocookie.net/wowwiki/images/9/95/BTNGhoul.png/revision/latest?cb=20090112004332" width="5%" height="10%">
- <br><input type="radio" name="option" value="ghoul">New ghoul</label><br><br>
- <br><label><input type="radio" name="option" value="spell">Cast a spell</label><br><br>
- <br>Id of spell target <input type="text" name="cast_id"><br><br>
- <br><label><img src="https://lh3.googleusercontent.com/-D_XgsF3CcNE/UdWCi5gNPvI/AAAAAAAAAEU/5vYoWFnmt6E/w530-h530-n/deathcoil_copy.gif" width="5%" height="10%">
- <input type="radio" name="cast_spell" value="death_coil" checked="">Death coil</label><br><br>
- <br><label><img src="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/c4/c4c7969eb7c3c44d067d46c3f54d6403d47d6735_full.jpg" width="5%" height="10%">
- <input type="radio" name="cast_spell" value="holy_light">Cast a spell</label><br><br>
- <input type="submit" value="Execute"><br>
- </form>
- <?php
- class unit{
- public $id;
- public $name;
- public $hp;
- public $armour;
- public $race;
- public $maxhp;
- public function set_hp($new_hp){
- echo "<br>$this->name, $this->id: hp change from $this->hp to ";
- $this->hp=$new_hp;
- if($this->hp>$this->maxhp){
- $this->hp=$this->maxhp;
- echo "$this->hp.";
- }
- if($this->hp<=0){
- $this->hp=0;
- echo "$this->hp.";
- echo "<br>The unit died.";
- }
- }
- public function death_coil(){
- echo "<br>$this->name, $this->id got hit by a death coil.";
- if($this->race=="ud") $this->set_hp($this->hp+200);
- else if($this->race=="hum") $this->set_hp($this->hp-100);
- }
- public function holy_light(){
- echo "<br>$this->name, $this->id got holy lighted.";
- if($this->race=="hum") $this->set_hp($this->hp+200);
- else if($this->race=="ud") $this->set_hp($this->hp-100);
- }
- }
- class ghoul extends unit{
- public function __construct($id){
- $this->id=$id;
- $this->name="Ghoul";
- $this->maxhp=340;
- $this->hp=$this->maxhp;
- $this->armour=0;
- $this->race="ud";
- echo "<br>New $this->name, $this->id created.";
- }
- }
- class footman extends unit{
- public function __construct($id){
- $this->id=$id;
- $this->name="Footman";
- $this->maxhp=420;
- $this->hp=$this->maxhp;
- $this->armour=2;
- $this->race="hum";
- echo "<br>New $this->name, $this->id created.";
- }
- }
- function coil($obj){
- $obj->death_coil();
- if($obj->hp==0) $obj=null;
- return $obj;
- }
- function light($obj){
- $obj->holy_light();
- if($obj->hp==0) $obj=null;
- return $obj;
- }
- session_start();
- if(isset($_GET['option'])){
- $id=$_SESSION['id'];
- if(isset($_SESSION['tab'])) $tab=$_SESSION['tab'];
- if($_GET['option']=='footman'){
- $tab[$id]=new footman($id);
- }
- else if($_GET['option']=='ghoul'){
- $tab[$id]=new ghoul($id);
- }
- else{
- if($_GET['cast_spell']=='death_coil'){
- $tab[$_GET['cast_id']]=coil($tab[$_GET['cast_id']]);
- }
- else{
- $tab[$_GET['cast_id']]=light($tab[$_GET['cast_id']]);
- }
- }
- $id++;
- }
- else{
- $id=0;
- }
- echo '
- <table style="height: 160px;" width="403"><caption>Existing units</caption>
- <tr>
- <td>Id</td>
- <td>Name</td>
- <td>Hp</td>
- </tr>
- ';
- foreach($tab as $unit){
- echo '<tr><td>'. $unit->id . '</td><td>' . $unit->name . '</td><td>' . $unit->hp . '</td></tr>';
- }
- echo '</table>';
- $_SESSION['tab']=$tab;
- $_SESSION['id']=$id;
- ?>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement