$npc_template = 'npc.oni.tpl'; $combat_data = array('victory' => $oni_killed); } elseif (array_key_exists($victim, $npcs)) { /**** Abstracted NPCs *****/ $npc_stats = $npcs[$victim]; // Pull an npcs individual stats with generic fallbacks. /* ============= STANDARD NPCS ======================= */ $npco = new Npc($npc_stats); // Construct the npc object. $display_name = first_value(@$npc_stats['name'], ucfirst($victim)); $max_damage = $npco->max_damage(); $percent_damage = null; // Percent damage does to the player's health. $status_effect = whichever(@$npc_stats['status'], null); $reward_item = first_value(@$npc_stats['item'], null); $base_gold = $npco->gold(); $npc_gold = (int) @$npc_stats['gold']; $is_quick = $npco->speed() > $player->speed() ? true : false; // Beyond basic speed and they see you coming, so show that message. // If npc gold explicitly set to 0, then none will be given. $reward_gold = $npc_gold === 0 ? 0 : ($reward_item ? round($base_gold * 0.9) : $base_gold); // Hack a little off reward gold if items received. $bounty_mod = @$npc_stats['bounty']; $is_villager = $npco->has_trait('villager'); // Give the villager message with the bounty. $is_weaker = $npco->strength() * 3 < $player->strength(); // Npc much weaker? $is_stronger = $npco->strength() > $player->strength() * 2; // Npc More than twice as strong? //debug($is_villager, $npco->traits, $npco);die(); $image = @$npc_stats['img'];
public function testGuard2AbstractNpcIsSimilarToGuard1() { if (!DEBUG) { $this->markTestSkipped(); } $guard2 = new Npc('guard2'); /* Guard1: Dam: 1 to attacker_str + 40 Gold: 1 to attacker_str + 40 Bounty: 10 + 1-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 */ $mock_pc = new Player(); $mock_pc->setStrength(30); $dam = $guard2->max_damage($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()); }