コード例 #1
0
ファイル: DefaultFilter.class.php プロジェクト: YYLP/y_game
 /**
  *
  * 执行默认检查方法
  *
  * @access public
  * @param 无
  * @return void
  */
 public function execute($request)
 {
     Logger::debug('----- ' . __CLASS__ . ' is started -----');
     // 验证 SessionKey
     $user_id = $request->getRequestParameter(Constants::PARAM_USER_ID);
     $clientSendKey = $request->getRequestParameter(Constants::PARAM_SESSION_KEY);
     //$userCache = UserCache::getCacheInstance();
     //$serverSaveKey = $userCache->getByKey( $user_id, Constants::CURRENT_SESSION_KEY);
     $serverSaveKey = UserCache::getByKey($user_id, Constants::CURRENT_SESSION_KEY);
     if ($serverSaveKey !== $clientSendKey && $clientSendKey != 0) {
         Logger::debug('Stopping ' . __CLASS__ . '. caused by: Invalid session key.');
         Logger::debug('server save session key: ', $serverSaveKey);
         Logger::debug('client send session key: ', $clientSendKey);
         $view = new JsonView();
         $view->setValue('result', Constants::RESP_RESULT_ERROR);
         $view->setValue('message', "session key not match");
         $view->display();
         throw new ForbiddenException("userid:{$user_id} send Session Key not match.");
     }
     Logger::debug(__CLASS__ . ' is success.');
     Logger::debug('----- ' . __CLASS__ . ' is finished -----');
 }
