本文整理汇总了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;
}