当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::health方法代码示例

本文整理汇总了PHP中Player::health方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::health方法的具体用法?PHP Player::health怎么用?PHP Player::health使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player::health方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: globalize_user_info

function globalize_user_info($private = true, $alive = true)
{
    global $username;
    global $char_id;
    $error = null;
    $char_id = self_char_id();
    // Will default to null.
    //$username = get_username(); // Will default to null.
    if ((!is_logged_in() || !$char_id) && $private) {
        $error = 'log_in';
        // A non-null set of content being in the error triggers a die at the end of the header.
    } elseif ($char_id) {
        // **************** Player information settings. *******************
        global $player, $player_id;
        // Polluting the global namespace here.  Booo.
        $player = new Player($char_id);
        // Defaults to current session user.
        $username = $player->name();
        // Set the global username.
        $player_id = $player->player_id;
        assert('isset($player_id)');
        if ($alive) {
            // *** That page requires the player to be alive to view it.
            if (!$player->health()) {
                $error = 'dead';
            } else {
                if ($player->hasStatus(FROZEN)) {
                    $error = 'frozen';
                }
            }
        }
    }
    return $error;
}
开发者ID:reillo,项目名称:ninjawars,代码行数:34,代码来源:lib_header.php

示例2: testCreatePlayerObjectHasUsefulInfo

 /**
  * group char
  **/
 function testCreatePlayerObjectHasUsefulInfo()
 {
     $char = new Player($this->char_id);
     $this->assertTrue((bool) positive_int($char->health()));
     $this->assertTrue((bool) positive_int($char->speed()));
     $this->assertTrue((bool) positive_int($char->stamina()));
     $this->assertTrue((bool) positive_int($char->strength()));
     $this->assertTrue((bool) positive_int($char->level()));
     $this->assertNotEmpty($char->name());
     $this->assertTrue((bool) positive_int($char->damage()));
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:14,代码来源:player_test.php

示例3: init

/**
 * Creates all the environmental variables, with no outputting.
 *
 * Places much of the user info into the global namespace.
 */
function init($private, $alive)
{
    global $today;
    global $username;
    global $char_id;
    // ******************** Declared variables *****************************
    $today = date("F j, Y, g:i a");
    // Today var is only used for creating mails.
    // Page viewing settings usually set before the header.
    update_activity_info();
    // *** Updates the activity of the page viewer in the database.
    $error = null;
    $char_id = self_char_id();
    // Will default to null.
    if ((!is_logged_in() || !$char_id) && $private) {
        $error = 'log_in';
        // A non-null set of content being in the error triggers a die at the end of the header.
    } elseif ($char_id) {
        // **************** Player information settings. *******************
        global $player, $player_id;
        // Polluting the global namespace here.  Booo.
        $player = new Player($char_id);
        // Defaults to current session user.
        $username = $player->name();
        // Set the global username.
        $player_id = $player->player_id;
        if ($alive) {
            // That page requires the player to be alive to view it
            if (!$player->health()) {
                $error = 'dead';
            } else {
                if ($player->hasStatus(FROZEN)) {
                    $error = 'frozen';
                }
            }
        }
    }
    return $error;
}
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:44,代码来源:lib_header.php

示例4: max

             // Harmonize some chakra!
             // Use up some ki to heal yourself.
             function harmonize_chakra(Player $char)
             {
                 // Heal at most 100 or ki available or hurt by AND at least 0
                 $heal_for = (int) max(0, min(100, $char->is_hurt_by(), $char->ki()));
                 if ($heal_for > 0) {
                     // If there's anything to heal, try.
                     // Subtract the ki used for healing.
                     $char->heal($heal_for);
                     $char->set_ki($char->ki() - $heal_for);
                     $char->save();
                 }
                 return $char;
             }
             $start_health = $player->health();
             // Harmonize those chakra!
             $player = harmonize_chakra($player);
             $healed_by = $player->health() - $start_health;
             $ki_cost = $healed_by;
         }
         $target->addStatus(HEALING);
         $generic_skill_result_message = "__TARGET__ healed by {$healed_by} to " . $target->health() . ".";
         if ($target->id() != $player->id()) {
             send_event($attacker_char_id, $target->id(), "You have been healed by {$attacker_id} for {$healed_by}.");
         }
     }
 } else {
     if ($command == 'Ice Bolt') {
         if (!$target->hasStatus(SLOW)) {
             if ($target->vo->turns >= 10) {
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:31,代码来源:skills_mod.php

示例5: array

                                            subtract_gold($char_id, $thief_gold);
                                        } else {
                                            if ($thief_attack < 30) {
                                                add_gold($char_id, $thief_gold);
                                                add_item($char_id, 'shuriken', $quantity = 1);
                                            }
                                        }
                                    } else {
                                        $thief_gold = 0;
                                    }
                                    $npc_template = 'npc.thief.tpl';
                                    $combat_data = array('attack' => $thief_attack, 'gold' => $thief_gold, 'victory' => $victory);
                                }
                            }
                        }
                    }
                }
            }
        }
        // ************ End of specific npc logic *******************
        // ************ FINAL CHECK FOR DEATH ***********************
        if ($player->health() <= 0) {
            $health = false;
            sendMessage("SysMsg", $username, "DEATH: You have been killed by a " . $victim . " on {$today}");
        }
        // Subtract the turn cost for attacking an npc, almost always going to be 1 apart from perhaps oni or group-of-thieves
        subtractTurns($char_id, $turn_cost);
    }
    // Add the combat_data into the standard stuff.
    display_page('npc.tpl', 'Battle', array('npc_template' => $npc_template, 'attacked' => 1, 'turns' => $turns, 'random_encounter' => $random_encounter, 'health' => $health) + $combat_data, array('quickstat' => 'player'));
}
开发者ID:reillo,项目名称:ninjawars,代码行数:31,代码来源:npc.php

