<?php
class Brawler extends Warrior {
public $name;
public function _constructor() {
$this->specialSkill = 'Increase Defence by 10';
}
public function Attack(&$character) {
$arr = array();
$rand = array();
$damageDealt = 0;
for ($i = 0; $i < 100; ++$i) {
$arr[$i] = 0;
$rand[$i] = $i;
}
$evadeRate = $character->getEvade();
for($i = 0; $i < $evadeRate; ++$i) {
$this->Swap($rand[$i], $rand[rand($i, 99)]);
$arr[$rand[$i]] = 1;
}
if ($this->isEvade = $arr[rand(0, 99)]) {
$character->evade();
} else {
$damageDealt = $this->attack - $character->defence;
$character->setHealth($damageDealt);
}
return $damageDealt;
}
public function Swap(&$a, &$b) {
$tmp = $a;
$a = $b;
$b = $tmp;
}
public function setHealth($health) {
$this->health = $health;
//Initialize special skill
if ($this->health < ($this->health * 0.20)) {
$this->setDefence($this->getDefence() + 10);
$this->isSkillActivated = 1;
}
}
}
?>
Walang komento:
Mag-post ng isang Komento