SHARE
TWEET

Untitled

a guest Sep 13th, 2017 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. echo "<b><center><a href=\"index.php\">Nochmal</a></center></b><br /><br />";
  3. class Player {
  4.     public $HP;
  5.     public $Name;
  6.     public $SpecialskillName;
  7.     public $SpecialskillDamage;
  8.     public $MaxHP;
  9.    
  10.     public function __construct($Name,$HP,$MaxHP,$SpecialskillName,$SpecialskillDamage) {
  11.         $this->Name = $Name;
  12.         $this->HP = $HP;
  13.         $this->MaxHP = $MaxHP;
  14.         $this->SpecialskillName = $SpecialskillName;
  15.         $this->SpecialskillDamage = $SpecialskillDamage;
  16.     }
  17.    
  18.     public function Attack() {
  19.         if($this->HP>0) {
  20.             $spskchance = rand(0,100);
  21.             if($spskchance < 30) {
  22.                 echo $this->Name." benutzt den Skill \"".$this->SpecialskillName."\".<br />";
  23.                 return $this->SpecialskillDamage+rand(-30,30);
  24.             }
  25.             $dmg = rand(20,60);
  26.             echo $this->Name." piekst mit $dmg Schaden<br />";
  27.             if(rand(0,100)<30) return 0;
  28.             return $dmg;
  29.         }
  30.     }
  31.    
  32.     public function Damage($damage) {
  33.         $this->HP = $this->HP-$damage;
  34.         if($this->HP<0) {
  35.             echo $this->Name." hat den Kampf verloren.<br />";
  36.             return false;
  37.         }
  38.         if($damage == 0)
  39.             echo $this->Name." ist ausgewichen.<br />";
  40.         else
  41.             echo $this->Name." hat ".$damage." Schaden erhalten.<br />";
  42.     }
  43. }
  44.  
  45. $Player1 = new Player("Alexandra",1243,1243,"Heulender Pieks",250);
  46. $Player2 = new Player("Torben",1034,1034,"Liebespieks",350);
  47.  
  48. $Round = 1;
  49. while($Player1->HP>0 && $Player2->HP>0) {
  50.     echo "<hr noshdade />";
  51.     echo "<b>Runde $Round</b><br />";
  52.     $Player2->Damage($Player1->Attack());
  53.     $Player1->Damage($Player2->Attack());
  54.     echo $Player1->Name.": ".$Player1->HP."/".$Player1->MaxHP."<br />";
  55.     echo $Player2->Name.": ".$Player2->HP."/".$Player2->MaxHP;
  56.     $Round++;
  57. }
  58.  
  59. echo "<b><center><a href=\"index.php\">Nochmal</a></center></b>";
  60.  
  61. ?>
RAW Paste Data
Top