コード例 #2
0
ファイル: MailAction.class.php プロジェクト: YYLP/y_game
 /**
  * 结算发送合体奖励邮件
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function sendFitMail($user_id, $friend_id)
 {
     $user_name = UserCache::getByKey($user_id, "s_name");
     if (!$friend_id) {
         $userInfo = MailModel::getUserInfo($user_id);
         $user_name = $userInfo['s_name'];
     }
     $type = Constants::FIT_REWARD_TYPE;
     $coin = Constants::FIT_REWARD_NUM;
     $str = "你的好友" . $user_name . "邀你助战,你获得人生果" . $coin;
     $res = MailModel::insert(array('n_send_id' => $user_id, 'n_receive_id' => $friend_id, 's_message' => $str, 'n_item_type' => $type, 'n_item_num' => $coin, 'n_type' => 1, 't_update_time' => date("Y-m-d H:i:s"), 't_create_time' => date("Y-m-d H:i:s")));
 }
コード例 #3
0
 /**
  * API:成就统计
  *
  * @access public
  * @param int $user_id 用户ID
  * @return array
  */
 public function achieveStatistic($user_id, $dataArr)
 {
     $pointArr = array(6 => 1, 12 => 2, 22 => 3, 30 => 4);
     $userAchieve = UserCache::getByKey($user_id, self::ACHIEVEMENT_STRING);
     if (!$userAchieve) {
         $userAchieve = TaskAchieveModel::getUserInfoByCondition($user_id, self::ACHIEVEMENT_STRING);
         UserCache::setByKey($user_id, self::ACHIEVEMENT_STRING, $userAchieve);
     }
     foreach ($userAchieve as $key => $value) {
         $str = "achievement_id = " . $key . "_" . ($userAchieve[$key]['n_level'] + 1);
         $file = IniFileManager::getRootDir() . "/files/csv/achievement.csv";
         $achieveInfo = CharacterAction::readCsv($file, $str);
         if ($userAchieve[$key]['n_level'] < $userAchieve[$key]['max_level'] && $userAchieve[$key]['n_num'] < $achieveInfo[0]['condition']) {
             //1
             if ($dataArr['friend_help'] == 1 && $key == 1) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['friend_help'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //2
             if ($dataArr['login_day'] == 1 && $key == 2) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['login_day'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //3
             if ($dataArr['monster'] && $key == 3) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['monster'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //4
             if ($dataArr['star_num'] && $key == 4) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['star_num'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //5
             if ($dataArr['pro_num'] && $key == 5) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['pro_num'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //6
             if (($dataArr['pass'] === 0 || $dataArr['pass'] === 1) && $key == 6) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //7
             if ($dataArr['away'] === 0 && $dataArr['attack'] === 0 && $key == 7) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //8
             if ($dataArr['skill_num'] && $key == 8) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['skill_num'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //9
             if ($dataArr['cost'] && $key == 9) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['cost'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //11
             if ($dataArr['pass'] === 0 && $key == 11) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //12
             if ($dataArr['soul'] && $key == 12) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['soul'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //15
             if ($dataArr['check_point_id'] == 1 && $dataArr['pass'] == 1 && $key == 15) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
         }
         if ($userAchieve[$key]['n_level'] < $userAchieve[$key]['max_level']) {
             //10
             if ($dataArr['pass'] == 1 && $pointArr[$dataArr['check_point_id']] > $userAchieve[$key]['n_num'] && $key == 10) {
                 if ($value['n_level'] < Constants::CHAPTER_NUM) {
                     $totalNum = $userAchieve[$key]['n_num'] + 1;
                     // if ($totalNum>=$achieveInfo[0]['condition'])
                     // {
                     //     $totalNum=$achieveInfo[0]['condition'];
                     // }
                     $userAchieve[$key]['n_num'] = $totalNum;
                 }
             }
             //13
             if ($dataArr['generl_full'] && $key == 13) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['generl_full'];
                 // if ($totalNum>=$achieveInfo[0]['condition'])
                 // {
                 //     $totalNum=$achieveInfo[0]['condition'];
                 // }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //14
             if ($dataArr['update_times'] && $key == 14) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['update_times'];
                 // if ($totalNum>=$achieveInfo[0]['condition'])
                 // {
                 //     $totalNum=$achieveInfo[0]['condition'];
                 // }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
         }
     }
     $s_achievement_info = serialize($userAchieve);
     $res = TaskAchieveModel::update(array('s_achievement_info' => $s_achievement_info), array('n_id' => $user_id));
     UserCache::setByKey($user_id, self::ACHIEVEMENT_STRING, $userAchieve);
 }
コード例 #4
0
ファイル: BuyPropAction.class.php プロジェクト: YYLP/y_game
 /**
  * API:购买商城物品
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeBuyMall()
 {
     $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'];
     $mall_id = $requestJsonParam['mall_id'];
     $session_key = $requestParam['session_key'];
     $str = "mall_id = " . $mall_id;
     $file = IniFileManager::getRootDir() . "/files/csv/mall.csv";
     $itemInfo = CharacterAction::readCsv($file, $str);
     $price_type = self::$price_type;
     //余额判断
     $type1 = $price_type[$itemInfo[0]['price_type']];
     $type2 = $price_type[$itemInfo[0]['buy_type']];
     $money1 = UserCache::getByKey($user_id, $type1);
     $money2 = UserCache::getByKey($user_id, $type2);
     if (!$money1) {
         $userInfo = BuyPropModel::getUserInfo($user_id);
         $money1 = $userInfo[$type1];
     }
     if (!$money2) {
         $userInfo = BuyPropModel::getUserInfo($user_id);
         $money2 = $userInfo[$type2];
     }
     $money1 = $money1 - $itemInfo[0]['price_num'];
     $money2 = $money2 + $itemInfo[0]['buy_num'];
     if ($money1 < 0) {
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $messageArr['error'] = "人生果/钻石不足!";
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "buy_prop/buy_mall");
     }
     //任务成就统计
     if ($type2 == $price_type[1]) {
         TaskAndAchieveAction::taskStatistic($user_id, array('reward' => $itemInfo[0]['buy_num']));
     }
     if ($type1 == $price_type[1]) {
         TaskAndAchieveAction::achieveStatistic($user_id, array('cost' => $itemInfo[0]['price_num']));
     }
     //购买体力是更新体力时间
     if ($type2 == $price_type[3]) {
         $thewArr['n_thew'] = $money2;
         $thewArr['n_refresh_time'] = UserCache::getBykey($user_id, 'n_refresh_time');
         if (!$thewArr['n_refresh_time']) {
             $userInfo = MailModel::getUserInfo($user_id);
             $thewArr['n_refresh_time'] = $userInfo['n_refresh_time'];
         }
         $getArr = UserAction::refreshThew($thewArr);
         if (!$getArr) {
             $res = CharacterModel::update($thewArr, array('n_id' => $user_id));
             UserCache::setByKey($user_id, 'n_thew', $thewArr['n_thew']);
             UserCache::setByKey($user_id, 'n_refresh_time', $thewArr['n_refresh_time']);
         } else {
             $res = CharacterModel::update($getArr, array('n_id' => $user_id));
             UserCache::setByKey($user_id, 'n_thew', $getArr['n_thew']);
             UserCache::setByKey($user_id, 'n_refresh_time', $getArr['n_refresh_time']);
         }
         $res = BuyPropModel::update(array($type1 => $money1), array('n_id' => $user_id));
         UserCache::setByKey($user_id, $type1, $money1);
     } else {
         $res = BuyPropModel::update(array($type1 => $money1, $type2 => $money2), array('n_id' => $user_id));
         UserCache::setByKey($user_id, $type1, $money1);
         UserCache::setByKey($user_id, $type2, $money2);
     }
     $messageArr['moneyInfo'] = BuyPropModel::getUserInfo($user_id);
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     //任务成就界面
     $messageArr['achieveInfo'] = TaskAndAchieveAction::getAchieveInfo($user_id);
     $messageArr['taskInfo'] = TaskAndAchieveAction::getTaskInfo($user_id);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "buy_prop/buy_mall");
 }
コード例 #5
0
ファイル: FriendAction.class.php プロジェクト: YYLP/y_game
 /**
  * 好友列表
  *
  * @access public
  * @param 无
  * @return arrary
  */
 public function getFriend($user_id)
 {
     $str = $user_id . '_friend';
     $friendList = UserCache::getByKey($str, 'friend_list');
     if (!$friendList) {
         $friendInfo = FriendModel::getFriendList($user_id);
         foreach ($friendInfo as $key => $value) {
             $friendList[] = $value['n_id'];
         }
         UserCache::setByKey($str, 'friend_list', $friendList);
     }
     return $friendList;
 }
コード例 #6
0
ファイル: GameAction.class.php プロジェクト: YYLP/y_game
 /**
  * API:获取星星数
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function getUserStar($user_id)
 {
     $userCheckPoint = UserCache::getByKey($user_id, 's_checkpoint_info');
     if (!$userCheckPoint) {
         $userInfo = UserModel::getUserInfo($user_id);
         $userCheckPoint = unserialize($userInfo['s_checkpoint_info']);
     }
     $star_num = 0;
     if ($userCheckPoint && count($userCheckPoint)) {
         foreach ($userCheckPoint as $key => $value) {
             $star_num = $value['star_num'] + $star_num;
         }
     }
     return $star_num;
 }
コード例 #7
0
ファイル: CharacterAction.class.php プロジェクト: YYLP/y_game
 /**
  * API:获取当前上阵主角信息
  *
  * @access public
  * @param $integer $user_id $general_id 用户ID,武将ID
  * @return array 
  */
 public function nowCharacterInfo($user_id)
 {
     $userCharacter = UserCache::getByKey($user_id, self::CHARACTER_STRING);
     if (!$userCharacter) {
         $userCharacter = CharacterModel::getUserCharacterInfo($user_id);
         UserCache::setByKey($user_id, self::CHARACTER_STRING, $userCharacter);
     }
     return self::GetCharacterAttribute($user_id, $userCharacter[0]);
 }
コード例 #8
0
ファイル: GeneralAction.class.php プロジェクト: YYLP/y_game
 /**
  * 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;
 }