Beispiel #1
0
 public function testBlankNpcHasZeroStrengthPositiveHealth()
 {
     $npc = new Npc($data = array());
     $this->assertEquals(0, $npc->strength());
     $this->assertGreaterThan(0, $npc->health());
     // All npcs should actually get some health!
 }
Beispiel #2
0
 $statuses = null;
 $status_classes = null;
 // Assume defeat...
 $victory = null;
 $received_gold = null;
 $received_display_items = null;
 $added_bounty = null;
 $is_rewarded = null;
 // Gets items or gold.
 $display_statuses = $display_statuses_classes = null;
 // Get percent of total initial health.
 // ******* FIGHT *********** & Hope for victory.
 $victory = false;
 $survive_fight = $player->vo->health = subtractHealth($char_id, $npco->damage());
 $armored = $npco->has_trait('armored') ? 1 : 0;
 $kill_npc = $npco->health() < $player->damage();
 if ($survive_fight) {
     // The ninja survived, they'll get gold.
     $received_gold = rand(floor($reward_gold / 5), $reward_gold);
     add_gold($char_id, $received_gold);
     $received_display_items = array();
     if ($kill_npc) {
         $victory = true;
         // Victory occurred, reward the poor sap.
         if ($npco->inventory()) {
             foreach ($npco->inventory() as $l_item => $avail) {
                 $item_info = item_info_from_identity($l_item);
                 $received_display_items[] = $item_info['item_display_name'];
                 add_item($char_id, $item_info['item_internal_name'], 1);
             }
         }