Exemplo n.º 1
0
 public function enhanceDefence($damage)
 {
     if (rand(1, 100) <= $this->probability) {
         $damage *= $this->factor;
         Message::display('Magic Shield skill is used!');
     }
     return $damage;
 }
Exemplo n.º 2
0
 public function enhanceAttack($damage)
 {
     if (rand(1, 100) <= $this->probability) {
         $damage *= $this->factor;
         Message::display('Rapid Strike skill is used!');
     }
     return $damage;
 }
Exemplo n.º 3
0
 public function defend($attackDamage)
 {
     if ($this->properties['luck'] >= rand(1, 100)) {
         Message::display($this->properties['name'] . ' used evasion! No damage done! ');
         return;
     }
     $attackDamage -= $this->properties['defence'];
     if (isset($this->skills['defence'])) {
         foreach ($this->skills['defence'] as $defence) {
             $attackDamage = $defence->enhanceDefence($attackDamage);
         }
     }
     Message::display($this->properties['name'] . ' takes ' . $attackDamage . ' damage.');
     $this->properties['health'] -= $attackDamage;
     if ($this->properties['health'] <= 0) {
         $this->isAlive = false;
         Message::display($this->properties['name'] . ' died!');
     }
 }
Exemplo n.º 4
0
 public function displayStats()
 {
     foreach ($this->players as $player) {
         Message::display($player->getDisplayProperties());
     }
 }