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


PHP self_char_id函数代码示例

本文整理汇总了PHP中self_char_id函数的典型用法代码示例。如果您正苦于以下问题:PHP self_char_id函数的具体用法?PHP self_char_id怎么用?PHP self_char_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: changeClass

 /**
  * Action to request class change form AND execute class change
  *
  * @todo split form request and execute into separate funcs
  * @return ViewSpec
  */
 public function changeClass()
 {
     if (is_logged_in()) {
         $player = new Player(self_char_id());
         $classes = $this->classesInfo();
         $requestedIdentity = in('requested_identity');
         $currentClass = $player->identity;
         $showMonks = false;
         $parts = [];
         if (isset($classes[$requestedIdentity])) {
             $error = $this->classChangeReqs($player, self::CLASS_CHANGE_COST);
             if ($currentClass != $requestedIdentity && !$error) {
                 $error = $this->changePlayerClass($player, $requestedIdentity);
             }
             $currentClass = $player->identity;
             if (!$error) {
                 $parts['pageParts'] = ['success-class-change'];
                 $showMonks = true;
             } else {
                 $parts['error'] = $error;
             }
         } else {
             $parts['pageParts'] = ['form-class-change'];
         }
         unset($classes[$currentClass]);
         $parts['classOptions'] = $classes;
         return $this->render($parts, $player, $showMonks);
     } else {
         return $this->accessDenied();
     }
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:37,代码来源:DojoController.php

示例2: prep_page

function prep_page($template, $title = null, $local_vars = array(), $options = null)
{
    // Updates the quickstat via javascript if requested.
    $quickstat = @$options['quickstat'];
    $quickstat = $quickstat ? $quickstat : @$local_vars['quickstat'];
    $body_classes = isset($options['body_classes']) ? $options['body_classes'] : (isset($local_vars['body_classes']) ? $local_vars['body_classes'] : null);
    $is_index = @$options['is_index'];
    // *** Initialize the template object ***
    $tpl = new NWTemplate();
    $tpl->assignArray($local_vars);
    $user_id = self_char_id();
    // Character id.
    $player = Player::find($user_id);
    $public_char_info = $player ? $player->publicData() : [];
    // Char info to pass to javascript.
    $tpl->assign('logged_in', $user_id);
    $tpl->assign('user_id', $user_id);
    $tpl->assign('title', $title);
    $tpl->assign('quickstat', $quickstat);
    $tpl->assign('is_index', $is_index);
    $tpl->assign('json_public_char_info', $public_char_info ? json_encode($public_char_info) : null);
    $tpl->assign('body_classes', $body_classes);
    $tpl->assign('main_template', $template);
    return $tpl;
}
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:25,代码来源:lib_templates.php

示例3: 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

示例4: deleteClan

 /**
  * Delete the all the messages from your clan.
  */
 public function deleteClan()
 {
     $char_id = self_char_id();
     $type = 1;
     Message::deleteByReceiver(new Player($char_id), $type);
     return new RedirectResponse('/messages.php?command=clan&informational=' . url('Messages deleted'));
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:10,代码来源:MessagesController.php

示例5: bet

 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a reward item
  */
 public function bet()
 {
     $player = new Player(self_char_id());
     $bet = intval(in('bet'));
     $negative = $bet < 0;
     set_setting('bet', max(0, $bet));
     $pageParts = ['reminder-max-bet'];
     if ($negative) {
         $pageParts = ['result-cheat'];
         $player->vo->health = subtractHealth($player->id(), 99);
     } else {
         if ($bet > $player->vo->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->vo->gold = add_gold($player->id(), $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->vo->gold = subtract_gold($player->id(), $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     // End of not cheating check.
     return $this->render(['pageParts' => $pageParts, 'player' => $player, 'bet' => get_setting('bet')]);
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:41,代码来源:CasinoController.php

示例6: bet

 /**
  * User command for betting on the coin toss game in the casino
  *
  * @param bet int The amount of money to bet on the coin toss game
  * @return Array
  *
  * @note
  * If the player bets within ~1% of the maximum bet, they will receive a
  * reward item
  */
 public function bet()
 {
     $player = Player::find(self_char_id());
     $bet = intval(in('bet'));
     $pageParts = ['reminder-max-bet'];
     if ($bet < 0) {
         $pageParts = ['result-cheat'];
         $player->harm(self::CHEAT_DMG);
     } else {
         if ($bet > $player->gold) {
             $pageParts = ['result-no-gold'];
         } else {
             if ($bet > 0 && $bet <= self::MAX_BET) {
                 if (rand(0, 1) === 1) {
                     $pageParts = ['result-win'];
                     $player->set_gold($player->gold + $bet);
                     if ($bet >= round(self::MAX_BET * 0.99)) {
                         // within about 1% of the max bet & you win, you get a reward item.
                         add_item($player->id(), self::REWARD, 1);
                     }
                 } else {
                     $player->set_gold($player->gold - $bet);
                     $pageParts = ['result-lose'];
                 }
             }
         }
     }
     $player->save();
     return $this->render(['pageParts' => $pageParts, 'player' => $player]);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:40,代码来源:CasinoController.php

示例7: game

 /**
  * The standard homepage
  *
  * @return ViewSpec
  */
 private function game()
 {
     // Get the actual values of the vars.
     $ninja = new Player(self_char_id());
     $playerInfo = $ninja->dataWithClan();
     $unreadCount = Message::where(['send_to' => $ninja->id(), 'unread' => 1])->count();
     // Assign these vars to the template.
     $parts = ['main_src' => '/intro', 'body_classes' => 'main-body', 'version' => 'NW Version 1.7.5 2010.12.05', 'ninja' => $ninja, 'player_info' => $playerInfo, 'unread_message_count' => $unreadCount];
     return ['template' => 'index.tpl', 'title' => 'Live by the Shuriken', 'parts' => $parts, 'options' => ['is_index' => true]];
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:15,代码来源:HomepageController.php

示例8: hasSkill

 /**
  * Check whether the player has the skill.
  **/
 public function hasSkill($skill, $username = null)
 {
     if (!$username) {
         $charId = self_char_id();
     } else {
         $charId = get_char_id($username);
     }
     $player = new Player($charId);
     $skills = $this->skills($player);
     $skill = strtolower($skill);
     $levelReq = isset($skills[$skill]['level']) ? $skills[$skill]['level'] : 1;
     return isset($skills[$skill]['available']) && $player->level >= $levelReq;
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:16,代码来源:Skill.php

示例9: message_to_clan

function message_to_clan($p_message)
{
    $error = null;
    $user_id = self_char_id();
    $clan_id = get_clan_by_player_id($user_id)->getID();
    $clan_members = query_resultset("SELECT player_id, uname\n\t    FROM clan JOIN clan_player ON _clan_id = clan_id JOIN players ON player_id = _player_id\n\t    WHERE clan_id = :clan", array(':clan' => $clan_id));
    $messaged_to = array();
    foreach ($clan_members as $loop_member) {
        send_message($user_id, $loop_member['player_id'], $p_message, $type = 1);
        $messaged_to[] = $loop_member['uname'];
    }
    return implode(', ', $messaged_to);
}
开发者ID:reillo,项目名称:ninjawars,代码行数:13,代码来源:lib_message.php

示例10: index

 /**
  * Display the combat/action events and mark them as read when displayed.
  */
 public function index()
 {
     $char = new Player(self_char_id());
     $events = $this->getEvents($char->id(), 300);
     // Check for clan to use it in the nav tabs.
     $has_clan = (bool) ClanFactory::clanOfMember($char);
     $this->readEvents($char->id());
     // mark events as viewed.
     $template = 'events.tpl';
     $title = 'Events';
     $parts = ['events' => $events, 'has_clan' => $has_clan, 'char' => $char];
     $options = ['quickstat' => 'player'];
     return ['title' => $title, 'template' => $template, 'parts' => $parts, 'options' => $options];
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:17,代码来源:EventsController.php

示例11: hasSkill

 /**
  * Check whether the player has the skill.
  **/
 public function hasSkill($skill, $username = null)
 {
     $skill = strtolower($skill);
     if (!$username) {
         $char_id = self_char_id();
     } else {
         $char_id = get_char_id($username);
     }
     $player_info = char_info($char_id);
     $player_level = $player_info['level'];
     $skills = $this->skills($char_id);
     $level_req = isset($skills[$skill]['level']) ? $skills[$skill]['level'] : 1;
     return isset($skills[$skill]['available']) && $player_level >= $level_req;
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:17,代码来源:Skill.php

示例12: index

 /**
  * Get the last turns worked by a pc, and pass it to display the default
  * page with form
  */
 public function index()
 {
     // Initialize variables to pass to the template.
     $work_multiplier = self::WORK_MULTIPLIER;
     $worked = null;
     $earned_gold = null;
     $not_enough_energy = null;
     $is_logged_in = is_logged_in();
     $char = new Player(self_char_id());
     // Fill out some of the variables.
     $recommended_to_work = self::DEFAULT_RECOMMENDED_TO_WORK;
     $gold_display = number_format($char->gold());
     $parts = ['recommended_to_work' => $recommended_to_work, 'work_multiplier' => $work_multiplier, 'is_logged_in' => $is_logged_in, 'gold_display' => $gold_display, 'worked' => $worked, 'earned_gold' => number_format($earned_gold), 'not_enough_energy' => $not_enough_energy];
     return $this->render($parts);
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:19,代码来源:WorkController.php

示例13: receive

 /**
  * Take in a chat and record it to the database.
  *
  **/
 public function receive()
 {
     $char_id = self_char_id();
     $message = in('message', null, 'no filter');
     // Essentially no filtering.
     $error = null;
     if (!empty($message)) {
         if ($char_id) {
             send_chat($char_id, $message);
         } else {
             $error = 'You must be logged in to chat.';
         }
     }
     return new RedirectResponse('/village.php' . ($error ? '?error=' . url($error) : ''));
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:19,代码来源:ChatController.php

示例14: configure

 /**
  * @TODO Document me!
  */
 private function configure()
 {
     $char = Player::find(self_char_id());
     // Array that simulates database display information for switching out for an npc database solution.
     $npcs = [['name' => 'Peasant', 'identity' => 'peasant', 'image' => 'fighter.png'], ['name' => 'Thief', 'identity' => 'thief', 'image' => 'thief.png'], ['name' => 'Merchant', 'identity' => 'merchant', 'image' => 'merchant.png'], ['name' => 'Guard', 'identity' => 'guard', 'image' => 'guard.png'], ['name' => 'Samurai', 'identity' => 'samurai', 'image' => 'samurai.png']];
     $peers = $char ? $this->getNearbyPeers($char->id()) : [];
     $active_ninjas = Player::findActive(5, true);
     $char_info = $char ? $char->dataWithClan() : [];
     // Generic/abstracted npcs
     $other_npcs = NpcFactory::npcsData();
     $enemy_list = $char ? $this->getCurrentEnemies($char->id()) : [];
     $enemy_count = rco($enemy_list);
     $recent_attackers = $char ? $this->getRecentAttackers($char) : [];
     return ['logged_in' => (bool) $char, 'enemy_list' => $enemy_list, 'enemy_count' => $enemy_count, 'char_name' => $char ? $char->name() : '', 'npcs' => $npcs, 'other_npcs' => $other_npcs, 'char_info' => $char_info, 'active_ninjas' => $active_ninjas, 'recent_attackers' => $recent_attackers, 'enemy_list' => $enemy_list, 'peers' => $peers, 'max_enemies' => self::ENEMY_LIMIT <= $enemy_count];
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:18,代码来源:ConsiderController.php

示例15: send_event

/**
 * For events, attacks, kills, invites, etc, and no user-created messages
 *
 * @param int $fromId
 * @param int $toId
 * @param String $msg
 * @return void
 * @throws Exception
 */
function send_event($fromId, $toId, $msg)
{
    if (!$toId) {
        $toId = self_char_id();
    }
    if (!is_numeric($fromId) || !is_numeric($toId)) {
        throw new \Exception('A player id wasn\'t sent in to the send_event function.');
    }
    DatabaseConnection::getInstance();
    $statement = DatabaseConnection::$pdo->prepare("INSERT INTO events (event_id, send_from, send_to, message, date)\n        VALUES (default, :from, :to, :message, now())");
    $statement->bindValue(':from', $fromId);
    $statement->bindValue(':to', $toId);
    $statement->bindValue(':message', $msg);
    $statement->execute();
}
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:24,代码来源:lib_events.php


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