瀏覽代碼

fixed: 挑战记录返回值结构.

gwang 5 年之前
父節點
當前提交
f9742545fd

+ 31 - 14
Gameserver/Amfphp/base/CmdCode.php

@@ -643,45 +643,62 @@ class CmdCode {
 
 
 //
-//      <editor-fold defaultstate="collapsed" desc="    PVP 挑战    ">
+//      <editor-fold defaultstate="collapsed" desc="    竞技场 681x  ">
 //
 
     /**
-     * pvp 主界面信息
+     *  竞技场 主界面信息
      */
     const cmd_fight_pvp_maininfo = 6810;
 
     /**
-     * pvp 挑战xx.
+     * 竞技场 刷新对手列表
      */
-    const cmd_fight_pvp_pk = 6811;
+    const cmd_fight_pvp_refresh = 6811;
 
     /**
-     * pvp 刷新对手列表
+     * 竞技场 挑战xx.
      */
-    const cmd_fight_pvp_refresh = 6812;
+    const cmd_fight_pvp_pk = 6812;
 
     /**
-     * pvp 体力充值
+     * 竞技场 调整阵容
      */
-    const cmd_fight_pvp_chargetili = 6813;
+    const cmd_fight_pvp_setTeam = 6813;
 
     /**
-     * pvp 拉取前100名榜单
+     * 竞技场 购买挑战票
      */
-    const cmd_fight_pvp_getrank = 6814;
+    const cmd_fight_pvp_buyTicket = 6814;
 
     /**
-     * pvp 拉取蝉联信息
+     * 竞技场 查看榜单
      */
-    const fight_pvp_getChanlianInfo = 6819;
+    const cmd_fight_pvp_getrank = 6815;
 
     /**
-     * pvp 领取活跃奖励
+     * 竞技场 查询战报
      */
-    const cmd_fight_pvp_drawactivereward = 6815;
+    const cmd_fight_pvp_getLog = 6816;
 
+    // <editor-fold defaultstate="collapsed" desc="   竞技商店  682x   ">
 
+    /**
+     * 竞技场 商店 主界面信息
+     */
+    const cmd_fight_pvpShop_getMainInfo = 6820;
+
+    /**
+     * 竞技场 商店 购买道具
+     */
+    const cmd_fight_pvpShop_buy = 6821;
+
+    /**
+     * 竞技场 商店 刷新道具
+     */
+    const cmd_fight_pvpShop_refresh = 6822;
+
+// </editor-fold>
 //
 // </editor-fold>
 //

+ 9 - 9
Gameserver/Amfphp/base/ErrCode.php

@@ -882,47 +882,47 @@ class ErrCode {
     const carbon_wrongdifficult = 4020;
 
     /**
-     * PVP - 指定的pvp对手不存在
+     * 竞技场 - 指定的pvp对手不存在
      */
     const pvp_wrongMather = 4021;
 
     /**
-     * pvp - 尚未达到免费刷新时间
+     * 竞技场 - 尚未达到免费刷新时间
      */
     const pvp_refresh_time = 4022;
 
     /**
-     * pvp - 错误的体力充值数量
+     * 竞技场 - 错误的体力充值数量
      */
     const pvp_tili_chargenum = 4023;
 
     /**
-     * pvp - 体力未有剩余就去挑战了.
+     * 竞技场 - 体力未有剩余就去挑战了.
      */
     const pvp_wrongtili = 4024;
 
     /**
-     * pvp - 刷新对手花费数据对不上.
+     * 竞技场 - 刷新对手花费数据对不上.
      */
     const pvp_refresh_cost_ilegal = 4030;
 
     /**
-     * pvp - 刷新对手已达次数上限
+     * 竞技场 - 刷新对手已达次数上限
      */
     const pvp_refresh_max = 4029;
 
     /**
-     * pvp - 体力购买, 跟预期的值对不上
+     * 竞技场 - 体力购买, 跟预期的值对不上
      */
     const pvp_tili_cost_ilegal = 4028;
 
     /**
-     * pvp - 当日体力购买已达上限
+     * 竞技场 - 当日体力购买已达上限
      */
     const pvp_tili_soldout = 4027;
 
     /**
-     * pvp - 活跃值不够
+     * 竞技场 - 活跃值不够
      */
     const pvp_activenotenough = 4026;
 

+ 42 - 58
Gameserver/Amfphp/base/MemKey_GameRun.php

@@ -69,76 +69,59 @@ class MemKey_GameRun {
         return "gamerun-sysmsg-zone$zoneid";
     }
 
-    // <editor-fold defaultstate="collapsed" desc="   PVP">
+    // <editor-fold defaultstate="collapsed" desc="   竞技场   "> 
 
     /**
-     * 运行时数据 - pvp蝉联信息
-     * @param int $zoneid
-     */
-    static function Game_PVP_Chanlian_normal($zoneid) {
-        return "gamerun-pvp-chanlian-zone$zoneid";
-    }
-
-    /**
-     * 运行时数据 - pvp蝉联历史冠军数据
-     * @param type $zoneid
-     * @return type
-     */
-    static function Game_PVP_Chanlian_History_hash($zoneid) {
-        return "gamerun-pvp-chanlian-history-zone$zoneid";
-    }
-
-    /**
-     * 运行时数据 - pvp实时积分榜(总榜)
-     * @param int $zoneid
-     * @return string
-     */
-    public static function Game_PVPScoreByZone_zset($zoneid) {
-        return "gamerun-pvpScore-zone$zoneid";
-    }
-
-    /**
-     * 运行时数据 - pvp实时积分榜(当前)
-     * 当前和上周都是作为总榜的记录存在,
-     * @param int $zoneid
-     * @return string
-     */
-    public static function Game_PVPScoreByZone_zset_curWeek($zoneid) {
-        $week = TimeUtil::tsWeek();
-        return "gamerun-pvpScore-zone$zoneid-$week";
-    }
-
-    /**
-     * 运行时数据 - pvp积分榜(上周)
-     * 当前和上周都是作为总榜的记录存在,
-     * @param int $zoneid
-     * @return string
-     */
-    public static function Game_PVPScoreByZone_zset_lastWeek($zoneid) {
-        $week = TimeUtil::tsWeek() - 1;
-        return "gamerun-pvpScore-zone$zoneid-$week";
-    }
-
-    /**
-     * 运行时数据 - pvp 每周排行榜发放记录 [tsweek,...]
-     * @param int $zoneid
+     * 运行时数据 - 竞技场 实时积分榜(总榜)
+     * @param int $zoneid 分区id
+     * @param int $season 赛季
      * @return string
      */
-    public static function Game_PVPRankRewardRecord_set($zoneid) {
-        return "gamerun-pvpRewardRecord-zone$zoneid";
+    public static function Game_PVPScoreByZoneSeason_zset($zoneid, $season) {
+        return "gamerun-pvpScore-zone$zoneid-season$season";
     }
 
     /**
-     * 运行时数据 - pvp 每周领取排行榜奖励的玩家记录 [tsweek,...]
+     * 运行时数据 - 竞技场 积分榜(某天)
+     * 业务逻辑: 查询下昨天的榜, 根据榜单发放奖励
      * @param int $zoneid
-     * @param int $tsweek Description
+     * @param int $day 天
      * @return string
      */
-    public static function Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek) {
-        return "gamerun-pvpRewardRecord-zone$zoneid-$tsweek";
+    public static function Game_PVPScoreByZone_zset_Day($zoneid, $day) {
+        return "gamerun-pvpScore-zone$zoneid-day$day";
     }
 
-// </editor-fold>
+//    /**
+//     * 运行时数据 - pvp积分榜(上周)
+//     * 当前和上周都是作为总榜的记录存在,
+//     * @param int $zoneid
+//     * @return string
+//     */
+//    public static function Game_PVPScoreByZone_zset_lastWeek($zoneid) {
+//        $week = TimeUtil::tsWeek() - 1;
+//        return "gamerun-pvpScore-zone$zoneid-$week";
+//    }
+//    /**
+//     * 运行时数据 - pvp 每周排行榜发放记录 [tsweek,...]
+//     * @param int $zoneid
+//     * @return string
+//     */
+//    public static function Game_PVPRankRewardRecord_set($zoneid) {
+//        return "gamerun-pvpRewardRecord-zone$zoneid";
+//    }
+//
+//    /**
+//     * 运行时数据 - pvp 每周领取排行榜奖励的玩家记录 [tsweek,...]
+//     * @param int $zoneid
+//     * @param int $tsweek Description
+//     * @return string
+//     */
+//    public static function Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek) {
+//        return "gamerun-pvpRewardRecord-zone$zoneid-$tsweek";
+//    }
+    // </editor-fold>
+    // 
     // <editor-fold defaultstate="collapsed" desc=" 排行榜相关 ">
     // 
 
@@ -191,6 +174,7 @@ class MemKey_GameRun {
     }
 
 // </editor-fold>
+    //
 
     /**
      * 运行时数据 - 每天的登录用户记录-byUId

+ 20 - 0
Gameserver/Amfphp/base/MemKey_User.php

@@ -84,6 +84,7 @@ class MemKey_User {
      * 主动挑战记录
      * @param type $zoneid
      * @param type $uid
+     * 
      */
     public static function OffensiveLog_zset($zoneid, $uid) {
         return self::Key_($zoneid, $uid) . (self::bUseShort() ? '-offlog' : '-offensivelog');
@@ -99,6 +100,25 @@ class MemKey_User {
         return self::Key_($zoneid, $uid) . (self::bUseShort() ? '-deflog' : '-defensivelog');
     }
 
+    /**
+     *  竞技场 主动挑战记录
+     * @param type $zoneid
+     * @param type $uid
+     */
+    public static function PVP_OffensiveLog_zset($zoneid, $uid) {
+        return self::Key_($zoneid, $uid) . "-pvp" . (self::bUseShort() ? '-offlog' : '-offensivelog');
+    }
+
+    /**
+     * 竞技场 被动挑战记录
+     * @param type $zoneid
+     * @param type $uid
+     * @return type
+     */
+    public static function PVP_DefensiveLog_zset($zoneid, $uid) {
+        return self::Key_($zoneid, $uid) . "-pvp" . (self::bUseShort() ? '-deflog' : '-defensivelog');
+    }
+
     /**
      * 玩家证书
      * @param int $zoneid 分区id

+ 2 - 0
Gameserver/Amfphp/configs/GameConstants.php

@@ -9,6 +9,7 @@ namespace loyalsoft;
  * @copyright © 2015-3-9, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  */
 class GameConstants {
+    // <editor-fold defaultstate="collapsed" desc="    兑换码相关   ">
 
     /**
      * @var string 全平台后缀字符串
@@ -69,6 +70,7 @@ class GameConstants {
         "yile_yj", #                                                            # 18 以乐易接
     );
 
+// </editor-fold>
 }
 
 //                                                                            <=> 元数据定义 <=>

+ 96 - 0
Gameserver/Amfphp/model/User/UserBaseInfo.php

@@ -0,0 +1,96 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace loyalsoft;
+
+/**
+ * Description of UserBaseInfo
+ *
+ * @author Administrator
+ */
+class UserBaseInfo {
+    //put your code here
+
+    /**
+     * 第一次登录时间
+     * @var int
+     */
+    public $firstLogin;
+
+    /**
+     * 上次登录时间
+     * @var int
+     */
+    public $lastLogin;
+
+    /**
+     * 上次活动时间
+     * @var int
+     */
+    public $lastSaveTs;
+
+    /**
+     * @var int 当前等级
+     */
+    public $level;  //
+
+    /**
+     * @var string 昵称
+     */
+    public $name; // 昵称
+
+    /**
+     * @var string 头像
+     */
+    public $img;  // 头像
+
+    /**
+     * @var int 头像框Id
+     */
+    public $imgBorderId = 0;
+
+    /**
+     * @var int 金币
+     */
+    public $gold;  // 金币
+
+    /**
+     * 钻石
+     * @var int
+     */
+    public $cash; //
+
+    /**
+     * 分解后得倒的晶石
+     * @var int
+     */
+    public $spar;
+
+    /**
+     * 体力值
+     * @var int
+     */
+    public $tili = 120; //体力
+
+    /**
+     * 当前经验
+     */
+    public $xp = 0;
+
+    /**
+     * 升级经验
+     * @var type
+     */
+    public $maxXp = 0;
+
+    /**
+     * @var int 好友赠送友情点数
+     */
+    public $friendPoint = 0;
+
+}

+ 8 - 12
Gameserver/Amfphp/model/User/UserGuildModel.php

@@ -13,12 +13,10 @@ namespace loyalsoft;
  *
  * @author cyzhao
  */
-class UserGuildModel
-{
+class UserGuildModel {
 
     //put your code here
-    public static function Clear()
-    {
+    public static function Clear() {
         $userGuildinfo = new UserGuildModel();
         $userGuildinfo->ts = now();
         $userGuildinfo->joints = now(); //玩家公会的创建时间
@@ -43,8 +41,7 @@ class UserGuildModel
      * 检查玩家每日需要清理的状态
      * @param UserGuildModel $userGuildInfo
      */
-    static function checkFirstlog($userGuildInfo)
-    {
+    static function checkFirstlog($userGuildInfo) {
         #每天清理
         if (TimeUtil::tsDay() > TimeUtil::tsDay($userGuildInfo->ts)) {
             $userGuildInfo->allDonateCount = 0;
@@ -67,18 +64,17 @@ class UserGuildModel
      * @param type $guildId
      * @param type $zoneid
      */
-    static function userGuildInfoInit($userGuildInfo, $uid, $game, $mem, $zoneid)
-    {
+    static function userGuildInfoInit($userGuildInfo, $uid, $game, $mem, $zoneid) {
         #self::Clear();
         $userGuildInfo->ts = now();
 //        if ($guildId != 0) {
 //            $guildInfo = GuildProc::getMemGuildInfo($mem, $guildId, $zoneid);
 //            $userGuildInfo->guildName = $guildInfo->name;
 //        }
-        $key_cur = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);   # 总积分榜
-        $score = $mem->zscore($key_cur, $uid);
-        $cupScore = $score == null ? 0 : $score;
-        $userGuildInfo->cupScore = $cupScore;
+//        $key_cur = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);   # 总积分榜
+//        $score = $mem->zscore($key_cur, $uid);
+//        $cupScore = $score == null ? 0 : $score;
+//        $userGuildInfo->cupScore = $cupScore;
         $userGuildInfo->name = $game->name;
         $userGuildInfo->level = $game->level;
         //$userGuildInfo->fightPower = GuildProc::initFightTeamInfo($mem, $uid, $zoneid); #$game->heroTeamConfig;

+ 45 - 49
Gameserver/Amfphp/model/User/UserPVPModel.php

@@ -3,98 +3,94 @@
 namespace loyalsoft;
 
 /**
- *  extends Object
+ *  玩家竞技场数据
  * @version
+ *          2.0.0 改自原PVP数据(内容基本全换). 2020.5.7 -- gwang
  *          1.0.0 Created at 2017-7-4. by --gwang
  * @author gwang (mail@wanggangzero.cn)
  * @copyright ? 2017-7-4, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  */
-class UserPVPModel extends Object_ext
-{
+class UserPVPModel extends Object_ext {
 
     /**
-     * 当前阶段,1~32
-     * @var int 所处阶段
+     * @var array[string] 每日/当天已挑战对手记录(有想法设定尽量不重复当天已经刷到过的对手)
      */
-    public $leagueId = 1;
-
-    /**
-     * @var ts 体力时间戳
-     */
-    public $tiliTs = 0;
-
-    /**
-     * @var int 体力溢出值,ugly
-     */
-    public $tiliExtra = 0;
+    public $dailyMatchRecord = array();
 
     /**
-     * @var ts 挑战对手,下次刷新时间
+     * @var object 防守阵容 
      */
-    public $nextRefreshTs = 0;
+    public $defTeam;
 
     /**
-     * @var int 获胜次数(每周清零)
+     * @var int 竞技币
      */
-    public $winTimes = 0;
+    public $pvpCoins = 0;
 
     /**
-     * @var int 总挑战次数(每周清零)
+     * @var int 竞技场挑战票 
      */
-    public $totalTimes = 0;
+    public $fightTicket = 0;
 
     /**
-     * @var int 连胜次数(每周清零)
+     * @var 下次刷新时间
      */
-    public $contWin = 0;
+    public $fightTicketRefreshTs = 0;
 
     /**
-     * @var int 活跃值
+     * @var int 每天有3次免费挑战次数,每天8天重置 
      */
-    public $actives = 0;
+    public $freeFightTickets = 0;
 
     /**
-     * @var int 每日/当日挑战计数
+     * @var int 挑战记录最后拉取时间戳(晚于此时间戳的记录为新记录,显示小红点)
      */
-    public $dailyPkCnt = 0;
+    public $tsFightLog = 0;
 
     /**
-     *
-     * @var int 每日/当日购买体力次数
+     * @var type 当前竞技商店内道具列表(子结构可以记录售罄状态)
      */
-    public $dailyBuyTiliTimes = 0;
+    public $curShopItems;
 
     /**
-     *
-     * @var int 每日/当日刷新对手次数
+     * @var int 商店下次刷新的时间戳(24小时自动刷新, 提前刷新扣钻)
      */
-    public $dailyRefreshMatchTimes = 0;
+    public $shopRefreshTs = 0;
 
     /**
-     * @var array[string] 每日/当天已挑战对手记录
+     * @var 今日未发放奖励(tsDay < today =>发放奖励并同步到today)
      */
-    public $dailyMatchRecord = array();
+    public $haventReward_tsDay = 0;
 
     /**
-     * @var int pvp币
+     * @var 赛季未发放奖励(seasonId < curSeason =>发放奖励并同步到curSeason)
      */
-    public $pvpCoins = 0;
+    public $haventReward_season = 0;
 
     /**
-     * @var array 每周结算奖励领取记录
+     * 刷新竞技商店道具列表
      */
-    public $weeklyRewardRecords = array();
+    public function refreshShopItem() {
+        if ($this->shopRefreshTs <= now()) {                                       # 刷新ts<now(), 该刷新了
+            // ...            
+        }
+    }
 
-    /**
-     * @var asoc_array 当前匹配对手列表
-     */
-    public $curMatches;
+    public function refreshDailyData() {
+        // 刷新免费挑战次数
+        if (tsDay($this->fightTicketRefreshTs) <= tsDay()) {                    # 刷新时间<=今天,该刷新了
+            $this->freeFightTickets = 3;                                        # 重置为3, 此处的3可以改为读取配置数据
+            $this->fightTicketRefreshTs = now() + 86400;                        # 刷新时间设置为明天 
+        }
+        // 刷新商店道具列表
+        $this->refreshShowItem();
+    }
 
-    public function clearWeekData()
-    {
-        $this->totalTimes = 0;
-        $this->winTimes = 0;
-        $this->contWin = 0;
+    public function __construct($arg) {
+        parent::__construct($arg);
+        if (null == $this->defTeam) {
+            $this->defTeam = JsonUtil::decode('{"heros":[]}');
+        }
     }
 
 }

+ 26 - 19
Gameserver/Amfphp/process/FightProc.php

@@ -22,34 +22,41 @@ class FightProc {
             case CmdCode::cmd_fight_arenasfight:                                # 6801 挑战关卡
                 return SweepGatesProc::Arenas_Fight($req);
             case CmdCode::cmd_fight_arenassweep:                                # [6802] 扫荡
-                return Resp::err(ErrCode::function_notopen_msg);                # 暂未开放扫荡功能. -gwang 2020.4.20
+                Err(ErrCode::function_notopen_msg);                            # 暂未开放扫荡功能. -gwang 2020.4.20
                 return SweepGatesProc::Arenas_NewSweepFight($req);
 
-            # 玩家-挑战    
+            // <editor-fold defaultstate="collapsed" desc="    玩家挑战    "> 
             case CmdCode::cmd_fight_GetChallengeAdversaryInfo:                  # 6803 获取挑战对手的信息
                 return PVPProc::GetChallengeAdversaryInfo($req);
             case CmdCode::cmd_fight_LogChallengeResult:                         # 6804 记录挑战结果
                 return PVPProc::LogChallengeInfo($req);
             case CmdCode::cmd_fight_GetChallengeLog:                            # 6805 拉取挑战记录
                 return PVPProc::GetChagllengeLog($req);
-// <editor-fold defaultstate="collapsed" desc=" PVP 模块 ">
-//            case CmdCode::cmd_fight_pvp_maininfo:                               # [6810] pvp 主界面拉取信息
-//                return PVPProc::pvpMainInfo($req);
-//            case CmdCode::cmd_fight_pvp_pk:                                     # [6811] pvp 挑战对手
-//                return PVPProc::pvp_PK($req);
-//            case CmdCode::cmd_fight_pvp_refresh:                                # [6812] pvp 刷新对手
-//                return PVPProc::pvp_Refresh($req);
-//            case CmdCode::cmd_fight_pvp_chargetili:                             # [6813] pvp 补充体力
-//                return PVPProc::pvp_buytili($req);
-////                return PVPProc::pvp_recharegetili($req);
-//            case CmdCode::cmd_fight_pvp_getrank:                                # [6814] pvp 拉取前100名,排行榜
-//                return PVPProc::pvp_getRank($req);
-//            case CmdCode::cmd_fight_pvp_drawactivereward:                       # [6815] pvp 领取活跃度奖励
-//                return PVPProc::pvp_drawacitverewards($req);
-//            case CmdCode::fight_pvp_getChanlianInfo:                            # [6819] pvp 拉取蝉联信息
-//                return PVPProc::getChanlianINfo($req);
 // </editor-fold>
-
+            //  <editor-fold defaultstate="collapsed" desc="   PVP 模块 681x ">
+            case CmdCode::cmd_fight_pvp_maininfo:                               # [6810] 竞技场 主界面拉取信息
+                return PVPProc::pvpMainInfo($req);
+            case CmdCode::cmd_fight_pvp_refresh:                                # [6811] 竞技场 刷新对手列表
+                return PVPProc::pvp_Refresh($req);
+            case CmdCode::cmd_fight_pvp_pk:                                     # [6812] 竞技场 挑战对手
+                return PVPProc::pvp_PK($req);
+            case CmdCode::cmd_fight_pvp_setTeam:                                # [6813] 竞技场 设定防守队伍
+                return PVPProc::pvp_setTeam($req);
+            case CmdCode::cmd_fight_pvp_buyTicket:                              # [6814] 竞技场 购买挑战票
+                return PVPProc::pvp_buyticket($req);
+            case CmdCode::cmd_fight_pvp_getrank:                                # [6815] 竞技场 查看排行榜
+                return PVPProc::pvp_getRank($req);
+            case CmdCode::cmd_fight_pvp_getLog:                                 # [6816] 竞技场 查看挑战记录
+                return PVPProc::pvp_getFightLogs($req);
+// </editor-fold>
+            // <editor-fold defaultstate="collapsed" desc="   竞技商店 682x  ">
+            case CmdCode::cmd_fight_pvpShop_getMainInfo:                        # [6820] 竞技场 竞技商店主界面
+                return PVPProc::pvpShopMain($req);
+            case CmdCode::cmd_fight_pvpShop_buy:                                # [6821] 竞技场 竞技商店购买道具
+                return PVPProc::pvpShopBuy($req);
+            case CmdCode::cmd_fight_pvpShop_refresh:                            # [6822] 竞技场 竞技商店刷新道具(扣钻)
+                return PVPProc::pvpShopRefresh($req);
+            // </editor-fold>
             default:
                 return Resp::err(ErrCode::cmd_err);
         }

+ 656 - 510
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -3,13 +3,47 @@
 namespace loyalsoft;
 
 /**
- *  PVPProc pvp 战斗模块, 挑战玩家镜像
+ *  PVPProc 竞技场 战斗模块, 挑战玩家镜像
  * @version
  *          1.0.0 Created at 2017-6-26. by --gwang
  * @author gwang (mail@wanggangzero.cn)
  * @copyright ? 2017-6-26, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  */
 class PVPProc {
+    //
+    // <editor-fold defaultstate="collapsed" desc="    常量    ">
+
+    /**
+     * 挑战记录最大条数
+     */
+    const maxLogCount = 49;
+
+    /**
+     * 查找对手数量
+     */
+    const matchCount = 5;
+
+    /**
+     * 竞技场赛季起始时间戳
+     */
+    const pvpStartTs = 1588521600;                                              # 2020年5月4日 0时0分0秒
+
+    /**
+     * 每个赛季持续时常
+     */
+    const pvpSeasonLengt = 86400 * 14;                                          # 2周
+
+    /**
+     * 竞技场初始积分
+     */
+    const pvpBaseScore = 1000;
+
+    /**
+     * 竞技场 最大上榜人数
+     */
+    const pvpMaxRank = 500;
+
+// </editor-fold>
 
     /**
      * [6803] 挑战 - 查询对手信息 等级、头像、昵称、战队信息(言灵师,等级,星级,武器,技能,言灵)
@@ -51,8 +85,6 @@ class PVPProc {
         return Resp::ok($result);
     }
 
-    const maxLogCount = 49;
-
     /**
      * [6804] 挑战 - 记录挑战结果
      * @param req $req
@@ -65,11 +97,11 @@ class PVPProc {
         $ts = now();                                                            # 记录时间戳
         $req->mem->zadd($key_mine, array(#                                      # 组装被挑战对手信息
             JsonUtil::encode(array(
-                'uid' => $targetUID,
-                'name' => $name,
-                'headImg' => $headImg,
-                'win' => $win,
-                'msg' => $msg,
+                'uid' => my_null_default($targetUID, "-"),
+                'name' => my_null_default($name, ""),
+                'headImg' => my_null_default($headImg, ""),
+                'win' => my_null_default($win, false),
+                'msg' => my_null_default($msg, ""),
                 'ts' => $ts
             )) => $ts));
         $req->mem->zremrangebyrank($key_mine, self::maxLogCount, -1);           # 保留50条数据
@@ -78,8 +110,8 @@ class PVPProc {
                 'uid' => $req->uid,
                 'name' => $req->userInfo->game->name,
                 'headImg' => $req->userInfo->game->img,
-                'win' => !$win,
-                'msg' => $msg,
+                'win' => !my_null_default($win, false),
+                'msg' => my_null_default($msg, ""),
                 'ts' => $ts
             )) => $ts));
         $req->mem->zremrangebyrank($key_target, self::maxLogCount, -1);         # 保留50条数据
@@ -107,172 +139,334 @@ class PVPProc {
         UserProc::updateUserInfo();                                             # 回写数据
         // 记录拉取时间戳(在主界面有个未读消息条数显示, 需要靠最后拉取时间戳对比, 时间戳之后的消息是未读消息)
         // 回传数据记录
+        array_walk($offLog, function (&$i) {
+            $i = JsonUtil::decode($i);
+        });
+        array_walk($defLog, function (&$i) {
+            $i = JsonUtil::decode($i);
+        });
         return Resp::ok(array(
                     'offLog' => $offLog,
                     'defLog' => $defLog
         ));
     }
 
+    // <editor-fold defaultstate="collapsed" desc="   竞技场   681x">
+    // 
+
+    /**
+     * 取当前赛季的编号(从赛季起始开始算起)
+     * @return int 
+     */
+    public static function GetCurSeasonID() {
+        $n = ceil((now() - self::pvpStartTs ) / self::pvpSeasonLengt);          # 进一取整
+        return $n;
+    }
+
+    /**
+     * 取指定赛季的结束时间戳
+     * @param int $seasonID
+     * @return int 
+     */
+    public static function GetSeasonEndTs($seasonID) {
+        $ts = self::pvpStartTs + $seasonID * self::pvpSeasonLengt;              # 从起始点开始 + n个赛季时常
+        return $ts;
+    }
+
+    /**
+     * [6810] 竞技场 拉取主界面信息
+     * @param Req $req
+     */
+    static function pvpMainInfo($req) {
+        $uid = $req->uid;                                                       # 快速访问UID
+        $zoneid = $req->zoneid;                                                 # 快速访问zoneid
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # 设计玩家pvp数据结构
+        $seasonId = self::GetCurSeasonID();                                     # 当前赛季ID
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
+        // 玩家数据
+        // 积分 + 排名
+        // 总战力
+        // 战报小红点
+        // 对手列表
+        // =======
+        // 检查昨日奖励是否发放
+        // 检查赛季奖励是否发放
+        // 返回
+        $score = self::_getScore_by_uid($uid, $key);                            # 玩家积分
+        $rank = self::_getRank_by_uid($uid, $key);                              # 玩家排名
+        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, $req->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
+        $bHasNewLog = true; // todo: 真正查询是否有新战报
+        $matches = self::getNewMatches($pvp, gMem(), $uid, $zoneid);            # 获得新的匹配对手
+
+        if ($pvp->haventReward_season > 0 && $pvp->haventReward_season < $seasonId) { # 尚未发放上赛季奖励
+            $haventKey = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $pvp->haventReward_season);
+            // todo:发放上周奖励邮件
+        }
+        if ($pvp->haventReward_tsDay > 0 && $pvp->haventReward_tsDay < tsDay()) { # 尚未发放昨天奖励
+            $haventKey_day = MemKey_GameRun::Game_PVPScoreByZone_zset_Day($zoneid, $day);
+            if (gMem()->exists($haventKey_day)) {                               # 昨天的积分记录不存在
+                gMem()->zcopy($key, $haventKey_day);                            # 复制一份当前积分作为昨天的截止积分榜
+            }
+            // todo:发放昨天奖励
+        }
+        // 组装 返回值结构
+        $ret = array(
+            'score' => $score, #                                                # 自己的积分
+            'rank' => $rank, #                                                  # 自己的排名
+            'pvpCoins' => $pvp->pvpCoins, #                                     # 自己的竞技币
+            'fPower' => $fPower, #                                              # 自己的总战力
+            'fightTicket' => $pvp->fightTicket, #                               # 自己的挑战票
+            'defTeam' => $pvp->defTeam, #                                       # 自己的防守队伍
+            'bHasNewFightLog' => $bHasNewLog, #                                 # 是否有战报刷新
+            'matches' => $matches, #                                            # 对手列表
+        );
+        return Resp::ok($ret);                                                  # 返回
+    }
+
+// </editor-fold>
+// 
+// <editor-fold defaultstate="collapsed" desc="   竞技商店  ">
+
+    /**
+     * [6820] 竞技商店 主界面
+     * @param type $req
+     */
+    public static function pvpShopMain($req) {
+        // 商品列表
+        // 检查刷新时间<now => 刷新商品列表
+        // 返回
+    }
+
+    /**
+     * [6821] 竞技 商店 购买道具
+     * @param type $req
+     */
+    public static function pvpShopBuy($req) {
+        // 查询物品配置数据
+        // 扣除竞技币
+        // 发放道具
+        // 回写数据
+        // 返回
+    }
+
+    /**
+     * [6822] 竞技 商店 刷新道具
+     * @param type $req
+     */
+    public static function pvpShopRefresh($req) {
+        // 扣除刷新消耗
+        // 更新刷新时间
+        // 重刷道具
+        // 回写数据
+        // 返回
+    }
+
+    /**
+     *  【移动支付】获取神秘商城物品
+     *  刷新规则: 根据玩家拥有的英雄、装备、道具等数据进行刷新。(因英雄、道具、装备数量不足以支撑该刷新规则,目前先按照随机刷新做,几率平等)
+     * @param Req $req
+     */
+    public static function m_pay_getDynamic($req) {
+        $user = $req->userInfo->game;
+        $userSecretshop = new userSecretshopModel($user->userSecretshop);
+        // 参数提取
+        $refreshType = $req->paras[0];                                          # 刷新类型(参数)0,不刷,1,免费刷,2,钻石刷
+        switch ($refreshType) {
+            case 1:                                                             # 免费刷
+                if (now() < $userSecretshop->lastRefreshTs + glc()->secretshop_refresh_interval) { // 检查是否达到免费刷新时间了, 执行自动更新
+                    return Resp::err(ErrCode::pay_secretshopt_freeRefresh_Time);
+                }
+                break;
+            case 2:                                                             # 钻石刷
+                if (glc()->secretshop_refresh_maxtimes <= $userSecretshop->refreshedTimes) { // 检查刷新次数, 已达上限, 返回错误信息
+                    return Resp::err(ErrCode::pay_refresh_times);
+                }                                                               # 可以继续刷新,
+                $cishu = $userSecretshop->refreshedTimes + 1;                   # 下次
+                $amt = GameConfig::secretshop_refresh_getItem($cishu)->price;
+                if (!UserGameModel::Consume_Cash($user, $amt)) {                # 扣除本次所需费用, 余额不足, 返回错误信息
+                    return Resp::err(ErrCode::notenough_cash_msg);
+                }
+                $userSecretshop->refreshedTimes++;                              # 增加当天付费刷新计数
+                break;
+            case 0:                                                             # 不刷
+            default :                                                           # 默认不刷
+                // do nothing.
+                break;
+        }
+        if ($refreshType != 0) {                                                   # 是否刷新
+            $err = self::refreshDynamicShopItems($req, $userSecretshop);        # 更新物品表
+            if ($err) {
+                return Resp::err($err);
+            }
+            $user->userSecretshop = $userSecretshop;
+            $req->userInfo->game = $user;
+            UserProc::updateUserInfo();
+        }
+        // 返回最新物品表
+        return Resp::ok(array(#                                                 # 成功后将最新的玩家数据返回给客户端
+                    'gold' => $user->gold,
+                    'tili' => $user->tili,
+                    'cash' => $user->cash,
+                    'uss' => $userSecretshop, #                                 # 当前神秘商城数据
+        ));
+    }
+
+    /**
+     * 更新神秘商城物品
+     * @param Req $req
+     * @param UserSecretshopModel $userSecretshop Description
+     */
+    private static function refreshDynamicShopItems($req, &$userSecretshop) {
+        $userSecretshop->lastRefreshTs = now();
+        // todo: 这里补完更新物品的函数,     //        第一版: 随机
+        $userSecretshop->currentItems = ObjectInit();
+        for ($i = 1; $i <= 3; $i++) {                                             # 3种类型的商品
+            $arr = GameConfig::secretshop_goodsType_getItem($i);
+            if (count($arr) > 0) {
+                $err = self::Dice(GameConfig::secretshop_goodsType_getItem($i), 1, $userSecretshop); # 一个种类一次1个物品
+                if ($err) {
+                    return $err;
+                }
+            }
+        }
+        return ErrCode::ok;
+    }
+
+// // </editor-fold>
     //
     // <editor-fold defaultstate="collapsed" desc=" 旧版PVP 681x ">
 //
-//    /**
-//     * 查找对手数量
-//     */
-//    const matchCount = 5;
-//
-//    /**
-//     * [6810] pvp 拉取主界面信息
-//     * @param Req $req
-//     */
-//    static function pvpMainInfo($req) {
-//        $mem = gMem();
-//        $uid = $req->uid;
-//        $zoneid = $req->zoneid;
-//        $pvp = new UserPVPModel($req->userInfo->game->pvp);                     # 设计玩家pvp数据结构
-//        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分总榜
-//        $key_last = MemKey_GameRun::Game_PVPScoreByZone_zset_lastWeek($zoneid); # 上周积分榜
-//        $score = self::_getScore_by_uid($req, $uid);                            # 取玩家当前pvp积分
-//        $tsLastWeek = TimeUtil::tsWeek() - 1;
-//        $lastWeekScore = $mem->zscore($key_last, $uid);
-//        if (!in_array($tsLastWeek, $pvp->weeklyRewardRecords)                   # 尚未发放上周奖励
-//                && $lastWeekScore) {                                            # 并且上周活跃
-//            $pvp->weeklyRewardRecords[] = $tsLastWeek;                          # 添加发奖记录
-//            $leagueid = self::GetLeagueByScore($lastWeekScore);                 # 上周积分所处阶段
-//            EmailProc::SendPvpLeagueReward($zoneid, $uid, $leagueid);           # 阶段奖励
-//            $pvp->clearWeekData();                                              # 每周清理胜率数据
-//            $pvp->curMatches = self::getNewMatches($pvp, $mem, $uid, $zoneid);  # 更新对手列表
-//            $req->userInfo->game->pvp = $pvp;
-//            UserProc::updateUserInfo();
-//        }
-//        self::sendLastRankReward($req);                                         # 发放每周上榜人员奖励
-//        self::UpdateChanlianInfo($req);                                         # 更新蝉联数据(并发奖)
-//        $pvp->score = $score;                                                   # 插入score数据
-//        $rank = $mem->zrevrank($key, $uid);                                     # 提取总榜排行信息
-//        $pvp->rank = (is_null($rank) ? -1 : $rank + 1);
-//        return Resp::ok($pvp);                                      # 返回pvp数据
-//    }
-//
-//    /**
-//     *
-//     * @param Req $req
-//     * @param type $uid
-//     */
-//    static function _getScore_by_uid($req, $uid) {
-//        if ("" == $uid) {
-//            CLog::err('"uid" is Null!');
-//            return 10;
-//        }
-//        $mem = $req->mem;
-//        $zoneid = $req->zoneid;
-//        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
-//        $score = $mem->zscore($key, $uid);
-//        if (!$score || $score <= 0) {                                           # 分数异常
-//            $leagueScore = GameConfig::pvp_leaguescore_getItem(1);              # 新手基础分
-//            $score = $leagueScore->minScore;
-//            $mem->zadd($key, array($uid => $score));                            # 更新玩家积分
-//            $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score));
-//        }
-//        return $score;
-//    }
-//
-//    /**
-//     *
-//     * @param Req $req
-//     * @param type $uid
-//     * @param type $addValue Description
-//     */
-//    private static function _addScore_by_uid($req, $uid, $addValue) {
-//        if ($addValue <= 0) {                                                   # 防御
-//            return;
-//        }
-//        $mem = $req->mem;
-//        $zoneid = $req->zoneid;
-//        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
-//        $score = $mem->zscore($key, $uid);
-//        if (!$score || $score <= 0) {                                           # 分数异常
-//            $leagueScore = GameConfig::pvp_leaguescore_getItem(1);              # 新手基础分
-//            $score = $leagueScore->minScore;
-//            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
-//        }
-//        $newscore = $mem->zincrby($key, $uid, $addValue);                       # 返回最新值
-//        $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $newscore));
-//        return $newscore;
-//    }
-//
-//    /**
-//     *
-//     * @param type $req
-//     * @param type $uid
-//     * @param type $subValue
-//     */
-//    private static function _subScore_by_uid($req, $uid, $subValue) {
-//        if ($subValue >= 0) {                                                   # 防御异常数值
-//            return;
-//        }
-//        $mem = $req->mem;
-//        $zoneid = $req->zoneid;
-//        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
-//        $score = $mem->zscore($key, $uid);
-//        $leagueScore = GameConfig::pvp_leaguescore_getItem(1);                  # 新手基础分
-//        if (!$score || $score <= 0                                              #
-//                || ($score + $subValue) <= $leagueScore->minScore) {            # 分数异常
-//            $score = $leagueScore->minScore;                                    # 新手基础分
-//            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
-//        } else {
-//            $score = $mem->zincrby($key, $uid, $subValue);                      # 扣除积分并返回最新值
-//        }
-//        $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score)); # 同步记录
-//        return $score;
-//    }
-//
-//    /**
-//     * 发送上周上榜奖励
-//     * @param Req $req
-//     */
-//    public static function sendLastRankReward($req) {
-//        $mem = gMem();
-//        $zoneid = $req->zoneid;
-//        $tsweek = TimeUtil::tsWeek();
-//        $key = MemKey_GameRun::Game_PVPRankRewardRecord_set($zoneid);
-//        if (!$mem->sismember($key, $tsweek)) {                                  # 上周榜单尚未处理, 每周只处理一次
-//            // 上周是空的情况.
-//            $lastKey = MemKey_GameRun::Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek - 1);
-//            $mem->sadd($key, $tsweek);                                      # 添加处理记录
-//            $key_total = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid); # 拉取上榜人员
-//            $uids = $mem->zrevrange($key_total, 0, 99);
-//            $rank = 0;
-//            foreach ($uids as $uid) {
-//                EmailProc::SendPvpRankReward($zoneid, $uid, ++$rank);           # 发送奖励邮件
+
+    /**
+     * @deprecated since version 2020.5.8
+     * @param Req $req
+     * @param type $uid
+     * @param type $addValue Description
+     */
+    private static function _addScore_by_uid($req, $uid, $addValue) {
+        if ($addValue <= 0) {                                                   # 防御
+            return;
+        }
+        $mem = $req->mem;
+        $zoneid = $req->zoneid;
+        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
+        $score = $mem->zscore($key, $uid);
+        if (!$score || $score <= 0) {                                           # 分数异常
+            $leagueScore = GameConfig::pvp_leaguescore_getItem(1);              # 新手基础分
+            $score = $leagueScore->minScore;
+            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
+        }
+        $newscore = $mem->zincrby($key, $uid, $addValue);                       # 返回最新值
+        $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $newscore));
+        return $newscore;
+    }
+
+    /**
+     * @deprecated since version 2020.5.8
+     * @param type $req
+     * @param type $uid
+     * @param type $subValue
+     */
+    private static function _subScore_by_uid($req, $uid, $subValue) {
+        if ($subValue >= 0) {                                                   # 防御异常数值
+            return;
+        }
+        $mem = $req->mem;
+        $zoneid = $req->zoneid;
+        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);               # 积分榜
+        $score = $mem->zscore($key, $uid);
+        $leagueScore = GameConfig::pvp_leaguescore_getItem(1);                  # 新手基础分
+        if (!$score || $score <= 0                                              #
+                || ($score + $subValue) <= $leagueScore->minScore) {            # 分数异常
+            $score = $leagueScore->minScore;                                    # 新手基础分
+            $mem->zadd($key, array($uid => $score));                            # 重置玩家积分
+        } else {
+            $score = $mem->zincrby($key, $uid, $subValue);                      # 扣除积分并返回最新值
+        }
+        $mem->zadd(MemKey_GameRun::Game_PVPScoreByZone_zset_curWeek($zoneid), array($uid => $score)); # 同步记录
+        return $score;
+    }
+
+    /**
+     * 发送上周上榜奖励
+     * @param Req $req
+     */
+    public static function sendLastRankReward($req) {
+        $mem = gMem();
+        $zoneid = $req->zoneid;
+        $tsweek = TimeUtil::tsWeek();
+        $key = MemKey_GameRun::Game_PVPRankRewardRecord_set($zoneid);
+        if (!$mem->sismember($key, $tsweek)) {                                  # 上周榜单尚未处理, 每周只处理一次
+            // 上周是空的情况.
+            $lastKey = MemKey_GameRun::Game_PVPRankRewardRecord_byWeek_str($zoneid, $tsweek - 1);
+            $mem->sadd($key, $tsweek);                                          # 添加处理记录
+            $key_total = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);     # 拉取上榜人员
+            $uids = $mem->zrevrange($key_total, 0, 99);
+            $rank = 0;
+            foreach ($uids as $uid) {
+                EmailProc::SendPvpRankReward($zoneid, $uid, ++$rank);           # 发送奖励邮件
+            }
+            $mem->add($lastKey, $uids);
+        }
+    }
+
+    /**
+     * [6811] 竞技场 刷新对手
+     * @param Req $req
+     */
+    static function pvp_Refresh($req) {
+        // 刷新无花费, 间隔时间3秒(客户端控制得了)
+        // 根据匹配规格获得5个对手即可(1. 排除自己, 2. 最好不要出现已经刷到过的对手)
+        // 低于玩家当前积分 -- 2个 -5%~-20%之间
+        // 与玩家当前积分基本持平 1个, ±5%之间
+        // 高于玩家当前积分 -- 2个 +5%~+40%之间
+//        $amt = $req->paras[0];                                                  # 提取 params , 验证下花费
+//        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+//        $ts = now();
+//        if ($amt <= 0) {                                                        # 免费情况
+//            if ($pvp->nextRefreshTs > $ts) {                                    # 验证时间
+//                return Resp::err(ErrCode::pvp_refresh_time);
+//            }
+//        } else {                                                                # 扣除钻石刷新的情况
+//            $priceArr = explode(',', glc()->PVP_reFresh_Match_cost);            # 价格
+//            if (count($priceArr) < $pvp->dailyRefreshMatchTimes) {              # 超过最大刷新次数
+//                return Resp::err(ErrCode::pvp_refresh_max);
+//            }
+//            $costCash = $priceArr[$pvp->dailyRefreshMatchTimes++];              # 查找对应的定价, 并计次
+//            if ($costCash != $amt) {                                            # 跟预期值不一致,
+//                return Resp::err(ErrCode::pvp_refresh_cost_ilegal);
+//            }
+//            if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {# 扣除钻石失败
+//                return Resp::err(ErrCode::notenough_cash_msg);
 //            }
-//            $mem->add($lastKey, $uids);
 //        }
-//    }
 //
-//    /**
-//     * [6819] pvp - 拉取蝉联信息
-//     * @param Req $req
-//     */
-//    static function getChanlianINfo($req) {
-//        $zoneid = $req->zoneid;
-//        $key = MemKey_GameRun::Game_PVP_Chanlian_normal($zoneid);
-//        $pvpChanlian = new GamePvpChanlian(gMem()->get($key));
-//        $pvpHistory = gMem()->hgetall(MemKey_GameRun::Game_PVP_Chanlian_History_hash($zoneid));
-//        return Resp::ok(array(
-//                    'info' => $pvpChanlian,
-//                    'history' => array_values((array) $pvpHistory)
-//        ));
-//    }
+//        $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
+//        $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
+//        $req->userInfo->game->pvp = $pvp;
+//        UserProc::updateUserInfo();                                         # 回写数据
 //
-//    /**
-//     * [6811] pvp 挑战对手xx
-//     * @param Req $req
-//     */
-//    static function pvp_PK($req) {
-//        $uid = $req->uid;
-//        $target_uid = $req->paras[0];                                           # 对手id
-//        $result = $req->paras[1];                                               # 胜负结果 0负,1胜
-//        $pvp = $req->userInfo->game->pvp;
+//        $ret = array(
+//            'nextRefreshTs' => $pvp->nextRefreshTs, #                           # 下次免费刷新的时间戳
+//            'dailyRefreshMatchTimes' => $pvp->dailyRefreshMatchTimes,
+//            'curMatches' => $pvp->curMatches  #                                 # 当前对手清单
+//        );
+        return Resp::ok($ret);
+    }
+
+    /**
+     * [6812] 竞技场 挑战对手xx
+     * @param Req $req
+     */
+    static function pvp_PK($req) {
+        $uid = $req->uid;
+        $target_uid = $req->paras[0];                                           # 对手id
+        $result = $req->paras[1];                                               # 胜负结果 0负,1胜
+        $pvp = $req->userInfo->game->pvp;
+        // 根据挑战结果, 计算双方积分变化
+        // 更新双方的积分变化 
+        // redis->zincr 修改各自积分
+        // 返回
 //        if (!property_exists($pvp->curMatches, $target_uid)//
 //                or property_exists($pvp->curMatches->$target_uid, 'killed')) {  # 对手已被ko
 //            return Resp::err(ErrCode::pvp_wrongMather);
@@ -344,55 +538,35 @@ class PVPProc {
 //            'leagueId' => $pvp->leagueId,
 //            'newscore' => $score, #                                             # 返回最新积分
 //        );
-//        return Resp::ok($ret);
-//    }
-//
-//    /**
-//     * [6812] pvp 刷新对手
-//     * @param Req $req
-//     */
-//    static function pvp_Refresh($req) {
-//        $amt = $req->paras[0];                                                  # 提取 params , 验证下花费
-//        $pvp = new UserPVPModel($req->userInfo->game->pvp);
-//        $ts = now();
-//        if ($amt <= 0) {                                                        # 免费情况
-//            if ($pvp->nextRefreshTs > $ts) {                                    # 验证时间
-//                return Resp::err(ErrCode::pvp_refresh_time);
-//            }
-//        } else {                                                                # 扣除钻石刷新的情况
-//            $priceArr = explode(',', glc()->PVP_reFresh_Match_cost);            # 价格
-//            if (count($priceArr) < $pvp->dailyRefreshMatchTimes) {              # 超过最大刷新次数
-//                return Resp::err(ErrCode::pvp_refresh_max);
-//            }
-//            $costCash = $priceArr[$pvp->dailyRefreshMatchTimes++];              # 查找对应的定价, 并计次
-//            if ($costCash != $amt) {                                            # 跟预期值不一致,
-//                return Resp::err(ErrCode::pvp_refresh_cost_ilegal);
-//            }
-//            if (!UserGameModel::Consume_Cash($req->userInfo->game, $costCash)) {# 扣除钻石失败
-//                return Resp::err(ErrCode::notenough_cash_msg);
-//            }
-//        }
-//
-//        $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid);
-//        $pvp->nextRefreshTs = now(glc()->PVP_refresh_Match_RecoverSeconds);
-//        $req->userInfo->game->pvp = $pvp;
-//        UserProc::updateUserInfo();                                         # 回写数据
-//
-//        $ret = array(
-//            'nextRefreshTs' => $pvp->nextRefreshTs, #                           # 下次免费刷新的时间戳
-//            'dailyRefreshMatchTimes' => $pvp->dailyRefreshMatchTimes,
-//            'curMatches' => $pvp->curMatches  #                                 # 当前对手清单
-//        );
-//        return Resp::ok($ret);
-//    }
-//
-//    /**
-//     * [6813] 购买体力 v2.0 阶梯定价.
-//     * @param Req $req
-//     * @return type
-//     */
-//    static function pvp_buytili($req) {
-//        $amt = $req->paras[0];                                                  # 验证下本次扣除的钻石数量
+        return Resp::ok($ret);
+    }
+
+    /**
+     * [6813] 竞技场 设置防守队伍
+     * @param req $req
+     */
+    public static function pvp_setTeam($req) {
+        $heros = $req->paras[0];                                                # para: 新阵容
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+        if (is_array($heros)) {                                                 # 更新阵容
+            $pvp->defTeam->heros = $heros;
+        }
+        $req->userInfo->game->pvp = $pvp;
+        UserProc::updateUserInfo();                                             # 回存数据
+        return Resp::ok($pvp->defTeam);                                         # 返回
+    }
+
+    /**
+     * [6814] 购买挑战票
+     * @param Req $req
+     * @return type
+     */
+    static function pvp_buyticket($req) {
+        $amt = $req->paras[0];                                                  # 验证下本次扣除的钻石数量
+        # 检查并扣除消耗
+        # 增加挑战票
+        # 回存数据
+        # 返回
 //        $pvp = new UserPVPModel($req->userInfo->game->pvp);
 //        $g = glc();
 //        $curTili = intval((now() - $pvp->tiliTs) / $g->PVP_reCover_Tili_costSec);
@@ -428,19 +602,18 @@ class PVPProc {
 //            'dailyBuyTiliTimes' => $pvp->dailyBuyTiliTimes,
 //            'userCash' => $req->userInfo->game->cash
 //        );
-//        return Resp::ok($ret);                                                  # 返回
-//    }
-//
-//    /**
-//     * [6814] pvp 拉取榜单数据
-//     * @param Req $req
-//     */
-//    static function pvp_getRank($req) {
-//        $maxAmt = 10;                                                           # 一次最多取10个玩家信息
-//        $zoneid = $req->zoneid;
-//        $index = $req->paras[0];                                                # 起始(0)
-//        $n = $req->paras[1];                                                    # 数量, (n<=max)
-//
+        return Resp::ok($ret);                                                  # 返回
+    }
+
+    /**
+     * [6815] 竞技场 拉取榜单数据
+     * @param Req $req
+     */
+    static function pvp_getRank($req) {
+        $maxAmt = 10;                                                           # 一次最多取10个玩家信息
+        $zoneid = $req->zoneid;
+        $index = $req->paras[0];                                                # 起始(0)
+        $n = $req->paras[1];                                                    # 数量, (n<=max)
 //        if ($n < 1 || $n > $maxAmt) {                                           # 防御非法情况
 //            $n = $maxAmt;
 //        }
@@ -458,295 +631,268 @@ class PVPProc {
 //        $ret = array(
 //            'arr' => $result
 //        );
-//        return Resp::ok($ret);
-//    }
-//
-//    /**
-//     * [6815] pvp 领取活跃度奖励
-//     * @param Req $req
-//     */
-//    static function pvp_drawacitverewards($req) {
-//        $rewardId = $req->paras[0];                                             # 提取参数
-//        $reward = GameConfig::pvp_activityreward_getItem($rewardId);
-//        if (!$reward) {
-//            return Resp::err(ErrCode::err_const_no);
-//        }
-//        $pvp = new UserPVPModel($req->userInfo->game->pvp);
-//        if ($reward->activityNum > $pvp->actives) {
-//            return Resp::err(ErrCode::pvp_activenotenough);
-//        }
-//        $pvp->actives = 0;                                                      # 活跃记录直接清零
-//        $req->userInfo->game->pvp = $pvp;                                       # 回写pvp数据
-//        $err = StoreProc::AddMultiItemInStore($req, $reward->reward1);          # 发放奖励
-//        if ($err) {
-//            return Resp::err($err);
-//        }
-//        UserProc::updateUserInfo();                                         # 回写玩家数据
-//        $ret = array(#                                                          # 返回值
-//            'actives' => $pvp->actives, //                                      # 最新的 活跃度值
-//            'store' => $req->userInfo->game->store, //                          # 获得奖励之后的玩家仓库信息
-//            'hero' => $req->userInfo->game->heros, //                           # 获得奖励之后的玩家英雄信息
-//            'reward' => $reward->reward1,
-//        );
-//        return Resp::ok($ret);
-//    }
-//
-//// ---------------- 辅助函数 -----------------------
-//
-//    /**
-//     * 清理每日计数器
-//     * @param Req $req
-//     */
-//    public static function ClearDailyPkcnt($req) {
-//        $pvp = new UserPVPModel($req->userInfo->game->pvp);
-//        $pvp->dailyPkCnt = 0;
-//        $pvp->dailyBuyTiliTimes = 0;
-//        $pvp->dailyRefreshMatchTimes = 0;
-//        $pvp->dailyMatchRecord = array($req->uid);                              # 屏蔽自己
-//        $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid); # added by: 李宁,2017年8月1日 11:45:41
-//        $pvp->nextRefreshTs = tsDay() * 86400 + glc()->PVP_refresh_Match_RecoverSeconds;
-//        $req->userInfo->game->pvp = $pvp;
-//    }
-//
-//    /**
-//     * 更新蝉联信息(并发奖,如果有)
-//     * @param Req $req
-//     */
-//    private static function UpdateChanlianInfo($req) {
-//        $zoneid = $req->zoneid;
-//        $tsWeek = TimeUtil::tsWeek();
-//        $key = MemKey_GameRun::Game_PVP_Chanlian_normal($zoneid);
-////        $key_lastWeek = MemKey_GameRun::Game_PVPScoreByZone_zset_lastWeek($zoneid);
-//        $pvpChanlian = new GamePvpChanlian(gMem()->get($key));
-//        if ($pvpChanlian->tsWeek == $tsWeek) {
-//            return;                                                             # 已处理
-//        }
-//        $pvpChanlian->tsWeek = $tsWeek;
-//        $arr_1 = gMem()->zrevrange(MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid), 0, 0);
-//        $uid = $arr_1[0];                                                       # 取上次第一
-//        if ($uid == $pvpChanlian->uid) {                                        # 蝉联了
-//            $pvpChanlian->times++;
-//            if ($pvpChanlian->times == 3) {                                     # 达到3次, 完成蝉联, 发放奖励
-//                EmailProc::SendPvpChanlianReward($zoneid, $uid);                # 发放奖励
-//                $historyKey = MemKey_GameRun::Game_PVP_Chanlian_History_hash($zoneid);
-//                gMem()->hset($historyKey, $tsWeek, $pvpChanlian->userInfo);     # 进入历届榜
-//            }
-//            if ($pvpChanlian->times > 3) {                                      # 第四次蝉联的时候
-//                $pvpChanlian->times -= 3;                                       # 循环蝉联计数信息
-//            }
-//        } else {                                                                # 替换掉上一届
-//            $arr = self::GetPlayerInfosForPVP(gMem(), $zoneid, array($uid => 100)); # 提取玩家信息
-//            $pvpChanlian->userInfo = $arr[$uid];                                # 更新蝉联玩家信息
-//            $pvpChanlian->uid = $uid;                                           # 玩家ID
-//            $pvpChanlian->times = 1;                                            # 首次
-//        }
-//        gMem()->set($key, $pvpChanlian);                                        # 回写数据
-//    }
-//
+        return Resp::ok($ret);
+    }
+
+    /**
+     * [6816] 竞技场 查看战报
+     * @param Req $req
+     */
+    static function pvp_getFightLogs($req) {
+        // 提取主动挑战+被挑战记录
+        // 更新下刷新时间
+        // 返回
+        return Resp::ok($ret);
+    }
+
+// ---------------- 辅助函数 -----------------------
 // <editor-fold defaultstate="collapsed" desc="    辅助 函数   ">
-//
-//    /**
-//     * 依据积分获得所在阶段的id
-//     * @param type $curScore
-//     * @return int
-//     */
-//    private static function GetLeagueByScore($curScore) {
-//        foreach (GameConfig::pvp_leaguescore() as $id => $lg) {
-//            isEditor() and $lg = new sm_pvp_leaguescore;
-//            if ($lg->maxScore >= $curScore && $lg->minScore <= $curScore) {
-//                return $id;
-//            }
-//        }
-//        return 1;                                                               # 找不到对应所属阶段的时候,返回 默认值 1
-//    }
-//
-//    /**
-//     * 获取对手匹配结果
-//     * @param UserPVPModel $pvp
-//     * @param CRedisutil $mem
-//     * @param type $uid
-//     * @param type $zoneid
-//     */
-//    private static function getNewMatches($pvp, $mem, $uid, $zoneid) {
-//        $arr = array();
-//        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
-//        self::findmatcher($zoneid, $key, $uid, $pvp, $arr);                     # 积分榜查找
-//        if (count($arr) < self::matchCount) {                                   # 如果没有凑足人数,战斗力候补来源,
-//            $keyfp = MemKey_GameRun::Game_FightPowerRank_zset($zoneid);
-//            self::findmatcher($zoneid, $keyfp, $uid, $pvp, $arr);               # 从战斗力榜找
-//        }
-//        if (count($arr) < self::matchCount) {                                   # 再不行, 准备机器人吧
-//// todo: 这里引入gm对手数据,
-//            CLog::err('PVP刷对手数量不足, 赶快考虑加入机器人.', 'PVP');
-//        }
-//        $ret = self::GetPlayerInfosForPVP($mem, $zoneid, $arr);
-//        $keys = array_keys($ret);
-//        $k = $keys[0];
-//        $v = $ret[$k];
-//        $v['fog'] = true;
-//        $ret[$k] = $v;
-////        var_dump($v);
-////        echoLine(JsonUtil::encode($ret[$k]));
-//        return $ret;
-//    }
-//
-//    /**
-//     * 查找匹配的对手
-//     * @param type $zoneid
-//     * @param type $key
-//     * @param type $uid
-//     * @param UserPVPModel $pvp
-//     * @param type $arr
-//     */
-//    private static function findmatcher($zoneid, $key, $uid, &$pvp, &$arr) {
-//        $mem = gMem();
-//        $rank = $mem->zrevrank($key, $uid);                                     # 直接查排名
-//        $zlen = $mem->zlen($key);                                               # 数据长度
-//        $i = 0;                                                                 # 计数器
-//        $b = false;                                                             # 上下标志位
-//        while (count($arr) < self::matchCount && $i < 50) {                     # 找够数量为止,或者查找超过100个位置, 跳出查找
-//            $index = $rank + ($b ? - $i : $i);
-//// todo: 这里引入连胜/连负修正系数.
-//            $b = !$b;
-//            if ($b) {                                                           # 变化查找方向
-//                $i++;                                                           #
-//            }
-//            if ($index < 0 || $index >= $zlen) {                                # 跳过不合理位置
-//                continue;
-//            }
-//            $back = $mem->zrevrange($key, $index, $index, true);                # 取1个人
-//            if (count($back) <= 0) {
-//                continue;
-//            }
-//            $us = array_keys($back);
-//            $d_uid = $us[0];
-//            if ($d_uid == $uid) {                                               # 避开自己
-//                continue;
-//            }
-//            $user = $mem->get(MemKey_User::Info_hash($zoneid, $d_uid));
-//            if (null == $user) {
-//                continue;
-//            }
+
+    /**
+     * 竞技场 查询玩家的积分 
+     * @param type $uid
+     * @return int 
+     */
+    static function _getScore_by_uid($uid, $key) {
+        if ("" == $uid) {
+            CLog::err('"uid" is Null!');
+            return 10;                                                          # 记录错误并返回一个极低分
+        }
+        $mem = gMem();
+        $score = $mem->zscore($key, $uid);
+        if (!$score || $score <= 0) {                                           # 分数异常
+            $score = self::pvpBaseScore;                                        # 新手基础分
+            $mem->zadd($key, array($uid => $score));                            # 更新玩家积分
+        }
+        return $score;
+    }
+
+    /**
+     * 竞技场 查询玩家的排名
+     * @param string $uid
+     * @param string $key
+     * @return int 
+     */
+    static function _getRank_by_uid($uid, $key) {
+        $rank = self::pvpMaxRank + 1;                                           # 未上榜
+        if ("" == $uid) {
+            CLog::err('"uid" is Null!');
+            return $rank;                                                       # 记录错误并返回未上榜
+        }
+        $mem = gMem();
+        $r = $mem->zrevrank($key, $uid);
+        if (!is_null($r)) {
+            $rank = $r;                                                         # 有名次,更新
+        }
+        return $rank;                                                           # 返回
+    }
+
+    /**
+     * 清理每日计数器
+     * @deprecated since version 2020.5.8
+     * @param Req $req
+     */
+    public static function ClearDailyPkcnt($req) {
+        $pvp = new UserPVPModel($req->userInfo->game->pvp);
+        $pvp->dailyPkCnt = 0;
+        $pvp->dailyBuyTiliTimes = 0;
+        $pvp->dailyRefreshMatchTimes = 0;
+        $pvp->dailyMatchRecord = array($req->uid);                              # 屏蔽自己
+        $pvp->curMatches = self::getNewMatches($pvp, $req->mem, $req->uid, $req->zoneid); # added by: 李宁,2017年8月1日 11:45:41
+        $pvp->nextRefreshTs = tsDay() * 86400 + glc()->PVP_refresh_Match_RecoverSeconds;
+        $req->userInfo->game->pvp = $pvp;
+    }
+
+    /**
+     * 依据积分获得所在阶段的id
+     * @deprecated since version 2020.5.8
+     * @param type $curScore
+     * @return int
+     */
+    private static function GetLeagueByScore($curScore) {
+        foreach (GameConfig::pvp_leaguescore() as $id => $lg) {
+            isEditor() and $lg = new sm_pvp_leaguescore;
+            if ($lg->maxScore >= $curScore && $lg->minScore <= $curScore) {
+                return $id;
+            }
+        }
+        return 1;                                                               # 找不到对应所属阶段的时候,返回 默认值 1
+    }
+
+    /**
+     * 获取对手匹配结果
+     * @param UserPVPModel $pvp
+     * @param CRedisutil $mem
+     * @param type $uid
+     * @param type $zoneid
+     */
+    private static function getNewMatches($pvp, $uid, $zoneid) {
+        $arr = array();
+        $seasonID = self::GetCurSeasonID();
+        $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonID); # redis key
+        self::findmatcher($zoneid, $key, $uid, $pvp, $arr);                     # 积分榜查找 
+        if (count($arr) < self::matchCount) {                                   # 再不行, 准备机器人吧
+// todo: 这里引入gm对手数据,
+            CLog::err('PVP刷对手数量不足, 赶快考虑加入机器人.', 'PVP');
+        }
+        $ret = self::GetPlayerInfosForPVP(gMem(), $zoneid, $arr);
+
+        return $ret;
+    }
+
+    /**
+     * 查找匹配的对手
+     * @param type $zoneid
+     * @param type $key
+     * @param type $uid
+     * @param UserPVPModel $pvp
+     * @param type $arr
+     */
+    private static function findmatcher($zoneid, $key, $uid, &$pvp, &$arr) {
+        $mem = gMem();
+        $rank = $mem->zrevrank($key, $uid);                                     # 直接查排名
+        $zlen = $mem->zlen($key);                                               # 数据长度
+        $i = 0;                                                                 # 计数器
+        $b = false;                                                             # 上下标志位
+        while (count($arr) < self::matchCount && $i < 50) {                     # 找够数量为止,或者查找超过100个位置, 跳出查找
+            $index = $rank + ($b ? - $i : $i);
+            $b = !$b;
+            if ($b) {                                                           # 变化查找方向
+                $i++;                                                           #
+            }
+            if ($index < 0 || $index >= $zlen) {                                # 跳过不合理位置
+                continue;
+            }
+            $back = $mem->zrevrange($key, $index, $index, true);                # 取1个人
+            if (count($back) <= 0) {
+                continue;                                                       # 跳过
+            }
+            $us = array_keys($back);
+            $d_uid = $us[0];
+            if ($d_uid == $uid) {                                               # 避开自己
+                continue;
+            }
+            $user = $mem->get(MemKey_User::Info_hash($zoneid, $d_uid));
+            if (null == $user) {                                                # 找不到对手数据,跳过
+                continue;
+            }
 //            $fp = HeroProc::CalcTeamFightPower($zoneid, $d_uid, $user);
 //            if ($fp > 0) {
-////                 $pvp->dailyMatchRecord
-//                if (!in_array($d_uid, $pvp->dailyMatchRecord)) {            # 已经匹配过的对手不在出现
-//                    $arr[$d_uid] = $back[$d_uid];
-//                    $pvp->dailyMatchRecord[] = $d_uid;
-//                }
-//            }
-//        }
-//    }
-//
-//    /**
-//     * 获取榜单玩家
-//     * @param Credisutil $mem
-//     * @param int $zoneid
-//     * @param int $start
-//     * @param int $stop
-//     * @return type
-//     */
-//    private static function getRankPlayers($mem, $zoneid, $start, $stop) {
-//        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
-//        $retUidsWithScore = $mem->zrevrange($key, $start, $stop, true);
-//        return self::GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore);
-//    }
-//
-//    /**
-//     * 拉取玩家信息-pvp模块专用信息
-//     * @param CredisUtil $mem
-//     * @param type $zoneid
-//     * @param type $retUidsWithScore
-//     * @return type
-//     */
-//    private static function GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore) {
-////        var_dump($retUidsWithScore);
-//        $retUids = array_keys($retUidsWithScore);
-//        $keysOfUserInfo = array_map(function($u)use($zoneid) {
-//            return MemKey_User::Info_hash($zoneid, $u);
-//        }, $retUids);
-//        $arrUserInfos = $mem->getMulti($keysOfUserInfo);
-//        $arr = ArrayInit();
-//        $i = 0;
-//        foreach ($arrUserInfos as $userGameInfo) {
-//            isEditor() && $userGameInfo = new UserGameModel;
-//            $uid = $retUids[$i++];
-////            $sharedHeroId = $userGameInfo->heros->firendSupportHeroUID;
-//            $team = JsonUtil::decode('{"teamLeader": 0,"heros":{}}');
-//            $teamConfig = JsonUtil::decode($userGameInfo->heroTeamConfig);
-//            if ($teamConfig && $teamConfig->curUseTeamID > 0) {
-//                $heros = ObjectInit();
-//                $teamid = $teamConfig->curUseTeamID;
-//                $heros_uid = $teamConfig->teamDic->$teamid->heros;
-//                $m = 0;
-//                foreach ($heros_uid as $heroid) {
-//                    $m++;
-//                    $heros->$m = $heroid ? self::getHeroInfoForShare($userGameInfo, $heroid) : null;
-//                }
-//                $team = array(
-//                    'teamLeader' => $teamConfig->teamDic->$teamid->teamLeader,
-//                    'heros' => $heros
-//                );
-//            }
-//
-//            $pvp = StlUtil::array2class(array('contWin' => '', 'totalTimes' => '', 'winTimes' => '', 'leagueId' => ''));
-//            CommUtil::loadObject($userGameInfo->pvp, $pvp);                     # 提取pvp数据
-//            $arr[$uid] = array(
-//                'img' => $userGameInfo->img,
-//                'imgBorderId' => $userGameInfo->imgBorderId,
-////                'sharedHero' => self::getHeroInfoForShare($userGameInfo, $sharedHeroId),
-//                'lastLoginTs' => isset($userGameInfo->lastLogin) ? $userGameInfo->lastLogin : 0,
-//                'nickname' => $userGameInfo->name,
-//                'pvp' => $pvp,
-//                'score' => $retUidsWithScore[$uid],
-//                'level' => $userGameInfo->level,
-//                'uid' => $uid,
-//                'heroTeamConfig' => $team                                       # 战队配置
-//            );
-//        }
-//        if (count($arr) <= 0) {
-//            $arr = null;
-//        }
-//        return $arr;
-//    }
-//
-//    /**
-//     * 提取英雄信息以供其他人使用
-//     * @param type $userInfo
-//     * @param type $heroId
-//     * @return UserHeroModel
-//     */
-//    public static function getHeroInfoForShare($userInfo, $heroId) {
-//        if ($heroId) {
-//            $heroInfo = $userInfo->heros->collectHeros->$heroId;
-//        } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
-//            $coll = $userInfo->heros->collectHeros;
-//            $keys = array_keys((array) $coll);
-//            if (count($keys) <= 0) {
-//                return null;  // 暴力跳过, 防止出现更大的错误
-//            }
-//            $heroId = $keys[0];
-//            $heroInfo = $userInfo->heros->collectHeros->$heroId;
-//        }
-//// 额外将英雄的装备数据替换为实例数据
-//        self::getArmor($userInfo, $heroInfo, 'weapon');
-//        self::getArmor($userInfo, $heroInfo, 'armor');
-//        self::getArmor($userInfo, $heroInfo, 'ring');
-//        return $heroInfo;
-//    }
-//
-//    private static function getArmor($userInfo, $hero, $armor) {
-//        if (isset($hero->equip->$armor)) {
-//            if (property_exists($hero->equip->$armor, 'itemuid')) {
-//                $armorid = $hero->equip->$armor->itemuid;
-//                if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
-//                    $hero->equip->$armor = $userInfo->store->equipment->$armorid;
-//                    return;                                                     # 找到后直接跳出
-//                }
+            if (!in_array($d_uid, $pvp->dailyMatchRecord)) {                    # 已经匹配过的对手不在出现
+                $arr[$d_uid] = $back[$d_uid];
+                $pvp->dailyMatchRecord[] = $d_uid;
+            }
 //            }
-//        }
-//        $hero->equip->$armor = null;
-//    }
+        }
+    }
+
+    /**
+     * 拉取玩家信息-pvp模块专用信息
+     * @param CredisUtil $mem
+     * @param type $zoneid
+     * @param type $retUidsWithScore
+     * @return type
+     */
+    private static function GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore) {
+        $retUids = array_keys($retUidsWithScore);
+        $keysOfUserInfo = array_map(function($u)use($zoneid) {
+            return MemKey_User::Info_hash($zoneid, $u);
+        }, $retUids);
+        $arrUserInfos = $mem->getMulti($keysOfUserInfo);
+        $arr = ArrayInit();
+        $i = 0;
+        foreach ($arrUserInfos as $userGameInfo) {                              # 遍历
+            isEditor() && $userGameInfo = new UserGameModel;                    # 语法辅助
+            $uid = $retUids[$i++];                                              # 当前UID
+            $teamConfig = $userGameInfo->pvp->defTeam;                          # 防守阵容
+            $heros = new \stdClass();                                           # 英雄集合
+            foreach ($teamConfig->heros as $i => $hid) {
+                if ($hid > 0) {
+                    $n_hid = $hid - 10000;
+                    $heros->$n_hid = $userGameInfo->game->heros->collectHeros->$hid;
+                }
+            }
+
+            $adversary = array(#                                                # 拼装玩家信息
+                'uid' => $uid,
+                'name' => my_null_default($userGameInfo->game->name, ""),
+                'level' => my_null_default($userGameInfo->game->level, 1),
+                'headImg' => my_null_default($userGameInfo->game->img, ""),
+//            'skills' => null, #                                                 # skills暂时没有实例数据 
+                'equipment' => array("equipments" => my_null_default($userGameInfo->game->store->equipment, new \stdClass())), # 武器
+                'yanling' => array("items" => my_null_default($userGameInfo->game->store->yanling, new \stdClass())), # 言灵
+                'heros' => my_null_default($heros, new \stdClass()), #          # 英雄集合
+                'score' => $retUidsWithScore[$uid], #                           # 积分
+            );
+            $arr[$uid] = $adversary;
+        }
+        if (count($arr) <= 0) {
+            $arr = null;
+        }
+        return $arr;
+    }
+
+    /**
+     * 获取榜单玩家
+     * @deprecated since version 2020.5.8
+     * @param Credisutil $mem
+     * @param int $zoneid
+     * @param int $start
+     * @param int $stop
+     * @return type
+     */
+    private static function getRankPlayers($mem, $zoneid, $start, $stop) {
+        $key = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
+        $retUidsWithScore = $mem->zrevrange($key, $start, $stop, true);
+        return self::GetPlayerInfosForPVP($mem, $zoneid, $retUidsWithScore);
+    }
+
+    /**
+     * 提取英雄信息以供其他人使用
+     * @deprecated since version 2020.5.8
+     * @param type $userInfo
+     * @param type $heroId
+     * @return UserHeroModel
+     */
+    public static function getHeroInfoForShare($userInfo, $heroId) {
+        if ($heroId) {
+            $heroInfo = $userInfo->heros->collectHeros->$heroId;
+        } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
+            $coll = $userInfo->heros->collectHeros;
+            $keys = array_keys((array) $coll);
+            if (count($keys) <= 0) {
+                return null;  // 暴力跳过, 防止出现更大的错误
+            }
+            $heroId = $keys[0];
+            $heroInfo = $userInfo->heros->collectHeros->$heroId;
+        }
+// 额外将英雄的装备数据替换为实例数据
+        self::getArmor($userInfo, $heroInfo, 'weapon');
+        self::getArmor($userInfo, $heroInfo, 'armor');
+        self::getArmor($userInfo, $heroInfo, 'ring');
+        return $heroInfo;
+    }
+
+    /**
+     * @deprecated since version 2020.5.8
+     * @param type $userInfo
+     * @param type $hero
+     * @param type $armor
+     * @return type
+     */
+    private static function getArmor($userInfo, $hero, $armor) {
+        if (isset($hero->equip->$armor)) {
+            if (property_exists($hero->equip->$armor, 'itemuid')) {
+                $armorid = $hero->equip->$armor->itemuid;
+                if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
+                    $hero->equip->$armor = $userInfo->store->equipment->$armorid;
+                    return;                                                     # 找到后直接跳出
+                }
+            }
+        }
+        $hero->equip->$armor = null;
+    }
+
 // </editor-fold>
 //
 // </editor-fold>

+ 2 - 2
Gameserver/Amfphp/process/GuildProc.php

@@ -929,7 +929,7 @@ class GuildProc {
             $resp = Resp::err(ErrCode::err_guild_guildinfono);
         } else {
             $memberArr = array();
-            $key_cur = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneID);
+//            $key_cur = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneID);
             foreach ($guildInfo->members as $mboid) {
                 $memberInfo = self::getMemUserGuildInfo($mem, $mboid, $zoneID);
                 $userInfo = UserProc::getUserInfo($mem, $zoneID, $mboid);
@@ -939,7 +939,7 @@ class GuildProc {
                 $memberInfo->uid = $mboid;
                 $memberInfo->img = $userInfo->game->img;
                 $memberInfo->imgBorderId = $userInfo->game->imgBorderId;
-                $score = $mem->zscore($key_cur, $mboid);
+//                $score = $mem->zscore($key_cur, $mboid);
                 $memberInfo->cupScore = $score == null ? 0 : $score;
                 $memberInfo->lastLogin = $userInfo->game->lastLogin; #成员最后登陆时间
                 unset($memberInfo->appliedguildlist);

+ 4 - 4
Gameserver/Amfphp/process/PayProc.php

@@ -34,16 +34,16 @@ class PayProc {
                 return PayProc::m_GetFirstPayGift($req);
             // <editor-fold defaultstate="collapsed" desc="  手机多渠道版 mpay  ">
             case CmdCode::cmd_mpay_pay:                                         # 8807 消费..
-                return self::m_pay($req);                                       # 购买普通商城物品
+                return self::m_pay($req);                                       # ::==> 购买普通商城物品
             case CmdCode::cmd_mpay_get_balance:                                 # 8808 刷新账号余额
-                return self::m_refreshChargeOrders($req);                       # 刷新订单-领取充值金额
+                return self::m_refreshChargeOrders($req);                       # ::==> 刷新订单-领取充值金额
             case CmdCode::cmd_mpay_buyDynamic:                                  # 8809 购买动态商城物品
                 return self::m_pay_buyDynamic($req);
             case CmdCode::cmd_mpay_getDynamic:                                  # 8810 刷新神秘商城物品
                 return self::m_pay_getDynamic($req);
             case CmdCode::cmd_mpay_selfCheckOrders:                             # 8811 自助检查异常订单
                 return self::selfhelpCheckOrders($req);
-            case CmdCode::cmd_mpay_selfCheckOrders:
+            case CmdCode::cmd_mpay_getPayRecords:                               # 8812 查询订单记录
                 return self::GetPayRecoreds($req);
 // </editor-fold>
 
@@ -604,7 +604,7 @@ class PayProc {
         }
         $req->userInfo->game->privateState->firstPayGift = true;                # 设置首付标志
         StoreProc::AddMultiItemInStore($req, $itemModel->goods);                # 发放首付礼包到玩家仓库
-        UserProc::updateUserInfo();                                         # 更新玩家数据
+        UserProc::updateUserInfo();                                             # 更新玩家数据
         return Resp::ok(array('itemid' => $itemId,
                     'rewardstr' => $itemModel->goods,
                     'store' => $req->userInfo->game->store));                   # 回送成功信息

+ 1 - 31
Gameserver/Amfphp/process/PreProc.php

@@ -16,9 +16,7 @@ class PreProc {
      * @return int 返回操作结果,0:成功,其余为错误码
      */
     public static function tk($req) {
-        my_Assert(!config::Inst()->isBaned($req->uid), ErrCode::err_server_updating); # 检查封号
-//        $ret = self::checkVersion($req);                                        # 检查客户端版本 -王刚 已经于2020.4.29 废弃, 改为提前检查版本号了.
-//        my_Assert(ErrCode::ok == $ret, $ret);                                   # 客户端版本过低
+        my_Assert(!config::Inst()->isBaned($req->uid), ErrCode::err_server_updating); # 检查封号 
         # 检查是否处于更新阶段,暂停对玩家请求的响应。
         if (GAME_ONLINE                                                         # 外网
                 && self::isUpdating()                                           # 更新
@@ -68,34 +66,6 @@ class PreProc {
         return substr(md5(substr($siginfo->uid, 2, 20) . $temp . substr($siginfo->sig, 5, 15)), 7, 23);
     }
 
-//    /**
-//     * 检查客户端版本是否需要强制更新
-//     * @param Req $req
-//     * @return int ErrCode
-//     */
-//    public static function checkVersion($req) {
-//        $clientVer = $req->clientVer;
-//        $ClientVerArr = explode('.', $clientVer);
-//        $ServerVerArr = explode('.', glc()->clientVer);
-//
-//        if ($ClientVerArr[0] < $ServerVerArr[0]  #                              # 主版本号小
-//                || $ClientVerArr[1] < $ServerVerArr[1]) {                       # 次版本号小
-//            $req->updateInfo = GameConfig::clientVersionHistory_getItem(glc()->clientVer);
-//            $req->updateInfo->newVer = glc()->clientVer;
-//            return ErrCode::clientversionlow_err;                               # 返回错误码,强制更新1
-//        }
-//
-//        if ($ClientVerArr[0] == $ServerVerArr[0]                                # 主版本号相同
-//                && $ClientVerArr[1] == $ServerVerArr[1]                         # 次版本号相同
-//                && $ClientVerArr[2] < $ServerVerArr[2] && #                     # 修订版本号不一致, 提示更新
-//                ($req->cmd == CmdCode::cmd_user_getzonelist                     # 只在拉取分区列表的时候提示下得了.又不是强更
-//                || $req->cmd == CmdCode::cmd_user_gameconstinfo)) {             # 或者是拉取常量信息也行
-//            $req->updateInfo = GameConfig::clientVersionHistory_getItem(glc()->clientVer); # 提示更新,可以暂不更新,不返回错误码了
-//            $req->updateInfo->newVer = glc()->clientVer;
-//        }
-//        return ErrCode::ok;
-//    }
-
     /**
      *  返回是否处于更新中
      * @return boolean

+ 4 - 18
Gameserver/Amfphp/test.php

@@ -8,24 +8,10 @@ include __DIR__ . '/main.php';
 //set_time_limit(15);                                                           # 设置执行超时时间
 echoLine("phpver:" . PHP_VERSION);
 
-class ABC extends HashSaver {
 
-    public $name;
-    public $age = 35;
+$key = "testzset";
+$key_new = "wanggang";
+gMem()->zcopy($key, $key_new);
 
-    public function __construct($args) {
-        parent::__construct($args);
-//        $this->LoadFrom(array('name' => "wanggangzero"));
-        $url = "http://115.159.121.129/SweepAllTower/CDN/hi.txt";
-        $newVer = HttpUtil::makeRequest($url, array(), array(), array(), "get"); # 取CDN上版本列表
-        $this->name = $newVer;
-    }
+var_dump(gMem()->zrevrange($key_new, 0, -1, true));
 
-}
-
-$arr = array(
-    'name' => '王刚'
-);
-$obj = new ABC($arr);
-var_dump($obj);
-$obj->updateData("test-hash");

+ 10 - 0
Gameserver/Amfphp/util/CRedisUtil.php

@@ -1105,6 +1105,16 @@ class CRedisUtil extends CMemBase {
         $this->redis->zremrangebyscore($key, $min, $max);
     }
 
+    /**
+     * 有序列表 - 复制有序类表到一个新的key
+     * @param string $key_source 源集合
+     * @param string $key_new    目标集合
+     */
+    public function zcopy($key_source, $key_new) {
+        self::debug();
+        $this->redis->zunionstore($key_new, 1, $key_source);
+    }
+
 // </editor-fold>
 //
 // <editor-fold defaultstate="collapsed" desc="    其他api    ">

+ 1 - 14
Gameserver/nbproject/private/private.xml

@@ -11,19 +11,6 @@
         </file>
     </editor-bookmarks>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
-        <group>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/util/HttpUtil.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/RankProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/PayProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/util/dao.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/UserProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/PreProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/HeroProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/model/User/UserInfoMo.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/base/ErrCode.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc/PVPProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/base/MemKey_GameRun.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc.php</file>
-        </group>
+        <group/>
     </open-files>
 </project-private>