本文整理汇总了PHP中Player::hasStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::hasStatus方法的具体用法?PHP Player::hasStatus怎么用?PHP Player::hasStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::hasStatus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: get_status_list
function get_status_list($target = null)
{
$states = array();
$result = '';
$target = isset($target) && (int) $target == $target ? $target : self_char_id();
// Default to showing own status.
$target = new Player($target);
if ($target->vo->health < 1) {
$states[] = 'Dead';
} else {
// *** Other statuses only display if not dead.
if ($target->vo->health < 80) {
$states[] = 'Injured';
} else {
$states[] = 'Healthy';
}
// The visibly viewable statuses.
if ($target->hasStatus(STEALTH)) {
$states[] = 'Stealthed';
}
if ($target->hasStatus(POISON)) {
$states[] = 'Poisoned';
}
if ($target->hasStatus(WEAKENED)) {
$states[] = 'Weakened';
}
if ($target->hasStatus(FROZEN)) {
$states[] = 'Frozen';
}
if ($target->hasStatus(STR_UP1)) {
$states[] = 'Buff';
}
if ($target->hasStatus(STR_UP2)) {
$states[] = 'Strength+';
}
// If any of the shield skills are up, show a single status state for any.
if ($target->hasStatus(FIRE_RESISTING) || $target->hasStatus(INSULATED) || $target->hasStatus(GROUNDED) || $target->hasStatus(BLESSED) || $target->hasStatus(IMMUNIZED) || $target->hasStatus(ACID_RESISTING)) {
$states[] = 'Shielded';
}
}
return $states;
}
示例4: AttackLegal
$target_id = $target->id();
$return_to_target = true;
} else {
// Use the skill on himself.
$return_to_target = false;
$target = $player;
$target_id = null;
}
$covert = false;
$victim_alive = true;
$attacker_id = $player->name();
$attacker_char_id = self_char_id();
$starting_turns = $player->vo->turns;
$ending_turns = null;
$level_check = $player->vo->level - $target->vo->level;
if ($player->hasStatus(STEALTH)) {
$attacker_id = 'A Stealthed Ninja';
}
$use_attack_legal = true;
if ($command == 'Clone Kill' || $command == 'Harmonize') {
$has_skill = true;
$use_attack_legal = false;
$attack_allowed = true;
$attack_error = null;
$covert = true;
} else {
// *** Checks the skill use legality, as long as the target isn't self.
$params = ['required_turns' => $turn_cost, 'ignores_stealth' => $ignores_stealth, 'self_use' => $self_use];
$AttackLegal = new AttackLegal($player, $target, $params);
$attack_allowed = $AttackLegal->check();
$attack_error = $AttackLegal->getError();
示例5: array
$error_template = 'npc.no-one.tpl';
// Error template also used down below.
$npc_template = $error_template;
// Error condition by default.
$turns = $player->turns();
$is_villager = false;
$ninja_str = $player->getStrength();
$ninja_health = $player->vo->health;
$static_npcs = array('peasant', 'thief', 'merchant', 'guard', 'samurai');
$npcs = NpcFactory::npcsData();
$possible_npcs = array_merge($static_npcs, array_keys($npcs));
$victim = restrict_to($victim, $possible_npcs);
// Filter to only the correct options.
if ($turns > 0 && !empty($victim)) {
// Strip stealth when attacking samurai or oni
if ($player->hasStatus('stealth') && (strtolower($victim) == 'samurai' || strtolower($victim) == 'oni')) {
$player->subtractStatus(STEALTH);
}
$attacker_str = $player->getStrength();
$attacker_health = $player->vo->health;
$attacker_gold = $player->vo->gold;
// Perform a random encounter (currently only oni).
if ($random_encounter) {
// *** ONI, Mothafucka! ***
// **********************************************************
// *** Oni attack! Yay! ***
// *** They take turns and a kill and do a little damage. ***
// **********************************************************
$victim = 'Oni';
$oni_turn_loss = 10;
$oni_health_loss = rand(1, 20);
示例6:
give_item($username, $target, $item->getName());
$alternateResultMessage = "__TARGET__ will receive your {$item->getName()}.";
} else {
if (!$item->isOtherUsable()) {
// If it doesn't do damage or have an effect, don't use up the item.
$resultMessage = $result = 'This item is not usable on __TARGET__, so it remains unused.';
$item_used = false;
$using_item = false;
} else {
if ($item->hasEffect('stealth')) {
$targetObj->addStatus(STEALTH);
$alternateResultMessage = "__TARGET__ is now stealthed.";
$targetResult = ' be shrouded in smoke.';
}
if ($item->hasEffect('vigor')) {
if ($targetObj->hasStatus(STR_UP1)) {
$result = "__TARGET__'s body cannot become more vigorous!";
$item_used = false;
$using_item = false;
} else {
$targetObj->addStatus(STR_UP1);
$result = "__TARGET__'s muscles experience a strange tingling.";
}
}
if ($item->hasEffect('strength')) {
if ($targetObj->hasStatus(STR_UP2)) {
$result = "__TARGET__'s body cannot become any stronger!";
$item_used = false;
$using_item = false;
} else {
$targetObj->addStatus(STR_UP2);
示例7: floor
$target_level = $target_player->level;
$target_str = $target_player->getStrength();
// *** Attacker's stats. ***
$attacker_health = $attacking_player->health;
$attacker_level = $attacking_player->level;
$attacker_turns = $attacking_player->turns;
$attacker_str = $attacking_player->getStrength();
$starting_target_health = $target_health;
$starting_turns = $attacker_turns;
$stealthAttackDamage = $attacker_str;
$level_check = $attacker_level - $target_level;
$loot = 0;
$victor = null;
$loser = null;
// *** ATTACKING + STEALTHED SECTION ***
if (!$duel && $attacking_player->hasStatus(STEALTH)) {
// *** Not dueling, and attacking from stealth ***
// TODO: This area seems to be the area that contains the broken stealth-kill-without-reporting bug
// https://github.com/BitLucid/ninjawars/issues/273
$attacking_player->subtractStatus(STEALTH);
$turns_to_take = 1;
$stealthed_attack = true;
$target_health = $target_player->harm($stealthAttackDamage);
if (0 > $target_health) {
// *** if Stealth attack of whatever damage kills target. ***
$victor = $attacker;
$loser = $target;
$gold_mod = 0.1;
$loot = floor($gold_mod * $target_player->gold());
$target_msg = "DEATH: You have been killed by a stealthed ninja in combat and lost {$loot} gold!";
$attacker_msg = "You have killed {$target} in combat and taken {$loot} gold.";