コード例 #1
0
ファイル: SkillUnitTest.php プロジェクト: BitLucid/ninjawars
 public function testStealthDecreasesStrengthIncreasesStamina()
 {
     $pc = new Player();
     $str = $pc->getStrength();
     $stamina = $pc->getStamina();
     $speed = $pc->getSpeed();
     $pc->addStatus(STEALTH);
     $this->assertTrue($pc->hasStatus(STEALTH));
     $this->assertLessThan($str, $pc->getStrength(), 'Stealth failed to affect strength.');
     $this->assertGreaterThan($stamina, $pc->getStamina(), 'Stealth status failed to affect stamina.');
     $this->assertGreaterThan($speed, $pc->getSpeed(), 'Stealth status failed to affect speed.');
 }
コード例 #2
0
 /**
  * @return void
  */
 private function stealthStrike(Player $attacker, Player $target)
 {
     $target->harm($attacker->getStrength());
     $attacker->turns = $attacker - turns - 1 * self::STEALTH_STRIKE_COST;
 }
コード例 #3
0
ファイル: Item.php プロジェクト: BitLucid/ninjawars
 /**
  * Get the maximum numeric damage of an object.
  *
  * If a player is passed in, damage is the better of 9 or 2/3rd of the
  * player's strength -4.
  *
  * @param Player|null $pc (optional) Use player to calculate damage
  * @return int
  * @note
  * Some effects-based object will not actually have a pre-known maxDamage
  */
 public function getMaxDamage(Player $pc = null)
 {
     if ($pc instanceof Player && $this->hasDynamicDamage()) {
         return max(static::MIN_DYNAMIC_DAMAGE, (int) floor($pc->getStrength() * 2 / 3) - 4);
     } else {
         return $this->target_damage;
     }
 }
コード例 #4
0
ファイル: NpcController.php プロジェクト: BitLucid/ninjawars
 private function attackSamurai(Player $player)
 {
     $gold = 0;
     $victory = false;
     $drop = false;
     $drop_display = null;
     $damage = [rand(1, $player->getStrength()), rand(10, 10 + round($player->getStrength() * 1.2))];
     if (rand(0, 1)) {
         $damage[] = rand(30 + round($player->getStrength() * 0.2), 30 + round($player->getStrength() * 1.7));
     } else {
         //Instant death.
         $damage[] = abs($player->health - $damage[0] - $damage[1]);
     }
     for ($i = 0; $i < count($damage) && $player->health > 0; ++$i) {
         $player->harm($damage[$i]);
     }
     if ($player->health > 0) {
         // Ninja still has health after all attacks
         $victory = true;
         $gold = rand(50, 50 + $damage[2] + $damage[1]);
         $player->addKills(1);
         $player->setGold($player->gold + $gold);
         $inventory = new Inventory($player);
         // If samurai dmg high, but ninja lived, give rewards
         if ($damage[2] > self::SAMURAI_REWARD_DMG) {
             $drop = true;
             if (rand(0, 1)) {
                 $drop_display = 'mushroom powder';
                 $dropItem = 'amanita';
             } else {
                 $drop_display = 'a strange herb';
                 $dropItem = 'ginsengroot';
             }
             $inventory->add($dropItem, 1);
         }
         // If the final damage was the exact max damage
         if ($damage[2] == $player->getStrength() * 3) {
             $drop = true;
             $drop_display = 'a black scroll';
             $inventory->add('dimmak', 1);
         }
     }
     $player->save();
     return ['npc.samurai.tpl', ['samurai_damage_array' => $damage, 'gold' => $gold, 'victory' => $victory, 'ninja_str' => $player->getStrength(), 'level' => $player->level, 'attacker_kills' => $player->kills, 'drop' => $drop, 'drop_display' => $drop_display]];
 }
コード例 #5
0
 /**
  * Technically max -additional damage off the base
  */
 public function fireBoltMaxDamage(Player $pc)
 {
     return (int) $pc->getStrength();
 }