Ejemplo n.º 1
0
 /**
  *获取PVP记录汇总
  */
 public function getPvpSummaryAction()
 {
     //基础元素,必须参与验证
     $User['UserId'] = abs(intval($this->request->UserId));
     $User['ServerId'] = $this->request->ServerId;
     $User['HeroId'] = intval($this->request->HeroId) ? intval($this->request->HeroId) : -1;
     $User['SlkId'] = abs(intval($this->request->SlkId));
     $User['Time'] = abs(intval($this->request->Time));
     $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2;
     //URL验证码
     $sign = $this->request->sign;
     //私钥,以后要移开到数据库存储
     $p_sign = 'lm';
     $sign_to_check = base_common::check_sign($User, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证用户名有效性
         if ($User['UserId']) {
             //验证时间戳,时差超过600秒即认为非法
             if (abs($User['Time'] - time()) <= 600) {
                 //查询用户
                 $UserInfo = $this->oUser->GetUserById($User['UserId']);
                 if ($UserInfo['UserId']) {
                     //判断用户所选服务器大区是否存在
                     $ServerInfo = $this->oServer->getRow($User['ServerId']);
                     if ($ServerInfo['ServerId']) {
                         $oTask = new Lm_Task();
                         $PvpSummary = $oTask->getPvpSummary(0, 0, $UserInfo['UserId'], $User['SlkId'], $User['HeroId'], $User['ServerId'], 0, 0, ($User['Page'] - 1) * $User['PageSize'], $User['PageSize']);
                         if (count($PvpSummary['Won']) > 0) {
                             $PvpDetailList = $oTask->getPvpDetail(0, 0, $User['UserId'], 0, -1, $User['ServerId'], 0, 0, 0, 0);
                             foreach ($PvpDetailList['PvpDetail'] as $key => $value) {
                                 $Comment = json_decode($value['Comment'], true);
                                 $PvpSummary['AssistKing'] += $Comment['AssistKing'];
                                 $PvpSummary['DestroyKing'] += $Comment['DestroyKing'];
                                 $PvpSummary['Mvp'] += $Comment['Mvp'];
                                 $PvpSummary['KillKing'] += $Comment['KillKing'];
                                 $PvpSummary['Killing']['2'] += $Comment['Double'];
                                 $PvpSummary['Killing']['3'] += $Comment['Triple'];
                                 $PvpSummary['Killing']['4'] += $Comment['Four'];
                                 $PvpSummary['Killing']['5'] += $Comment['Five'];
                                 $PvpSummary['MaxKilling'] = max($PvpSummary['MaxKilling'], $value['KillNum']);
                                 $Log[count($Log) + 1] = array("Time" => $value['PvpEnterTime'], 'Won' => $value['Won']);
                             }
                             foreach ($Log as $k => $v) {
                                 if (!$Log[$k - 1]['Won'] && $v['Won']) {
                                     for ($i = $k; $i <= count($Log); $i++) {
                                         if ($Log[$i]['Won']) {
                                             $t[$v['Time']][] = $Log[$i]['Time'];
                                             $PvpSummary['ContinuousWon'] = max($PvpSummary['ContinuousWon'], count($t[$v['Time']]));
                                         } else {
                                             break;
                                         }
                                     }
                                 }
                             }
                             $PvpSummary['LastUpdateTime'] = $Log['1']['Time'];
                             $result = array('return' => 1, 'PvpSummary' => $PvpSummary);
                         } else {
                             $result = array('return' => 0, 'comment' => "无PVP记录");
                         }
                     } else {
                         $result = array('return' => 0, 'comment' => "您所选择的服务器不存在");
                     }
                 } else {
                     $result = array('return' => 2, 'comment' => "无此用户");
                 }
             } else {
                 $result = array('return' => 2, 'comment' => "时间有误");
             }
         } else {
             $result = array('return' => 0, 'comment' => "请指定用户");
         }
     } else {
         $result = array('return' => 2, 'comment' => "验证失败,请检查URL");
     }
     if ($User['ReturnType'] == 1) {
         echo json_encode($result);
     }
 }