本文整理汇总了PHP中Player::name方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::name方法的具体用法?PHP Player::name怎么用?PHP Player::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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()));
}
示例3: testCantAttackIfExcessiveAmountOfTurnsIsRequired
public function testCantAttackIfExcessiveAmountOfTurnsIsRequired()
{
$confirm = true;
$char_id = TestAccountCreateAndDestroy::create_testing_account($confirm);
$this->oldify_character_last_attack($char_id);
$char_2_id = TestAccountCreateAndDestroy::create_alternate_testing_account($confirm);
$this->oldify_character_last_attack($char_2_id);
$char = new Player($char_2_id);
$legal = new AttackLegal($char_id, $char->name(), ['required_turns' => 4000000000.0, 'ignores_stealth' => true]);
$this->assertFalse($legal->check($update_timer = false));
}
示例4: testDoshinOfferSomeBountyOnATestPlayer
public function testDoshinOfferSomeBountyOnATestPlayer()
{
$target_id = TestAccountCreateAndDestroy::create_alternate_testing_account(true);
$this->char->set_gold(434343);
$this->char->save();
$target = new Player($target_id);
$request = new Request(['target' => $target->name(), 'amount' => 600]);
RequestWrapper::inject($request);
$doshin = new DoshinController();
$doshin->offerBounty();
$new_bounty = (new Player($target->id()))->bounty();
TestAccountCreateAndDestroy::destroy();
$this->assertEquals(600, $new_bounty);
}
示例5: addPlayer
public function addPlayer(Player $user)
{
foreach ($this->players as $player) {
$player->send('newplayer', array('id' => $user->id(), 'name' => $user->name()));
$user->send('newplayer', array('id' => $player->id(), 'name' => $player->name()));
}
if (count($this->players) == 0) {
$this->creator = $user;
}
$this->players[] = $user;
$user->setGame($this);
if (count($this->players) == $this->maxplayers) {
$this->startGame();
}
}
示例6: skills
/**
* Returns the list fo all skills available to a ninja.
**/
public function skills($char_id = null)
{
if (!$char_id) {
$char_id = self_char_id();
}
$char = new Player($char_id);
$char_name = $char->name();
if ($char->isAdmin()) {
// Admins get access to all skills.
$skills = $this->skill_map['crane'] + $this->skill_map['dragon'] + $this->skill_map['tiger'] + $this->skill_map['viper'] + $this->skill_map['all'];
return $skills;
}
$class = char_class_identity($char_id);
$class_skills = array();
if ($class) {
$class_skills = $this->skill_map[$class];
}
return $class_skills + $this->skill_map['all'];
}
示例7: 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;
}
示例8: 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;
}
}
}
}
示例9: Player
// *** Even on failure take at least one turn.
$char_id = self_char_id();
$player = new Player($char_id);
if ($target != '' && $target != $player->player_id) {
$target = new Player($target);
$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 {
示例10: identifier
$item = null;
}
if (!is_object($item)) {
error_log('Invalid item identifier (' . (is_string($item_in) ? $item_in : 'non-string') . ') sent to page from ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '(no referrer)') . '.');
redirect(WEB_ROOT . 'inventory.php?error=noitem');
}
$item_count = item_count($user_id, $item);
// Check whether use on self is occurring.
$self_use = $selfTarget || $target_id === $user_id;
if ($self_use) {
$target = $username;
$targetObj = $player;
} else {
if ($target_id) {
$targetObj = new Player($target_id);
$target = $targetObj->name();
set_setting("last_item_used", $item_in);
// Save last item used.
}
}
$starting_turns = $player->vo->turns;
$username_turns = $starting_turns;
$username_level = $player->vo->level;
if ($targetObj instanceof Player && $targetObj->id()) {
$targets_turns = $targetObj->vo->turns;
$targets_level = $targetObj->vo->level;
$target_hp = $targetObj->vo->health;
} else {
$targets_turns = $targets_level = $target_hp = null;
}
$max_power_increase = 10;
示例11: kickMember
public function kickMember($p_playerID, Player $kicker, $self_leave = false)
{
global $today;
query("DELETE FROM clan_player WHERE _player_id = :player AND _clan_id = :clan", [':player' => $p_playerID, ':clan' => $this->getID()]);
if ($self_leave) {
$msg = "You have been kicked out of " . $this->getName() . " by " . $kicker->name() . " on {$today}.";
} else {
$msg = "You have left clan " . $this->getName() . " on {$today}.";
}
send_message($kicker->id(), $p_playerID, $msg);
return true;
}
示例12: sendMessage
sendMessage($attacking_player->name(), $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 ***
$target_damage = rand(1, $target_str);
示例13: onMessage
public function onMessage(IWebSocketConnection $conn, IWebSocketMessage $msg)
{
$arr = json_decode($msg->getData(), true);
// If this is a new websocket connection, handle the user up front
if ($arr['messageType'] == 'myid') {
if (isset($this->users[$arr['id']])) {
$user = $this->users[$arr['id']];
} else {
$user = new Player(gentoken(), $conn->getId());
}
$this->users[$user->id()] = $user;
$this->conns[$conn->getId()] = $user;
$user->setConnection($conn);
$user->send('myname', array('name' => $user->name(), 'id' => $user->id(), 'ingame' => $user->game() != null));
if ($user->game() != null) {
if ($user->game()->started) {
$user->rejoinGame();
} else {
$user->rejoinWaitingRoom();
}
} else {
foreach ($this->games as $game) {
if ($game->started) {
continue;
}
$user->send('newgame', array('name' => $game->name, 'creator' => $game->creator->name(), 'id' => $game->id));
}
}
$this->say("{$user->id()} connected");
return;
}
// Otherwise we better have a user set for them, and then continue on
// as normally when processing the message
if (!isset($this->conns[$conn->getId()])) {
return;
}
$user = $this->conns[$conn->getId()];
switch ($arr['messageType']) {
case 'newgame':
if ($user->game() != null) {
return;
}
// ERRORS NOT SHOWING ON CLIENT: FIX FIX FIX
if ($arr['name'] == '') {
return $user->send('error', 'Game needs a valid name');
}
$game = new SevenWonders();
$game->maxplayers = intval($arr['players']);
$game->name = $arr['name'];
$game->id = gentoken();
$game->server = $this;
$game->addPlayer($user);
$this->games[$game->id] = $game;
if ($game->maxplayers > 1) {
$this->broadcast('newgame', array('name' => $game->name, 'creator' => $game->creator->name(), 'id' => $game->id), $user);
}
break;
case 'joingame':
if ($user->game() != null) {
break;
}
$id = $arr['id'];
if (!isset($this->games[$id]) || $this->games[$id]->started) {
break;
}
$this->games[$id]->addPlayer($user);
break;
case 'changename':
if ($user->game() == null && $arr['name'] != '') {
$user->setName($arr['name']);
}
// Broadcast name change here in case they're hosting a game?
break;
default:
if ($user->game() != null) {
$user->game()->onMessage($user, $arr);
} else {
$user->send('error', "Error: could not recognize command " . $arr['messageType']);
}
break;
}
}
示例14: sendMessage
} else {
// *** if damage from stealth only hurts the target. ***
$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) {
示例15: array
$template = 'no-player.tpl';
$parts = array();
} else {
$player_info = $target_player_obj->as_array();
// Pull the info out of the object.
if (!$player_info) {
$template = 'no-player.tpl';
$parts = array();
} else {
$viewing_player_obj = new Player(self_char_id());
//$score = get_score_formula();
$self = self_char_id() && self_char_id() == $player_info['player_id'];
// Record whether this is a self-viewing.
if ($viewing_player_obj && $viewing_player_obj->vo) {
$char_id = $viewing_player_obj->id();
$username = $viewing_player_obj->name();
}
$message = in('message');
$player = $target = $player_info['uname'];
// reset the target and target_id vars.
$target_id = $player_info['player_id'];
$target_class_theme = char_class_theme($target_id);
if ($message) {
send_message($char_id, $target_id, $message);
// "message sent" notice will be displayed by the template itself.
}
// Get the player's kills for this date.
$kills_today = query_item('select sum(killpoints) from levelling_log where _player_id = :player_id and killsdate = CURRENT_DATE and killpoints > 0', array(':player_id' => $target_id));
$viewers_clan = $viewing_player_obj instanceof Player && $viewing_player_obj->vo ? get_clan_by_player_id($viewing_player_obj->vo->player_id) : null;
// Attack Legal section
$params = array('required_turns' => 0, 'ignores_stealth' => true);