/** * The reward for defeating an npc, less if items popped * * @param Npc $npco * @param boolean $reward_item Any items were rewarded. * @return int * @note * If npc gold explicitly set to 0, reward gold will be totally skipped * "rich" npcs will have a higher gold minimum */ private function calcReceivedGold(Npc $npco, $reward_item) { if ($npco->gold() === 0) { // These npcs simply don't give gold. return 0; } // Hack a little off max gold if items received. $divisor = 1; if ($reward_item) { $divisor = self::ITEM_DECREASES_GOLD_FACTOR; } return rand($npco->minGold(), floor($npco->gold() / $divisor)); }
/** * Guard1: * Dam: 1 to attacker_str + 40 * Gold: 1 to attacker_str + 40 * Bounty: 10 + 0-10 * 1 in 9 chance of ginseng root * Guard2: Strength is about 30, which is multiplied by 2, + 1 point during damage calc. * Gold doesn't get boosted by strength */ public function testGuard2AbstractNpcIsSimilarToGuard1() { if (!DEBUG) { $this->markTestSkipped(); } $guard2 = new Npc('guard2'); $mock_pc = new Player(); $mock_pc->setStrength(30); $dam = $guard2->maxDamage($mock_pc); // partial_match_strength should add about 1/3rd of the enemies' strength as dam. $this->assertGreaterThan(40, $dam); $this->assertLessThan(80, $dam); // Dam is strength * 2 + 1 $this->assertLessThan(61, $guard2->gold()); $this->assertGreaterThan(40, $guard2->gold()); $this->assertGreaterThan(9, $guard2->bountyMod()); }