示例6: testCloneKillKillingWipesHealthAndTurns

 public function testCloneKillKillingWipesHealthAndTurns()
 {
     $char_id = TestAccountCreateAndDestroy::char_id();
     $charObj = new Player($char_id);
     $char_id_2 = TestAccountCreateAndDestroy::char_id_2();
     $charObj_2 = new Player($char_id_2);
     // Will create characters with 127.0.0.1 ip, but that shouldn't be clone kill able.
     $this->assertFalse(CloneKill::canKill($char_id, $char_id_2));
     $this->syncIps('222.244.244.222', $char_id, $char_id_2);
     $this->assertTrue(CloneKill::canKill($char_id, $char_id_2), 'Should be able to clone kill similar and same ip characters!');
     CloneKill::kill($charObj, $charObj, $charObj_2);
     // Obliterate them.
     $pc1 = new Player($char_id);
     $pc2 = new Player($char_id_2);
     $this->assertEquals(0, $pc1->health());
     $this->assertEquals(0, $pc2->health());
     $this->assertEquals(0, $pc1->turns());
     $this->assertEquals(0, $pc2->turns());
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:19,代码来源:skill_test.php

示例7: while

 } else {
     // *** If the attacker is purely dueling or attacking, even if stealthed, though stealth is broken by dueling. ***
     // *** MAIN DUELING SECTION ***
     if ($attacking_player->hasStatus(STEALTH)) {
         // *** Remove their stealth if they duel instead of preventing dueling.
         $attacking_player->subtractStatus(STEALTH);
         $stealth_lost = true;
     }
     // *** PRE-BATTLE STATS - Template Vars ***
     $pre_battle_stats = true;
     $pbs_attacker_name = $attacking_player->name();
     $pbs_attacker_str = $attacking_player->getStrength();
     $pbs_attacker_hp = $attacking_player->health();
     $pbs_target_name = $target_player->name();
     $pbs_target_str = $target_player->getStrength();
     $pbs_target_hp = $target_player->health();
     // *** BEGINNING OF MAIN BATTLE ALGORITHM ***
     $turns_counter = $attack_turns;
     $total_target_damage = 0;
     $total_attacker_damage = 0;
     $target_damage = 0;
     $attacker_damage = 0;
     // *** Combat Calculations ***
     $round = 1;
     $rounds = 0;
     while ($turns_counter > 0 && $total_target_damage < $attacker_health && $total_attacker_damage < $target_health) {
         $turns_counter -= !$duel ? 1 : 0;
         // *** SWITCH BETWEEN DUELING LOOP AND SINGLE ATTACK ***
         $target_damage = rand(1, $target_str);
         $attacker_damage = rand(1, $attacker_str);
         if ($blaze) {
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:31,代码来源:attack_mod.php

示例8: testCauseDeath

 public function testCauseDeath()
 {
     $char = new Player($this->char_id);
     $char->death();
     $this->assertEquals(0, $char->health());
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:6,代码来源:player_test.php

示例9: sendMessage

         $stealth_damage = true;
         sendMessage($attacker, $target, "{$attacker} has attacked you from the shadows for {$stealthAttackDamage} damage.");
     }
 } else {
     // *** If the attacker is purely dueling or attacking, even if stealthed, though stealth is broken by dueling. ***
     // *** MAIN DUELING SECTION ***
     if ($attacking_player->hasStatus(STEALTH)) {
         // *** Remove their stealth if they duel instead of preventing dueling.
         $attacking_player->subtractStatus(STEALTH);
         $stealth_lost = true;
     }
     // *** PRE-BATTLE STATS - Template Vars ***
     $pre_battle_stats = true;
     $pbs_attacker_name = $attacking_player->name();
     $pbs_attacker_str = $attacking_player->getStrength();
     $pbs_attacker_hp = $attacking_player->health();
     $pbs_target_name = $target_player->name();
     $pbs_target_str = $target_player->getStrength();
     $pbs_target_hp = $target_player->health();
     // *** BEGINNING OF MAIN BATTLE ALGORITHM ***
     $turns_counter = $attack_turns;
     $total_target_damage = 0;
     $total_attacker_damage = 0;
     $target_damage = 0;
     $attacker_damage = 0;
     // *** Combat Calculations ***
     $round = 1;
     $rounds = 0;
     while ($turns_counter > 0 && $total_target_damage < $attacker_health && $total_attacker_damage < $target_health) {
         $turns_counter -= !$duel ? 1 : 0;
         // *** SWITCH BETWEEN DUELING LOOP AND SINGLE ATTACK ***
开发者ID:reillo,项目名称:ninjawars,代码行数:31,代码来源:attack_mod.php


注:本文中的Player::health方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。