Huwebes, Setyembre 27, 2012


<?php

class Brawler extends Warrior {
public $name;

public function Attack(&$character) {
$arr = array();
$rand = array();

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 ($arr[rand(0, 99)] == 0) {
$character->setHealth($character->getHealth() - ($this->attack - $character->defence));
} else {
echo '<br />' . $character->getEvade() . ' Evaded <br />';
$character->evade();
}
}

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);
}
}
}
?>

Walang komento:

Mag-post ng isang Komento