Ejemplo n.º 1
0
 /**
  * API:更新合体时间
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeUpdateFitTime()
 {
     $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'];
     $friend_id = $requestJsonParam['friend_id'];
     $session_key = $requestParam['session_key'];
     //判断是否已为好友关系
     $ret = FriendModel::isFriend($user_id, $friend_id);
     if (!$ret) {
         $messageArr['error'] = "非好友关系!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "friend/update_fit_time");
     }
     $fitTime = FriendModel::fitFriend($user_id);
     foreach ($fitTime as $key => $value) {
         if ($value['n_id'] == $friend_id) {
             $time = $value['time'];
             $fit_num = $value['num'] + 1;
         }
     }
     $nowTime = time();
     //冷却时间未到,扣除金钱
     if ($time > $nowTime) {
         $price_type = array(1 => 'n_coin', 2 => 'n_diamond');
         $costInfo = FriendAction::getFitCostInfo($friend_id, $fit_num);
         $type = $price_type[$costInfo['price_type']];
         $price = $costInfo['price'];
         $money = UserCache::getByKey($user_id, $type);
         if (!$money) {
             $userInfo = FriendModel::getUserInfo($user_id);
             $money = $userInfo[$type];
         }
         $money = $money - $price;
         if ($money < 0) {
             $messageArr['error'] = "人生果/钻石不足!";
             $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
             $view = new JsonView();
             return $this->getViewByJson($view, $messageArr, 0, "friend/update_fit_time");
         }
         $ret = CharacterModel::update(array($type => $money), array('n_id' => $user_id));
         FriendModel::updateFitNum($user_id, $friend_id);
         UserCache::setByKey($user_id, $type, $money);
     } else {
         $ret = FriendModel::fitTime($user_id, $friend_id);
     }
     //任务成就统计
     TaskAndAchieveAction::taskStatistic($user_id, array('friend_help' => 1));
     TaskAndAchieveAction::achieveStatistic($user_id, array('friend_help' => 1));
     $friendInfo = FriendModel::getUserInfo($friend_id);
     $messageArr = CharacterAction::getFitBattleInfo($user_id, $friendInfo['n_battle']);
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "friend/update_fit_time");
 }
Ejemplo n.º 2
0
 /**
  * API:获取好友排行
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function getFriendRank($user_id)
 {
     // 好友列表加入缓存后此处需要修改
     $friendList = FriendAction::getFriend($user_id);
     if ($friendList && count($friendList)) {
         foreach ($friendList as $key => $value) {
             $userInfo = UserCache::getAllUserCache($value);
             if (!$userInfo['n_id'] || !$userInfo['n_head'] || !$userInfo['s_name'] || !$userInfo['n_sex'] || !$userInfo['n_level'] || !$userInfo['n_max_checkpoint']) {
                 $userInfo = UserAction::iniUserInfo($value);
             }
             $rankInfo['id'] = $userInfo['n_id'];
             $rankInfo['head'] = $userInfo['n_head'];
             $rankInfo['name'] = $userInfo['s_name'];
             $rankInfo['sex'] = $userInfo['n_sex'];
             $rankInfo['level'] = $userInfo['n_level'];
             $rankInfo['checkpoint'] = $userInfo['n_max_checkpoint'];
             $rankInfo['battle'] = $userInfo['n_battle'];
             $FriendRankInfo[] = $rankInfo;
         }
     }
     $userInfo = UserCache::getAllUserCache($user_id);
     if (!$userInfo) {
         $userInfo = UserAction::iniUserInfo($user_id);
     }
     $rankInfo['id'] = $userInfo['n_id'];
     $rankInfo['head'] = $userInfo['n_head'];
     $rankInfo['name'] = $userInfo['s_name'];
     $rankInfo['sex'] = $userInfo['n_sex'];
     $rankInfo['level'] = $userInfo['n_level'];
     $rankInfo['checkpoint'] = $userInfo['n_max_checkpoint'];
     $rankInfo['battle'] = $userInfo['n_battle'];
     $FriendRankInfo[] = $rankInfo;
     return $FriendRankInfo;
 }
Ejemplo n.º 3
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;
 }