Ejemplo n.º 1
0
 /**
  * API:注册登陆时获取所有界面信息
  *
  * @access public
  * @param int $user_id 用户ID $character_id主角ID
  * @return array
  */
 public function getAllMessage($user_id)
 {
     //主角界面
     $characterInfo = CharacterAction::GetAllCharacterInfo($user_id);
     //武将界面
     $generalInfo = GeneralAction::GetAllGeneralInfo($user_id);
     $messageArr = array_merge($characterInfo, $generalInfo);
     //任务成就界面
     $messageArr['achieveInfo'] = TaskAndAchieveAction::getAchieveInfo($user_id);
     $messageArr['taskInfo'] = TaskAndAchieveAction::getTaskInfo($user_id);
     //商城数据
     $messageArr['mallInfo'] = BuyPropAction::exeGetMallInfo($user_id);
     //道具数据
     $messageArr['itemInfo'] = BuyPropAction::exeGetPropInfo($user_id);
     //好友界面
     $messageArr['friendInfo'] = FriendAction::exeGetFriendMenu($user_id);
     $messageArr['mail_num'] = MailAction::getMailNum($user_id);
     $messageArr['achieve_type'] = TaskAndAchieveAction::isFinish($user_id);
     //复活信息
     $messageArr['resurrextInfo']['price_type'] = Constants::RESURE_TYPE;
     $messageArr['resurrextInfo']['price'] = Constants::RESURE_COST;
     $messageArr['resurrextInfo']['hp'] = Constants::RESURE_HP;
     $messageArr['resurrextInfo']['time'] = Constants::RESURE_TIME;
     //BOSS关卡评分
     $messageArr['bossPoint']['time'] = Constants::BOSS_TIME;
     $messageArr['bossPoint']['less_time'] = Constants::LESS_TIME;
     $messageArr['bossPoint']['more_time'] = Constants::MORE_TIME;
     return $messageArr;
 }
Ejemplo n.º 2
0
 /**
  * API:升级武将属性
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeUpdateGeneral()
 {
     $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'];
     $general_id = $requestJsonParam['general_id'];
     $attribute_id = $requestJsonParam['attribute_id'];
     $session_key = $requestParam['session_key'];
     $userGeneral = UserCache::getByKey($user_id, 's_general_info');
     if (!$userGeneral) {
         $userGeneral = GeneralModel::getUserGeneralInfo($user_id);
         UserCache::setByKey($user_id, 's_general_info', $userGeneral);
     }
     $attribute = self::$attribute;
     $price_type = self::$price_type;
     // 读取csv类  ,读取目标文件
     $file = IniFileManager::getRootDir() . "/files/csv/general" . $general_id . "_update_value.csv";
     $str = "update_id = " . $attribute_id . '_' . $userGeneral[$general_id][$attribute[$attribute_id]];
     $nowArr = CharacterAction::readCsv($file, $str);
     $type = $price_type[$nowArr[0]['price_type']];
     $money = UserCache::getByKey($user_id, $type);
     if (!$money) {
         $userInfo = GeneralModel::getUserInfo($user_id);
         $money = $userInfo[$type];
     }
     $money = $money - $nowArr[0]['price'];
     if ($money < 0) {
         $messageArr['error'] = "人生果/钻石不足!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "general/update_general");
     }
     if ($userGeneral[$general_id][$attribute[$attribute_id]] >= Constants::MAX_LEVEL) {
         $messageArr['error'] = "等级已达最大!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "general/update_general");
     }
     $userGeneral[$general_id][$attribute[$attribute_id]] = $userGeneral[$general_id][$attribute[$attribute_id]] + 1;
     $s_general_info = serialize($userGeneral);
     $res = GeneralModel::update(array($type => $money, 's_general_info' => $s_general_info), array('n_id' => $user_id));
     if (!$res) {
         throw new Exception(" update false pa_user_master ");
     }
     //任务成就统计
     $num = 0;
     TaskAndAchieveAction::taskStatistic($user_id, array('generl_up' => 1));
     if ($type == $price_type[1]) {
         TaskAndAchieveAction::achieveStatistic($user_id, array('cost' => $nowArr[0]['price']));
     }
     foreach ($attribute as $key => $value) {
         if ($userGeneral[$general_id][$value] >= Constants::MAX_LEVEL) {
             $num++;
         }
     }
     if ($num == 2) {
         TaskAndAchieveAction::achieveStatistic($user_id, array('generl_full' => 1));
     }
     //session_key
     UserCache::setByKey($user_id, 's_general_info', $userGeneral);
     UserCache::setByKey($user_id, $type, $money);
     //更新战斗力
     $battle = UserAction::getUserBattle($user_id);
     GeneralModel::update(array('n_battle' => $battle), array('n_id' => $user_id));
     UserCache::setByKey($user_id, 'n_battle', $battle);
     $messageArr = self::GetAllGeneralInfo($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, "general/update_general");
 }