예제 #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);
 }
예제 #2
0
파일: Battle.php 프로젝트: rdohms/ManoWars
 public function fight()
 {
     while ($this->manoA->isAlive() && $this->manoB->isAlive()) {
         echo $this->manoA->attack($this->manoB) . PHP_EOL;
     }
     if ($this->manoA->isAlive()) {
         return $this->manoA->getName() . " won!" . PHP_EOL;
     } else {
         return $this->manoB->getName() . " won!" . PHP_EOL;
     }
 }
예제 #3
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());
 }
예제 #4
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());
 }
예제 #5
0
<?php

include "../init.php";
$greenMushroom = new MW_Powerup_Mushroom_NoPain();
$knife = new MW_Powerup_Sword_Little();
$f****r = new MW_Powerup_Sword_Fucker();
//Preparar Manos
$gil = new MW_Mano('Gil');
$gil->setAtk(10);
$gil->setDef(8);
echo "<pre>";
echo 'Mano ' . $gil->getName() . ' pronto para combater. Atk: ' . $gil->getAtk() . ' / Def: ' . $gil->getDef() . PHP_EOL;
$brown = new MW_Mano('Brown');
$brown->setAtk(11);
$brown->setDef(9);
$brown->addPowerup($knife);
$brown->addPowerup($greenMushroom);
$brown->addPowerup($f****r);
echo 'Mano ' . $brown->getName() . ' pronto para combater. Atk: ' . $brown->getAtk() . ' / Def: ' . $brown->getDef() . PHP_EOL;
//Batalha!
$battle = new MW_Battle($gil, $brown);
echo "Round 1" . PHP_EOL;
echo "Fight!" . PHP_EOL;
echo $battle->fight();
예제 #6
0
파일: index.php 프로젝트: rdohms/ManoWars
<?php

include "../init.php";
//Preparar Manos
$gil = new MW_Mano('Gil');
$gil->setAtk(10);
$gil->setDef(8);
echo 'Mano ' . $gil->getName() . ' pronto para combater. Atk: ' . $gil->getAtk() . ' / Def: ' . $gil->getDef() . PHP_EOL;
$brown = new MW_Mano('Brown');
$brown->setAtk(11);
$brown->setDef(9);
echo 'Mano ' . $brown->getName() . ' pronto para combater. Atk: ' . $brown->getAtk() . ' / Def: ' . $brown->getDef() . PHP_EOL;
//Batalha!
$battle = new MW_Battle($gil, $brown);
echo "Round 1" . PHP_EOL;
echo "Fight!" . PHP_EOL;
echo $battle->fight();