Advertisement
ElooEminem

Untitled

Jul 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2.  
  3. class unit{
  4. public $id;
  5. public $name;
  6. public $hp;
  7. public $armour;
  8. public $race;
  9. public function set_hp($new_hp){
  10. echo "<br>$this->$name, $this->$id: hp change from $this->$hp to ";
  11. $this->$hp=$new_hp;
  12. echo "$this->hp.";
  13. if($this->$hp<=0){
  14. $this->$hp=0;
  15. echo "<br>The unit died.";
  16. }
  17. }
  18. public function death_coil(){
  19. echo "<br>$this->$name, $this->$id got hit by a death coil.";
  20. if($this->$race=="ud") set_hp($this->$hp+200);
  21. else if($this->$race=="hum") set_hp($this->$hp-100);
  22. }
  23. public function holy_light(){
  24. echo "<br>$this->$name, $this->$id got holy lighted.";
  25. if($this->$race=="hum") set_hp($this->$hp+200);
  26. else if($this->$race=="ud") set_hp($this->$hp-100);
  27. }
  28. }
  29.  
  30. class ghoul extends unit{
  31. public function __construct($id){
  32. $this->$id=$id;
  33. $this->$name="Ghoul";
  34. $this->$hp=340;
  35. $this->$armour=0;
  36. $this->$race="ud";
  37. echo "<br>New $this->$name, $this->$id created.";
  38. }
  39. }
  40.  
  41. class footman extends unit{
  42. public function __construct($id){
  43. $this->$id=$id;
  44. $this->$name="Footman";
  45. $this->$hp=420;
  46. $this->$armour=2;
  47. $this->$race="hum";
  48. echo "<br>New $this->$name, $this->$id created.";
  49. }
  50. }
  51.  
  52. $id=0;
  53.  
  54. function add_footman(){
  55. global $id;
  56. $tab[$id]=new footman($id);
  57. $id++;
  58. }
  59.  
  60. function add_ghoul(){
  61. global $id;
  62. $tab[$id]=new ghoul($id);
  63. $id++;
  64. }
  65.  
  66. function coil($id){
  67. $tab[$id]->death_coil();
  68. if($tab[$id]->hp==0) unset($tab[$id]);
  69. }
  70.  
  71. function light($id){
  72. $tab[$id]->holy_light();
  73. if($tab[$id]->hp==0) unset($tab[$id]);
  74. }
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement