本文整理汇总了PHP中Player::level方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::level方法的具体用法?PHP Player::level怎么用?PHP Player::level使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::level方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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()));
}
示例2: level_up_if_possible
function level_up_if_possible($char_id, $auto_level = false)
{
// Setup values:
$max_level = maximum_level();
$health_to_add = 100;
$turns_to_give = 50;
$stat_value_to_add = 5;
$char_kills = get_kills($char_id);
if ($char_kills < 0) {
// If the character doesn't have any kills, shortcut the levelling process.
return false;
} else {
$char_obj = new Player($char_id);
$username = $char_obj->name();
$char_level = $char_obj->level();
if ($auto_level && $char_obj->isAdmin()) {
// If the character is an admin, do not auto-level them.
return false;
} else {
// For normal characters, do auto-level them.
// Check required values:
$nextLevel = $char_level + 1;
$required_kills = required_kills_to_level($char_level);
// Have to be under the max level and have enough kills.
$level_up_possible = $nextLevel <= $max_level && $char_kills >= $required_kills;
if ($level_up_possible) {
// ****** Perform the level up actions ****** //
// Explicitly call for the special case of kill changing to prevent an infinite loop.
$userKills = change_kills($char_id, -1 * $required_kills, $auto_level_check = false);
$userLevel = addLevel($char_id, 1);
change_strength($char_id, $stat_value_to_add);
change_speed($char_id, $stat_value_to_add);
change_stamina($char_id, $stat_value_to_add);
change_karma($char_id, 1);
// Only add 1 to karma via levelling.
change_ki($char_id, 50);
// Add 50 ki points via levelling.
addHealth($char_id, $health_to_add);
addTurns($char_id, $turns_to_give);
// Send a level-up message, for those times when auto-levelling happens.
send_event($char_id, $char_id, "You levelled up! Your strength raised by {$stat_value_to_add}, speed by {$stat_value_to_add}, stamina by {$stat_value_to_add}, Karma by 1, and your Ki raised 50! You gained some health and turns as well! You are now a level {$userLevel} ninja! Go kill some stuff.");
return true;
} else {
return false;
}
}
}
}
示例3: Skill
<?php
$private = true;
$alive = false;
if ($error = init($private, $alive)) {
display_error($error);
} else {
require_once LIB_ROOT . "control/lib_status.php";
// statuses for quickstats
require_once LIB_ROOT . "control/lib_player.php";
// Player info display pieces.
require_once LIB_ROOT . "control/Skill.php";
$skillsListObj = new Skill();
$player = new Player(self_char_id());
$level = $player->level();
$class = $player->class_display_name();
// Just to be displayed in the template.
$starting_turns = $player->turns();
$starting_ki = $player->ki();
$status_list = get_status_list();
$no_skills = true;
$stealth = $skillsListObj->hasSkill('Stealth');
if ($stealth) {
$no_skills = false;
}
$stealth_turn_cost = $skillsListObj->getTurnCost('Stealth');
$unstealth_turn_cost = $skillsListObj->getTurnCost('Unstealth');
$chi = $skillsListObj->hasSkill('Chi');
$speed = $skillsListObj->hasSkill('speed');
$hidden_resurrect = $skillsListObj->hasSkill('hidden resurrect');
$midnight_heal = $skillsListObj->hasSkill('midnight heal');
示例4: rand
$generic_skill_result_message = 'You do not have the necessary ginsengroots or energy to create any Kampo formulas.';
}
} else {
if ($command == 'Poison Touch') {
$covert = true;
$target->addStatus(POISON);
$target->addStatus(WEAKENED);
// Weakness kills strength.
$target_damage = rand($poisonMinimum, $poisonMaximum);
$victim_alive = $target->subtractHealth($target_damage);
$generic_state_change = "__TARGET__ has been poisoned!";
$generic_skill_result_message = "__TARGET__ has taken {$target_damage} damage!";
$msg = "You have been poisoned by {$attacker_id}";
send_event($attacker_char_id, $target->id(), $msg);
} elseif ($command == 'Fire Bolt') {
$target_damage = 5 * ceil($player->level() / 3) + rand(1, $player->getStrength());
$generic_skill_result_message = "__TARGET__ has taken {$target_damage} damage!";
$victim_alive = $target->harm($target_damage);
$msg = "You have had fire bolt cast on you by " . $player->name();
send_event($player->id(), $target->id(), $msg);
} else {
if ($command == 'Heal' || $command == 'Harmonize') {
// This is the starting template for self-use commands, eventually it'll be all refactored.
$harmonize = false;
if ($command == 'Harmonize') {
$harmonize = true;
}
$hurt = $target->is_hurt_by();
// Check how much the TARGET is hurt (not the originator, necessarily).
// Check that the target is not already status healing.
if ($target->hasStatus(HEALING) && !$player->isAdmin()) {
示例5: isset
$userLevel = $player->vo->level;
$userKills = $player->vo->kills;
$user_turns = $player->turns();
$userClass = $player->class_identity();
$user_class_display = $player->class_display_name();
$user_class_theme = class_theme($userClass);
// Pull info for the class requested to change to.
$destination_class_identity = isset($requested_identity) && isset($classes[$requested_identity]) ? $requested_identity : null;
$destination_class_info = $destination_class_display = $destination_class_theme = null;
if ($destination_class_identity) {
$destination_class_info = $classes[$destination_class_identity];
$destination_class_display = $destination_class_info['class_name'];
$destination_class_theme = $destination_class_info['theme'];
}
// Pull the number of kills required to get to the next level.
$required_kills = required_kills_to_level($player->level());
$current_class_untrusted = whichever($current_class_untrusted, $userClass);
// Initialize the class record to prevent double change on refresh.
// Requirement functions.
// Returns an error if there's an obstacle to changing classes.
function class_change_reqs($char_obj, $turn_req)
{
$error = null;
if ($char_obj->turns() < $turn_req) {
// Check the turns, return the error if it's too below.
$error = "You don't have enough turns to change your class.";
}
return $error;
}
// Returns an error if the requirements for getting a dim mak aren't met.
function dim_mak_reqs($char_obj, $turn_req, $str_req)
示例6: elseif
}
$hurt = $target->hurt_by();
// Check how much the TARGET is hurt (not the originator, necessarily).
// Check that the target is not already status healing.
if ($target->hasStatus(HEALING) && !$player->isAdmin()) {
$turn_cost = 0;
$generic_state_change = '__TARGET__ is already under a healing aura.';
} elseif ($hurt < 1) {
$turn_cost = 0;
$generic_skill_result_message = '__TARGET__ is already fully healed.';
} else {
if (!$harmonize) {
$heal_per_level = 10;
// For standard heal.
// Heal at most either: hurt, or heal capacity.
$healed_by = min($hurt, $player->level() * $heal_per_level);
// Call the heal method on the targetted player object.
$new_health = $target->heal($healed_by);
} else {
// Harmonize some chakra!
// Use up some ki to heal yourself.
function harmonize_chakra($char_obj)
{
$ki = $char_obj->ki();
$healed_by = 0;
$hurt = $char_obj->hurt_by();
if ($hurt > 0) {
// If there's anything to heal, try.
// Heal to whichever is lowest, ki, hurt, or 300.
$heal_for = min(100, $hurt, $ki);
// Subtract the ki used for healing.
示例7: testPeasant2AbstractNpcIsSimilarToOriginal
public function testPeasant2AbstractNpcIsSimilarToOriginal()
{
if (!DEBUG) {
$this->markTestSkipped();
}
// Peasant damage is 0-10
// Peasant gold is between 0 and 20.
// 1 in 20 chance of being disguised ninja.
// Has added bounty if attacker is below level 21, and greater than 1.
// added bounty is 1/3rd of attacker's level.
// If they were a disguised ninja, they should drop the max inventory.
$peasant = new Npc('peasant2');
$this->assertLessThan(13, $peasant->max_damage());
$this->assertGreaterThan(0, $peasant->max_damage());
$this->assertLessThan(21, $peasant->gold());
$mock_pc = new Player();
$mock_pc->vo->level = 10;
$this->assertEquals(10, $mock_pc->level());
$this->assertGreaterThan(0, $peasant->dynamicBounty($mock_pc));
}
示例8: closestTo
/**
* @access private
* @since 0.1.0
*
* @param Player $player The player to find
* @return Player The closest player to the given one
*/
private function closestTo($players, $player)
{
$playerLevel = $player->level() + $this->debt;
$diff = 0;
while (true) {
foreach ($players as $opponent) {
$opponentLevel = $opponent->level();
if ($playerLevel >= $opponentLevel - $diff && $playerLevel <= $opponentLevel + $diff) {
$this->debt = $playerLevel - $opponentLevel;
return $opponent;
}
}
$diff++;
}
}
示例9: dynamicBounty
public function dynamicBounty(Player $char)
{
if ($char->level() <= 2) {
return 0;
} else {
return $this->bounty();
}
}