本文整理匯總了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");
}
示例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;
}