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


PHP Player::id方法代码示例

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


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

示例1: testMessageHasARobustSender

 public function testMessageHasARobustSender()
 {
     $rec = new Player($this->char_id);
     Message::create(['send_from' => $rec->id(), 'send_to' => $this->char_id_2, 'message' => 'Random phpunit test message of some content', 'type' => 0]);
     $messages = Message::findByReceiver(new Player($this->char_id_2), $type = 0, $limit = 1000, $offset = 0);
     $this->assertGreaterThan(0, count($messages), 'Collection has no results found');
     $first_message = $messages->first();
     $this->assertTrue($first_message instanceof Message, 'First message not a valid message model');
     $this->assertNotEmpty($first_message->sender);
     $this->assertGreaterThan(0, strlen($first_message->sender));
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:11,代码来源:MessageTest.php

示例2: kill

 /**
  * Perform the effects of a clonekill.
  * @return string outcome or false
  **/
 public static function kill(Player $self, Player $clone1, Player $clone2)
 {
     if (self::canKill($clone1, $clone2)) {
         $today = date("F j, Y, g:i a");
         $clone1_health = $clone1->health();
         $clone2_health = $clone2->health();
         $clone1_turns = $clone1->turns();
         $clone2_turns = $clone2->turns();
         $clone1->changeTurns(-1 * $clone1->turns());
         $clone1->death();
         $clone2->changeTurns(-1 * $clone2->turns());
         $clone2->death();
         $result_message = "You obliterate the clone {$clone1->name()} for {$clone1_health} health, {$clone1_turns} turns\n                     and the clone {$clone2->name()} for {$clone2_health} health, {$clone2_turns} turns.";
         send_event($self->id(), $clone1->id(), "You and {$clone2->name()} were Clone Killed at {$today}.");
         send_event($self->id(), $clone2->id(), "You and {$clone1->name()} were Clone Killed at {$today}.");
         return $result_message;
     } else {
         return false;
     }
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:24,代码来源:CloneKill.class.php

示例3: 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);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:14,代码来源:DoshinControllerTest.php

示例4: 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();
     }
 }
开发者ID:intelligentspark,项目名称:sevenwonders-fb,代码行数:15,代码来源:wonders.php

示例5: testCreatePlayerObject

 /**
  * group char
  **/
 function testCreatePlayerObject()
 {
     $char = new Player($this->char_id);
     $this->assertTrue((bool) positive_int($char->id()));
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:8,代码来源:player_test.php

示例6: char_info

/**
 * Returns the state of the player from the database,
 * uses a user_id if one is present, otherwise
 * defaults to the currently logged in player, but can act on any player
 * if another username is passed in.
 * @param $user user_id or username
**/
function char_info($p_id)
{
    if (!$p_id) {
        if (defined('DEBUG') && DEBUG) {
            nw_error('DEPRECATED: call to char_info with a null argument.  For clarity reasons, this is now deprecated, use the player object instead. Backtrace: ' . print_r(debug_backtrace(), true));
        }
        return self_info();
    }
    $id = whichever($p_id, SESSION::get('player_id'));
    // *** Default to current player. ***
    if (!is_numeric($id)) {
        // If there's no id, don't try to get any data.
        return null;
    }
    $player = new Player($id);
    // Constructor uses DAO to get player object.
    $player_data = array();
    if ($player instanceof Player && $player->id()) {
        // Turn the player data vo into a simple array.
        $player_data = (array) $player->vo;
        $player_data['clan_id'] = $player->getClan() ? $player->getClan()->getID() : null;
        $player_data = add_data_to_player_row($player_data);
    }
    return $player_data;
}
开发者ID:reillo,项目名称:ninjawars,代码行数:32,代码来源:lib_player.php

示例7: rand

     $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()) {
             $turn_cost = 0;
             $generic_state_change = '__TARGET__ is already under a healing aura.';
         } elseif ($hurt < 1) {
             $turn_cost = 0;
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:31,代码来源:skills_mod.php

示例8: saveDetails

 /**
  * Static details saving workaround for now.
  **/
 public static function saveDetails(Player $pc)
 {
     $updated = update_query('update players set description = :desc, goals = :goals, instincts = :instincts, beliefs = :beliefs, traits = :traits where player_id = :id', [':id' => $pc->id(), ':desc' => $pc->description(), ':goals' => $pc->goals(), ':instincts' => $pc->instincts(), ':beliefs' => $pc->beliefs(), ':traits' => $pc->traits()]);
     return (bool) $updated;
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:8,代码来源:PlayerDAO.class.php

示例9: testKickClanMember

 function testKickClanMember()
 {
     $player1 = new Player($this->char_id);
     $clan = ClanFactory::find($this->clan_id);
     $this->assertTrue($clan->addMember($player1, $player1));
     $this->assertTrue($clan->addMember($player2 = new Player($this->char_id_2), $player1));
     $this->assertTrue($clan->hasMember($player2->id()));
     $this->assertTrue($clan->hasMember($player1->id()));
     $clan->kickMember($player1->id(), $player2);
     $this->assertFalse($clan->hasMember($player1->id()));
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:11,代码来源:ClanTest.php

示例10: Player

 $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;
 $level_difference = $targets_level - $username_level;
 $level_check = $username_level - $targets_level;
 $near_level_power_increase = nearLevelPowerIncrease($level_difference, $max_power_increase);
 // Sets the page to link back to.
 if ($target_id && ($link_back == "" || $link_back == 'player') && $target_id != $user_id) {
     $return_to = 'player';
 } else {
     $return_to = 'inventory';
开发者ID:reillo,项目名称:ninjawars,代码行数:31,代码来源:inventory_mod.php

示例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;
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:12,代码来源:Clan.php

示例12: date

$ki_cost = 0;
// Ki taken during use.
$reuse = true;
// Able to reuse the skill.
$today = date("F j, Y, g:i a");
// Check whether the user actually has the needed skill.
$has_skill = $skillListObj->hasSkill($command);
$starting_turn_cost = $turn_cost;
assert($turn_cost >= 0);
$turns_to_take = null;
// *** 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;
}
$class = $player->vo->class;
$covert = false;
$victim_alive = true;
$attacker_id = $username;
$attacker_char_id = self_char_id();
$starting_turns = $player->vo->turns;
$ending_turns = null;
$level_check = $player->vo->level - $target->vo->level;
开发者ID:reillo,项目名称:ninjawars,代码行数:31,代码来源:skills_mod.php

示例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;
     }
 }
开发者ID:intelligentspark,项目名称:sevenwonders-fb,代码行数:82,代码来源:server.php

示例14: array

 if (!$target_player_obj || !$target_player_obj->id() || !$target_player_obj->isActive()) {
     $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
开发者ID:reillo,项目名称:ninjawars,代码行数:31,代码来源:player.php


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