public function enhanceDefence($damage) { if (rand(1, 100) <= $this->probability) { $damage *= $this->factor; Message::display('Magic Shield skill is used!'); } return $damage; }
public function enhanceAttack($damage) { if (rand(1, 100) <= $this->probability) { $damage *= $this->factor; Message::display('Rapid Strike skill is used!'); } return $damage; }
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!'); } }
public function displayStats() { foreach ($this->players as $player) { Message::display($player->getDisplayProperties()); } }