Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<b><center><a href=\"index.php\">Nochmal</a></center></b><br /><br />";
- class Player {
- public $HP;
- public $Name;
- public $SpecialskillName;
- public $SpecialskillDamage;
- public $MaxHP;
- public function __construct($Name,$HP,$MaxHP,$SpecialskillName,$SpecialskillDamage) {
- $this->Name = $Name;
- $this->HP = $HP;
- $this->MaxHP = $MaxHP;
- $this->SpecialskillName = $SpecialskillName;
- $this->SpecialskillDamage = $SpecialskillDamage;
- }
- public function Attack() {
- if($this->HP>0) {
- $spskchance = rand(0,100);
- if($spskchance < 30) {
- echo $this->Name." benutzt den Skill \"".$this->SpecialskillName."\".<br />";
- return $this->SpecialskillDamage+rand(-30,30);
- }
- $dmg = rand(20,60);
- echo $this->Name." piekst mit $dmg Schaden<br />";
- if(rand(0,100)<30) return 0;
- return $dmg;
- }
- }
- public function Damage($damage) {
- $this->HP = $this->HP-$damage;
- if($this->HP<0) {
- echo $this->Name." hat den Kampf verloren.<br />";
- return false;
- }
- if($damage == 0)
- echo $this->Name." ist ausgewichen.<br />";
- else
- echo $this->Name." hat ".$damage." Schaden erhalten.<br />";
- }
- }
- $Player1 = new Player("Alexandra",1243,1243,"Heulender Pieks",250);
- $Player2 = new Player("Torben",1034,1034,"Liebespieks",350);
- $Round = 1;
- while($Player1->HP>0 && $Player2->HP>0) {
- echo "<hr noshdade />";
- echo "<b>Runde $Round</b><br />";
- $Player2->Damage($Player1->Attack());
- $Player1->Damage($Player2->Attack());
- echo $Player1->Name.": ".$Player1->HP."/".$Player1->MaxHP."<br />";
- echo $Player2->Name.": ".$Player2->HP."/".$Player2->MaxHP;
- $Round++;
- }
- echo "<b><center><a href=\"index.php\">Nochmal</a></center></b>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement