Esempio n. 1
0
 /**
  * Tests MW_Mano->defend()
  */
 public function testDefend()
 {
     $this->MW_Mano = new MW_Mano('Gil');
     $this->MW_Mano->setDef(5);
     $this->assertEquals(5, $this->MW_Mano->getDef());
     $sgth = $this->MW_Mano->defend();
     $this->assertGreaterThan(5, $sgth);
 }
Esempio 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());
 }
Esempio 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());
 }