當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserAction::getUserBattle方法代碼示例

本文整理匯總了PHP中UserAction::getUserBattle方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserAction::getUserBattle方法的具體用法?PHP UserAction::getUserBattle怎麽用?PHP UserAction::getUserBattle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserAction的用法示例。


在下文中一共展示了UserAction::getUserBattle方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: exeChangeFightCharacter

 /**
  * API:更改上陣主角,及頭像
  *
  * @access public
  * @param 無
  * @return JsonView 響應json
  */
 public function exeChangeFightCharacter()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     $user_id = $requestParam['user_id'];
     $character_id = $requestJsonParam['character_id'];
     $session_key = $requestParam['session_key'];
     $userCharacter = UserCache::getByKey($user_id, self::CHARACTER_STRING);
     if (!$userCharacter) {
         $userCharacter = CharacterModel::getUserCharacterInfo($user_id);
         UserCache::setByKey($user_id, self::CHARACTER_STRING, $userCharacter);
     }
     if (!$userCharacter[$character_id]) {
         $messageArr['error'] = "尚未擁有該角色!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "character/change_fight_character");
     }
     $userCharacter[0] = $character_id;
     $s_role_info = serialize($userCharacter);
     $res = CharacterModel::update(array('s_role_info' => $s_role_info, 'n_head' => $character_id), array('n_id' => $user_id));
     if (!$res) {
         throw new Exception("update false");
     }
     UserCache::setByKey($user_id, self::CHARACTER_STRING, $userCharacter);
     UserCache::setByKey($user_id, 'n_head', $character_id);
     //更新戰鬥力
     $battle = UserAction::getUserBattle($user_id);
     CharacterModel::update(array('n_battle' => $battle), array('n_id' => $user_id));
     UserCache::setByKey($user_id, 'n_battle', $battle);
     $messageArr = self::GetAllCharacterInfo($user_id);
     $messageArr['battle'] = $battle;
     //任務成就界麵
     $messageArr['achieveInfo'] = TaskAndAchieveAction::getAchieveInfo($user_id);
     $messageArr['taskInfo'] = TaskAndAchieveAction::getTaskInfo($user_id);
     $messageArr['mail_num'] = MailAction::getMailNum($user_id);
     $messageArr['achieve_type'] = TaskAndAchieveAction::isFinish($user_id);
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "character/change_fight_character");
 }
開發者ID:YYLP,項目名稱:y_game,代碼行數:50,代碼來源:CharacterAction.class.php

示例2: isUnlock

 /**
  * API:武將解鎖直接擁有
  *
  * @access public
  * @param int $user_id 用戶ID $general_id主角ID
  * @return array
  */
 public function isUnlock($user_id)
 {
     $starNum = GameAction::getUserStar($user_id);
     $userGeneral = UserCache::getByKey($user_id, 's_general_info');
     if (!$userGeneral) {
         $userGeneral = GeneralModel::getUserGeneralInfo($user_id);
         UserCache::setByKey($user_id, 's_general_info', $userGeneral);
     }
     //讀取係統武將,屬性列表
     $file = IniFileManager::getRootDir() . "/files/csv/general.csv";
     $generalArr = CharacterAction::readCsv($file);
     foreach ($generalArr as $key => $value) {
         if (!$userGeneral[$value['general_id']]) {
             if ($starNum >= $value['unlock_star']) {
                 //添加新武將到武將信息字段、更新用戶金錢
                 $userGeneral[$value['general_id']] = array('n_continue_level' => 0, 'n_cool_level' => 0);
                 $unlockInfo = $value['general_id'];
             }
         }
     }
     $s_general_info = serialize($userGeneral);
     $ret = GeneralModel::update(array('s_general_info' => $s_general_info), array('n_id' => $user_id));
     UserCache::setByKey($user_id, 's_general_info', $userGeneral);
     //更新戰鬥力
     $battle = UserAction::getUserBattle($user_id);
     GeneralModel::update(array('n_battle' => $battle), array('n_id' => $user_id));
     UserCache::setByKey($user_id, 'n_battle', $battle);
     return $unlockInfo ? $unlockInfo : 0;
 }
開發者ID:YYLP,項目名稱:y_game,代碼行數:36,代碼來源:GeneralAction.class.php


注:本文中的UserAction::getUserBattle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。