예제 #1
0
파일: npc.php 프로젝트: reillo/ninjawars
             }
         }
     } else {
         $oni_killed = false;
     }
     $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();
예제 #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');
 }