Example #1
0
 // 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'];
 $image_path = null;
 if ($image && file_exists(SERVER_ROOT . 'www/images/characters/' . $image)) {
     // If the image exists, set the path to it for use on the page.
     $image_path = IMAGE_ROOT . 'characters/' . $image;
 }
 $statuses = null;
 $status_classes = null;
 // Assume defeat...
Example #2
0
 function testGuardsThatMatchStrengthTakeEnemyStrength()
 {
     if (!DEBUG) {
         $this->markTestSkipped();
     }
     $pc = new Player();
     $pc->vo->strength = 100;
     $guard = new Npc('guard2');
     $guard_strength = $guard->strength();
     $guard_max_damage = $guard->max_damage();
     $guard_with_enemy = new Npc('guard2');
     $improved_dam = $guard_with_enemy->max_damage($pc);
     $this->assertTrue($guard->has_trait('partial_match_strength'));
     $this->assertGreaterThan(0, $guard_max_damage);
     $this->assertGreaterThan($guard_max_damage, $improved_dam, 'Guard damage should be higher with an enemy that has any strength');
 }