Exemplo n.º 1
0
 public function testIsAlive()
 {
     $this->MW_Mano = new MW_Mano('Gil');
     $this->MW_Mano->resetHealth();
     //Verificar vivo ao nascer
     $this->assertTrue($this->MW_Mano->isAlive());
     //Verificar vivo apos se machucar
     $this->MW_Mano->hurt(50);
     $this->assertTrue($this->MW_Mano->isAlive());
     //Verificar vivo ap—s apanhar ate a morte
     $this->MW_Mano->hurt(50);
     $this->assertFalse($this->MW_Mano->isAlive());
 }
Exemplo n.º 2
0
 public function attack(MW_Mano $victim)
 {
     $atk = $this->getAtk() + $this->getRandom();
     $def = $victim->defend();
     $dmgMultiplier = $this->getRandom(1, 100) / 100;
     if ($atk > $def) {
         $dmg = round($atk * $dmgMultiplier);
         $victim->hurt($dmg);
         $action = "%s did %d damage on %s";
     } else {
         $dmg = round($def * $dmgMultiplier);
         $this->hurt($dmg);
         $action = "%s took %d damage from %s";
     }
     return sprintf($action, $this->getName(), $dmg, $victim->getName());
 }
Exemplo n.º 3
0
 public function attack(MW_Mano $victim)
 {
     $atk = $this->getAtk() + trim(file_get_contents('http://www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'));
     $def = $victim->defend();
     $dmgMultiplier = trim(file_get_contents('http://www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new')) / 10;
     if ($atk > $def) {
         $dmg = round($atk * $dmgMultiplier);
         $victim->hurt($dmg);
         $action = "%s did %d damage on %s";
     } else {
         $dmg = round($def * $dmgMultiplier);
         $this->hurt($dmg);
         $action = "%s took %d damage from %s";
     }
     return sprintf($action, $this->getName(), $dmg, $victim->getName());
 }