Преглед на файлове

调整玩家信息存储结构

gwang преди 5 години
родител
ревизия
056eacfbd0

+ 5 - 0
Gameserver/Amfphp/base/ErrCode.php

@@ -785,6 +785,11 @@ class ErrCode {
     // </editor-fold>
     // ---------战斗错误码----------- 4000
 
+    /**
+     * 关卡挑战 - 难度参数错误
+     */
+    const err_arenas_difficulty = 4004;
+
     /**
      * 关卡挑战记录非法
      */

+ 10 - 12
Gameserver/Amfphp/model/User/PrivateStateModel.php

@@ -6,8 +6,7 @@ namespace loyalsoft;
  * Description of UserGameDataModel
  * 私有状态标志字
  */
-class PrivateStateModel extends Object_ext
-{
+class PrivateStateModel extends Object_ext {
 // ------------字段声明-------------
 //    tian添加7日活动的数据结构
 
@@ -172,8 +171,7 @@ class PrivateStateModel extends Object_ext
     /**
      * 玩家注册时初始化
      */
-    public function initialize()
-    {
+    public function initialize() {
 // 用于给各个字段赋默认初始值
         $this->day7 = JsonUtil::decode(JsonUtil::encode(array('tasks' => ObjectInit(), 'dianshu' => 0)));
         $this->Tasks = ObjectInit();
@@ -195,17 +193,17 @@ class PrivateStateModel extends Object_ext
         $this->lottery = new UserLotteryModel;
         $this->usedTokens = ArrayInit();
 // <editor-fold defaultstate="collapsed" desc="    day7 相关">
-        $con = GameConfig::day7();
-        foreach ($con as $k => $v) {
-            $this->day7->tasks->$k = json_decode('{"state":1}');
-        }
+//        $con = GameConfig::day7();
+//        foreach ($con as $k => $v) {
+//            $this->day7->tasks->$k = json_decode('{"state":1}');
+//        }
 //        var_dump($this->day7);
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="    任务 相关">
-        $conTasks = GameConfig::task();
-        foreach ($conTasks as $k => $v) {
-            $this->Tasks->$k = json_decode('{"state":1}');
-        }
+//        $conTasks = GameConfig::task();
+//        foreach ($conTasks as $k => $v) {
+//            $this->Tasks->$k = json_decode('{"state":1}');
+//        }
 // </editor-fold>
 // <editor-fold defaultstate="collapsed" desc="   成就任务 相关">
 //        $AchiTasks = GameConfig::task_achi();

+ 10 - 2
Gameserver/Amfphp/model/User/UGateModel.php

@@ -9,11 +9,19 @@ namespace loyalsoft;
  * @author gwang (mail@wanggangzero.cn)
  * @copyright ? 2017-2-14, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  */
-class UGateModel extends Object_ext
-{
+class UGateModel extends Object_ext {
 
+    /**
+     *
+     * @var int 得分评星 
+     */
     public $star = 1;
     public $cleared = 0;
+
+    /**
+     *
+     * @var int 挑战次数
+     */
     public $challengeTimes = 0;
 
 }

+ 3 - 12
Gameserver/Amfphp/model/User/UserGateDifficulty.php

@@ -9,10 +9,9 @@ namespace loyalsoft;
  * @author gwang (mail@wanggangzero.cn)
  * @copyright ? 2017-2-14, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  */
-class UserGateDifficulty extends Object_ext
-{
-
+class UserGateDifficulty extends Object_ext {
     ///目前是按关卡的难度来分的结果
+
     /**
      * 普通关卡
      */
@@ -44,13 +43,7 @@ class UserGateDifficulty extends Object_ext
      */
     public $killedBoss;
 
-    /**
-     * @var userCarbonModel 关卡副本数据
-     */
-    public $carbons;
-
-    function __construct($arg = null)
-    {
+    function __construct($arg = null) {
         if (null === $arg) {
             $this->TotalNum = 0;
             $this->Times = 0;
@@ -61,8 +54,6 @@ class UserGateDifficulty extends Object_ext
             $this->elite = new UserGatesModel;
             $this->elite->initialize();
             $this->killedBoss = ArrayInit();
-            $this->carbons = new UserCarbonModel;
-            $this->carbons->initialize();
         } else {
             parent::__construct($arg);
         }

+ 18 - 17
Gameserver/Amfphp/process/FightProc.php

@@ -40,26 +40,27 @@ class FightProc {
             case CmdCode::cmd_fight_ChallengeCarbon:                            # [6809] 挑战副本关卡
                 return SweepGatesProc::NewChallengeCarbon($req);
 // --------- 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);
+//            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);
 //  ----------------- 剧情关卡 ----------------------
             case CmdCode::cmd_fight_Challenge_StoryGate:                        # [6816] 挑战剧情关卡
                 return SweepGatesProc::ChallengeStoryGate($req);
             //------------------------------------------------
             case CmdCode::cmd_new_arenas_fight:                                 # [6817] 新的挑战关卡
+                return Resp::err(ErrCode::function_notopen_msg);
                 return SweepGatesProc::NewArenas_Fight($req);
             case CmdCode::cmd_new_arenas_changeStayCity:                        # [6818] 记录玩家到达哪一关的
                 return SweepGatesProc::ChangeArenas_StayCity($req);
@@ -74,8 +75,8 @@ class FightProc {
      * @param Req $req
      */
     static function ClearByDay($req) {
-        SweepGatesProc::ClearFightRentRecord($req);                             # 清理战斗中租借好友记录
-        SweepGatesProc::ClearGateForeverGold_FightCountEveryDay($req);          # 清理无尽模式的战斗次数记录
+//        SweepGatesProc::ClearFightRentRecord($req);                             # 清理战斗中租借好友记录
+//        SweepGatesProc::ClearGateForeverGold_FightCountEveryDay($req);          # 清理无尽模式的战斗次数记录
         SweepGatesProc::ClearGateTimes($req);                                   # 清理每个难度副本的每日战斗次数
 //        PVPProc::ClearDailyPkcnt($req);                                       # 清理每日挑战次数计数
     }

+ 603 - 616
Gameserver/Amfphp/process/FightProc/SweepGatesProc.php

@@ -7,6 +7,8 @@ namespace loyalsoft;
  * @author gwang
  */
 class SweepGatesProc {
+    //
+    // <editor-fold defaultstate="collapsed" desc="三层关卡">
 
     /**
      * [6817]新版本的挑战地图关卡
@@ -29,7 +31,7 @@ class SweepGatesProc {
         $gold = self::getProperty_n($smGate, "gold", $i);
         $exp = self::getProperty_n($smGate, "exp", $i);
 
-        self::recordFight($req, $gateId, $difficulty, $star);                   # 更新战斗记录
+        self::newRecordFight($req, $gateId, $difficulty, $star);                   # 更新战斗记录
 
         $canfighterr = SweepGatesProc::CanFight($req, $gateId, $difficulty);    # 是否可以挑战当前关卡计算
 
@@ -96,13 +98,13 @@ class SweepGatesProc {
     }
 
     /**
-     * 更新战斗记录
+     * 更新战斗记录(新)
      * @param req $req
      * @param type $gateId
      * @param type $difficulty
      * @param type $star
      */
-    private static function recordFight($req, $gateId, $difficulty, $star) {
+    private static function newRecordFight($req, $gateId, $difficulty, $star) {
         if (!CommUtil::isPropertyExists($req->userInfo->game->gates, "newGateRecord")) {
             $req->userInfo->game->gates->newGateRecord = ObjectInit();          # 防御未初始化的变量
         }
@@ -133,6 +135,42 @@ class SweepGatesProc {
         $req->userInfo->game->gates->newGateRecord = $gatesRecord;              # 回写数据
     }
 
+//    /**
+//     * [6818]更改地图所停留的城镇
+//     * //需要消耗体力
+//     * @param type $req
+//     * @deprecated since version 0
+//     */
+//    public static function ChangeArenas_StayCity($req) {
+//# 提取参数
+//# 0. 目标地址
+//# 1. 消耗体力
+//        $cityId = $req->paras[0];
+//        $costTili = $req->paras[1];
+//        if (!CommUtil::isPropertyExists($req->userInfo->game->gates, "newGateRecord")) {
+//            $req->userInfo->game->gates->newGateRecord = ObjectInit();
+//        }
+//        $gatesRecord = $req->userInfo->game->gates->newGateRecord;
+//
+//        #在此补充检查消耗体力的数值是否正确
+//        #
+//
+//        $gatesRecord->lastStayCityId = $cityId;
+//        $req->userInfo->game->gates->newGateRecord = $gatesRecord;
+//        #体力变化
+//        ActiveProc::ChangeTili(-$costTili, $req);
+//        UserProc::updateUserInfo($req);
+//
+//        $result = array(
+//            'gates' => $req->userInfo->game->gates,
+//            'tili' => $req->userInfo->game->tili,
+//            'time' => $req->userInfo->game->privateState->TiliTime,
+//        );
+//        return Resp::ok($result);
+//    }
+// </editor-fold>
+//
+
     /**
      * 提取某个对象的某个字段(利用后面2个参数组合为字段名)
      * @param type $obj
@@ -151,148 +189,126 @@ class SweepGatesProc {
     }
 
     /**
-     * [6818]更改地图所停留的城镇
-     * //需要消耗体力
-     * @param type $req
+     * [6801] 关卡挑战1次
+     * @param Req $req
+     * @deprecated since version 0 用新版
      */
-    public static function ChangeArenas_StayCity($req) {
-# 提取参数
-# 0. 目标地址
-# 1. 消耗体力
-        $cityId = $req->paras[0];
-        $costTili = $req->paras[1];
-        if (!CommUtil::isPropertyExists($req->userInfo->game->gates, "newGateRecord")) {
-            $req->userInfo->game->gates->newGateRecord = ObjectInit();
+    public static function Arenas_Fight($req) {
+        list($gateId, $difficulty, $star) = $req->paras;                        # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星. 
+
+        $err = self::recordFight($req, $gateId, $difficulty, $star);            # 挑战记录
+        if (ErrCode::ok != $err) {
+            return Resp::err($err);
         }
-        $gatesRecord = $req->userInfo->game->gates->newGateRecord;
+        $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
+        $i = $difficulty + 1;                                                   # 按三个难度取不同的值.
+        $tili = self::getProperty_n($smGate, "tili", $i);
+        $rwdstr = self::getProperty_n($smGate, "reward", $i);
+        $gold = self::getProperty_n($smGate, "gold", $i);
+        $exp = self::getProperty_n($smGate, "exp", $i);
 
-        #在此补充检查消耗体力的数值是否正确
-        #
+//        ActiveProc::ChangeTili(-$tili, $req);                                   # 扣减体力变化 
+//        foreach ($TeamObj as $heroUID) {
+//            HeroProc::HeroAddEXP($heroUID, $tili, $req);                        # 增加英雄经验 这个功能组长取消掉了
+//        }
+//        UserGameModel::Add_Exp($req->mem, $req->userInfo->game, $tili);         # 老的增加玩家经验的去掉
 
-        $gatesRecord->lastStayCityId = $cityId;
-        $req->userInfo->game->gates->newGateRecord = $gatesRecord;
-        #体力变化
-        ActiveProc::ChangeTili(-$costTili, $req);
-        UserProc::updateUserInfo($req);
+        $err = StoreProc::AddMultiItemInStore($req, $rwdstr);                   # 发放战利品
+        if ($err != ErrCode::ok) {
+            return Resp::err($err);
+        }
+
+        UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold);        // 增加发经验和发金币
+        UserGameModel::Add_Exp($req, $exp);
+
+        UserProc::updateUserInfo($req);                                         // 在获取战利品那里已经update了.
 
         $result = array(
+            'store' => $req->userInfo->game->store,
+            'heros' => $req->userInfo->game->heros,
             'gates' => $req->userInfo->game->gates,
             'tili' => $req->userInfo->game->tili,
             'time' => $req->userInfo->game->privateState->TiliTime,
+            'gold' => $gold,
+            'exp' => $exp
         );
         return Resp::ok($result);
     }
 
     /**
-     * [6801] 关卡挑战1次
-     * @param Req $req
-     * @deprecated since version 0 用新版
+     * 更新战斗记录
+     * @param req $req
+     * @param type $gateId
+     * @param type $difficulty
+     * @param type $star
      */
-    public static function Arenas_Fight($req) {
-# 提取参数
-# 0. 挑战的关卡Id
-# 1. 挑战结果  和李宁商量了,挑战结果是没有用的,只有胜利以后才会发送服务器端.所以这里打算改为关卡难度(0,1,2)
-# 2. 挑战记录  // 验证之用.几星.
-#3.队伍信息
-        $gateId = $req->paras[0];
-        $difficulty = $req->paras[1];  ///这里将会改为关卡难度 difficulty
-        $star = $req->paras[2];
-        $TeamObj = $req->paras[3];
-        $bossId = $req->paras[4];      // 本关消灭的bossid (<=0代表本关卡未出现boss)
-
-
-        $isNewbieGuideGate = false;
-        if ($gateId == 504001) {
-            $isNewbieGuideGate = true;
-        }
-
-        $smGate = GameConfig::gate_getItem($gateId);
-///按三个难度取不同的值.
-        if ($difficulty == 0) {
-            $gates = $req->userInfo->game->gates->normal;
-            $tili = $smGate->tili1;
-            $rwdstr = $smGate->reward1;
-            $gold = $smGate->gold1;
-            $exp = $smGate->exp1;
+    private static function recordFight($req, $gateId, $difficulty, $star) {
+        $userGates = $req->userInfo->game->gates;
+        if ($difficulty == 0) {                                                 # 按照难度查找
+            $diffCult = $userGates->normal;
         } else if ($difficulty == 1) {
-            $gates = $req->userInfo->game->gates->hard;
-            $tili = $smGate->tili2;
-            $rwdstr = $smGate->reward2;
-            $gold = $smGate->gold2;
-            $exp = $smGate->exp2;
+            $diffCult = $userGates->hard;
         } else if ($difficulty == 2) {
-            $gates = $req->userInfo->game->gates->elite;
-            $tili = $smGate->tili3;
-            $rwdstr = $smGate->reward3;
-            $gold = $smGate->gold3;
-            $exp = $smGate->exp3;
+            $diffCult = $userGates->elite;
+        } else {
+            return ErrCode::err_arenas_difficulty;                              # 找不到难度类型
         }
 
-        $typeId = substr($gates->highest, 0, 3); #分类
+        $typeId = substr($diffCult->highest, 0, 3);                             # 防御: 分类头不对
         if ($typeId != '503') {
-            $gates->highest = 503000;
+            $diffCult->highest = 503000;                                        # 设置为关卡第一关
+        }
+        if ($gateId > $diffCult->highest + 1) {                                 # 不能跳关
+            return ErrCode::err_arenasgate_indexillegal;
         }
 
-        if (!$isNewbieGuideGate) {
-            if ($gateId > $gates->highest + 1) { # 不能跳关
-                return Resp::err(ErrCode::err_arenasgate_indexillegal);
-            } else if ($gateId == $gates->highest + 1) {
-                $gates->highest += 1; // 更新最高记录
-            }
-
-            $gates->latest = $gateId;
-#记录数据
-            $uGate = new UGateModel();
-            if (isset($gates->gates->$gateId)) {
-                $uGate = $gates->gates->$gateId;
-            }
-            $uGate->challengeTimes++;
-
-            if ($uGate->star < $star) {
-                $uGate->star = $star;
-            }
-            $uGate->cleared = 1;
-            $gates->gates->$gateId = $uGate;
-////体力变化
-//   UserGameModel::Add_Exp($req->mem, $req->userInfo->game, $tili);////老的增加玩家经验的去掉
-            ActiveProc::ChangeTili(-$tili, $req);
-
-///增加英雄经验     这个功能组长取消掉了
-//            foreach ($TeamObj as $heroUID) {
-//                HeroProc::HeroAddEXP($heroUID, $tili, $req);
-//            }
-////总战斗次数+1
-            $req->userInfo->game->gates->TotalNum++;
-            $req->userInfo->game->gates->Times++;
+        if ($gateId == $diffCult->highest + 1) {
+            $diffCult->highest += 1;                                            # 更新最高记录
         }
+        $diffCult->latest = $gateId;                                            # 记录上次挑战关卡id
 
-/////检测如果当前物品格子大于物品总数,则可以获取战利品,否则不可以
-////战利品获取
-        $err = StoreProc::AddMultiItemInStore($req, $rwdstr);
-        if ($err) {
-            return Resp::err($err);
+        $uGate = new UGateModel();                                              # 当前关卡的记录数据
+        if (isset($diffCult->gates->$gateId)) {
+            $uGate = $diffCult->gates->$gateId;
         }
+        $uGate->challengeTimes++;                                               # 当前关卡挑战次数
 
-        if ($bossId > 0) {
-            $req->userInfo->game->gates->killedBoss[] = $bossId;
+        if ($uGate->star < $star) {                                             # 当前关卡得分评星
+            $uGate->star = $star;
         }
+        $uGate->cleared = 1;                                                    # 当前关卡未知                                    
+        $diffCult->gates->$gateId = $uGate;                                     # 回写关卡记录
 
-// 增加发经验和发金币
-        UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $gold);
-        UserGameModel::Add_Exp($req, $exp);
+        $userGates->TotalNum++;                                                 # 总战斗次数+1 
+        $userGates->Times++;
+        $req->userInfo->game->gates = $userGates;                               # 回写数据
 
-        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
+        return ErrCode::ok;
+    }
 
-        $result = array(
-            'store' => $req->userInfo->game->store,
-            'heros' => $req->userInfo->game->heros,
-            'gates' => $req->userInfo->game->gates,
-            'tili' => $req->userInfo->game->tili,
-            'time' => $req->userInfo->game->privateState->TiliTime,
-            'gold' => $gold,
-            'exp' => $exp
-        );
-        return Resp::ok($result);
+    /**
+     * 清理每个难度副本的每日战斗次数
+     * @param Req $req
+     */
+    public static function ClearGateTimes($req) {
+        $req->userInfo->game->gates->Times = 0;
+//        if (!CommUtil::isPropertyExists($req->userInfo->game->gates, 'newGateRecord')) {
+//            $req->userInfo->game->gates->newGateRecord = ObjectInit();
+//        }
+//        if (!CommUtil::isPropertyExists($req->userInfo->game->gates->newGateRecord, 'record')) {
+//            return;
+//        }
+//        $obj = $req->userInfo->game->gates->newGateRecord->record;
+//        //$result = empty($obj);
+//        // if ($result == true) {
+//        //    return;
+//        //}
+//        foreach ($obj as $key => $value) {
+//            $value->normalToday = 0;
+//            $value->hardToday = 0;
+//            $value->eliteToday = 0;
+//        }
+//        UserProc::updateUserInfo($req);
     }
 
 //
@@ -569,516 +585,487 @@ class SweepGatesProc {
         return $resp;
     }
 
-    /**
-     * [6804] 扣除买buffer的费用
-     * @param type $req
-     * @return type
-     */
-    public static function ConsumeBufferGold($req) {
-        $user = $req->userInfo->game; # user引用
-        $money = $req->paras[0]; //需要的手工费
-// echo var_dump($money);
-        $bDeal = UserGameModel::Consume_Gold($user, $money);
-        if ($bDeal) {
-            $result = array(
-                'resp' => "succeed!"
-            );
-//  更新数据库数据
-
-            $resp = Resp::ok($result);
-        } else {
-
-//   $user->gold=0;
-            $result = array(
-                'resp' => "succeed!"
-            );
-//  更新数据库数据
-
-            $resp = Resp::ok($result);
-        }
-        UserProc::updateUserInfo($req);
-        return $resp;
-    }
-
 //
 // <editor-fold defaultstate="collapsed" desc="    好友租借   ">
-
-    /**
-     * [6805] 查询租借好友记录
-     * @param Req $req
-     */
-    public static function GetBorrowedFriends($req) {
-// 查询好友借用记录中的数据
-        $rentedfriends = $req->userInfo->game->privateState->rentedFriends;
-        if (!$rentedfriends || !is_array($rentedfriends)) {
-            $rentedfriends = ArrayInit();
-        }
-        return Resp::ok(array('ret' => $rentedfriends));
-    }
-
-    /**
-     * 清理战斗租借好友记录
-     *
-     */
-    public static function ClearFightRentRecord($req) {
-        $req->userInfo->game->privateState->rentedFriends = ArrayInit();
-    }
-
-    /**
-     * [6806] 扣除借用好友费用
-     * @param Req $req
-     */
-    public static function ConsumeBorrowFriend($req) {
-// 提取参数:好友id
-        $friend_uid = $req->paras[0];
-// 验证好友关系
-        if (!FriendProc::isFriendship($req->zoneid, $req->uid, $friend_uid)) {
-            return Resp::err(ErrCode::friend_no_err);
-        }
-// 验证尚未租借过
-        $rentedfriends = $req->userInfo->game->privateState->rentedFriends;
-        if (!$rentedfriends || !is_array($rentedfriends)) {
-            $rentedfriends = ArrayInit();
-        }
-        if (in_array($friend_uid, $rentedfriends)) {
-            return Resp::err(array('err' => -1, 'msg' => 'has rented this player today!'));
-        }
-// 验证好友出借英雄
-        $friend_info = UserProc::getUserInfo(gMem(), $req->zoneid, $friend_uid);
-        if (!$friend_info) {
-            return Resp::err(ErrCode::user_no_err, '找不到好友的游戏数据!');
-        }
-// todo:啦啦啦... 先不写了,管它用的是哪个英雄呢
+//    /**
+//     * [6805] 查询租借好友记录
+//     * @param Req $req
+//     */
+//    public static function GetBorrowedFriends($req) {
+//// 查询好友借用记录中的数据
+//        $rentedfriends = $req->userInfo->game->privateState->rentedFriends;
+//        if (!$rentedfriends || !is_array($rentedfriends)) {
+//            $rentedfriends = ArrayInit();
+//        }
+//        return Resp::ok(array('ret' => $rentedfriends));
+//    }
 //
-// 扣除费用,失败->金币不足
-        $arr = explode(',', glc()->User_Friends_HireFriendForBattle_Cost);
-        if (count($arr) < 2) {
-            return Resp::err(ErrCode::err_const_no);
-        }
-        $itemid = $arr[0];   # 道具id
-        $amt = $arr[1];      # 数量
-        if ($itemid == META_GOLD_ITEMID) {
-            $user = $req->userInfo->game;
-            if ($user->gold < $amt) {
-                return Resp::err(array('err' => -2, 'msg' => 'gold not enough!'));
-            }
-            UserGameModel::Consume_Gold($user, $amt);
-// todo: 给好友发送金币 邮件
-            EmailProc::SendHireCoinFromFight($req->zoneid, $friend_uid, #
-                    $req->userInfo->game->name, $req->uid, $amt); # 好友收益需要扣除系统税率.
-        } else {
-            return Resp::err(ErrCode::err_const_no);
-        }
-// 添加借用记录
-        $rentedfriends[] = $friend_uid;
-        $req->userInfo->game->privateState->rentedFriends = $rentedfriends;
-// 回写数据
-        UserProc::updateUserInfo($req);                     // 玩家数据
-//        UserProc::setUserInfo(global_mem(), $friend_info);  // 好友数据
-// 返回
-        return Resp::ok(array('err' => 0, 'curgold' => $user->gold));
-    }
-
+//    /**
+//     * 清理战斗租借好友记录
+//     *
+//     */
+//    public static function ClearFightRentRecord($req) {
+//        $req->userInfo->game->privateState->rentedFriends = ArrayInit();
+//    }
+//
+//    /**
+//     * [6806] 扣除借用好友费用
+//     * @param Req $req
+//     */
+//    public static function ConsumeBorrowFriend($req) {
+//// 提取参数:好友id
+//        $friend_uid = $req->paras[0];
+//// 验证好友关系
+//        if (!FriendProc::isFriendship($req->zoneid, $req->uid, $friend_uid)) {
+//            return Resp::err(ErrCode::friend_no_err);
+//        }
+//// 验证尚未租借过
+//        $rentedfriends = $req->userInfo->game->privateState->rentedFriends;
+//        if (!$rentedfriends || !is_array($rentedfriends)) {
+//            $rentedfriends = ArrayInit();
+//        }
+//        if (in_array($friend_uid, $rentedfriends)) {
+//            return Resp::err(array('err' => -1, 'msg' => 'has rented this player today!'));
+//        }
+//// 验证好友出借英雄
+//        $friend_info = UserProc::getUserInfo(gMem(), $req->zoneid, $friend_uid);
+//        if (!$friend_info) {
+//            return Resp::err(ErrCode::user_no_err, '找不到好友的游戏数据!');
+//        }
+//// todo:啦啦啦... 先不写了,管它用的是哪个英雄呢
+////
+//// 扣除费用,失败->金币不足
+//        $arr = explode(',', glc()->User_Friends_HireFriendForBattle_Cost);
+//        if (count($arr) < 2) {
+//            return Resp::err(ErrCode::err_const_no);
+//        }
+//        $itemid = $arr[0];   # 道具id
+//        $amt = $arr[1];      # 数量
+//        if ($itemid == META_GOLD_ITEMID) {
+//            $user = $req->userInfo->game;
+//            if ($user->gold < $amt) {
+//                return Resp::err(array('err' => -2, 'msg' => 'gold not enough!'));
+//            }
+//            UserGameModel::Consume_Gold($user, $amt);
+//// todo: 给好友发送金币 邮件
+//            EmailProc::SendHireCoinFromFight($req->zoneid, $friend_uid, #
+//                    $req->userInfo->game->name, $req->uid, $amt); # 好友收益需要扣除系统税率.
+//        } else {
+//            return Resp::err(ErrCode::err_const_no);
+//        }
+//// 添加借用记录
+//        $rentedfriends[] = $friend_uid;
+//        $req->userInfo->game->privateState->rentedFriends = $rentedfriends;
+//// 回写数据
+//        UserProc::updateUserInfo($req);                     // 玩家数据
+////        UserProc::setUserInfo(global_mem(), $friend_info);  // 好友数据
+//// 返回
+//        return Resp::ok(array('err' => 0, 'curgold' => $user->gold));
+//    }
 // </editor-fold>
+// 
+// <editor-fold defaultstate="collapsed" desc="黄金挑战">
+//    /**
+//     * [6804] 扣除买buffer的费用
+//     * @param type $req
+//     * @return type
+//     */
+//    public static function ConsumeBufferGold($req) {
+//        $user = $req->userInfo->game; # user引用
+//        $money = $req->paras[0]; //需要的手工费
+//// echo var_dump($money);
+//        $bDeal = UserGameModel::Consume_Gold($user, $money);
+//        if ($bDeal) {
+//            $result = array(
+//                'resp' => "succeed!"
+//            );
+////  更新数据库数据
 //
-
-    /**
-     * [6807] 挑战黄金 无穷无尽战斗模式
-     * @param type $req
-     */
-    public static function ChallengeEndlessFightMode_Gold($req) {
-        $gateForeverId = $req->paras[0];
-        $difficuty = $req->paras[1];
-        $bociCount = $req->paras[2];
-//判断是否已经达到挑战的次数上限
-        $gates = $req->userInfo->game->gates;
-
-        if (!CommUtil::isPropertyExists($gates, "forever_Gold_FightTimes")) {
-            $gates->forever_Gold_FightTimes = 0;
-        }
-
-        if ($gates->forever_Gold_FightTimes >= glc()->Battle_Forever_MaxCountEveryDay) {
-            return Resp::err(ErrCode::err_gateForever_countIsFull, '挑战次数已经用尽!');
-        }
-//1.取出无尽模式的关卡常量数据
-        $gateForeverConst = GameConfig::gateforever_getItem($gateForeverId);   // ConstProc::getGold_GateForeverGoldConst($gateForeverId);
-        $gateBattleBociConst = GameConfig::gatecombat_getItem($gateForeverId);
-        if (!$gateForeverConst) {
-            return Resp::err(ErrCode::err_gateForever_const_no);
-        }
-//判断次数是否合法
-        $bociArr = explode(",", $gateBattleBociConst->level);
-        if ($bociCount > count($bociArr)) {
-            return Resp::err(ErrCode::err_gateForever_countillegal);
-        }
-//2.取出模式下的奖励数据
-        $rewardStr = $gateForeverConst->reward1;
-
-        $arr_reward = explode(";", $rewardStr);
-        foreach ($arr_reward as $value) {
-            if (strlen($value) > 0) {
-
-                $arr_RealReward = explode(",", $value);
-                $itemId = $arr_RealReward[0];
-                $itemNum = $arr_RealReward[1];
-
-                $str1 = substr($itemId, 0, 3);
-//3.根据挑战的波次数据,重复累计获得奖励
-                for ($i = 0; $i < $bociCount; $i++) {
-
-                    switch ($str1) {
-///怪物卡或者英雄卡牌获取
-                        case "101":
-                        case "201":
-//                            HeroProc::AddHeroTFromStore($req, $itemId);
-                            break;
-///装备物品的获取.
-                        case "301":
-                        case "302":
-                        case "303":
-                            StoreProc::PutEquipInStore($itemId, $req);
-                            break;
-///宝石的获取
-                        case "304":
-                            StoreProc:: PutOverlyingItemInStore($itemId, $itemNum, $req);
-                            break;
-//金币的获取
-                        case "399":
-                            if ($itemId == "399002") {
-                                UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $itemNum);
-                            }
-                            break;
-                        default:
-                            break;
-                    }
-                }
-            }
-        }
-//4、存储玩家的挑战次数
-        $gates->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes + 1;
-// 回写数据
-        UserProc::updateUserInfo($req);
-        $result = ObjectInit();
-        $result->result = "succeed";
-        $result->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes;
-        $resp = Resp::ok($result);
-        return $resp;
-    }
-
-    /**
-     * 清理挑战无尽模式的 次数记录
-     *
-     */
-    public static function ClearGateForeverGold_FightCountEveryDay($req) {
-        $req->userInfo->game->gates->forever_Gold_FightTimes = 0;
-    }
-
-    /**
-     * 清理每个难度副本的每日战斗次数
-     * @param type $req
-     */
-    public static function ClearGateTimes($req) {
-        if (!CommUtil::isPropertyExists($req->userInfo->game->gates, 'newGateRecord')) {
-            $req->userInfo->game->gates->newGateRecord = ObjectInit();
-        }
-        if (!CommUtil::isPropertyExists($req->userInfo->game->gates->newGateRecord, 'record')) {
-            return;
-        }
-        $obj = $req->userInfo->game->gates->newGateRecord->record;
-        //$result = empty($obj);
-        // if ($result == true) {
-        //    return;
-        //}
-        foreach ($obj as $key => $value) {
-            $value->normalToday = 0;
-            $value->hardToday = 0;
-            $value->eliteToday = 0;
-        }
-        UserProc::updateUserInfo($req);
-    }
-
+//            $resp = Resp::ok($result);
+//        } else {
+//
+////   $user->gold=0;
+//            $result = array(
+//                'resp' => "succeed!"
+//            );
+////  更新数据库数据
+//
+//            $resp = Resp::ok($result);
+//        }
+//        UserProc::updateUserInfo($req);
+//        return $resp;
+//    }
+//    /**
+//     * [6807] 挑战黄金 无穷无尽战斗模式
+//     * @param type $req
+//     */
+//    public static function ChallengeEndlessFightMode_Gold($req) {
+//        $gateForeverId = $req->paras[0];
+//        $difficuty = $req->paras[1];
+//        $bociCount = $req->paras[2];
+////判断是否已经达到挑战的次数上限
+//        $gates = $req->userInfo->game->gates;
+//
+//        if (!CommUtil::isPropertyExists($gates, "forever_Gold_FightTimes")) {
+//            $gates->forever_Gold_FightTimes = 0;
+//        }
+//
+//        if ($gates->forever_Gold_FightTimes >= glc()->Battle_Forever_MaxCountEveryDay) {
+//            return Resp::err(ErrCode::err_gateForever_countIsFull, '挑战次数已经用尽!');
+//        }
+////1.取出无尽模式的关卡常量数据
+//        $gateForeverConst = GameConfig::gateforever_getItem($gateForeverId);   // ConstProc::getGold_GateForeverGoldConst($gateForeverId);
+//        $gateBattleBociConst = GameConfig::gatecombat_getItem($gateForeverId);
+//        if (!$gateForeverConst) {
+//            return Resp::err(ErrCode::err_gateForever_const_no);
+//        }
+////判断次数是否合法
+//        $bociArr = explode(",", $gateBattleBociConst->level);
+//        if ($bociCount > count($bociArr)) {
+//            return Resp::err(ErrCode::err_gateForever_countillegal);
+//        }
+////2.取出模式下的奖励数据
+//        $rewardStr = $gateForeverConst->reward1;
+//
+//        $arr_reward = explode(";", $rewardStr);
+//        foreach ($arr_reward as $value) {
+//            if (strlen($value) > 0) {
+//
+//                $arr_RealReward = explode(",", $value);
+//                $itemId = $arr_RealReward[0];
+//                $itemNum = $arr_RealReward[1];
+//
+//                $str1 = substr($itemId, 0, 3);
+////3.根据挑战的波次数据,重复累计获得奖励
+//                for ($i = 0; $i < $bociCount; $i++) {
+//
+//                    switch ($str1) {
+/////怪物卡或者英雄卡牌获取
+//                        case "101":
+//                        case "201":
+////                            HeroProc::AddHeroTFromStore($req, $itemId);
+//                            break;
+/////装备物品的获取.
+//                        case "301":
+//                        case "302":
+//                        case "303":
+//                            StoreProc::PutEquipInStore($itemId, $req);
+//                            break;
+/////宝石的获取
+//                        case "304":
+//                            StoreProc:: PutOverlyingItemInStore($itemId, $itemNum, $req);
+//                            break;
+////金币的获取
+//                        case "399":
+//                            if ($itemId == "399002") {
+//                                UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $itemNum);
+//                            }
+//                            break;
+//                        default:
+//                            break;
+//                    }
+//                }
+//            }
+//        }
+////4、存储玩家的挑战次数
+//        $gates->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes + 1;
+//// 回写数据
+//        UserProc::updateUserInfo($req);
+//        $result = ObjectInit();
+//        $result->result = "succeed";
+//        $result->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes;
+//        $resp = Resp::ok($result);
+//        return $resp;
+//    }
+//    /**
+//     * 清理挑战无尽模式的 次数记录
+//     *
+//     */
+//    public static function ClearGateForeverGold_FightCountEveryDay($req) {
+//        $req->userInfo->game->gates->forever_Gold_FightTimes = 0;
+//    }
+    // </editor-fold>
 //
 // <editor-fold defaultstate="collapsed" desc="    副本    ">
 //
-
-    /**
-     * [6801] 开启副本
-     * @param Req $req
-     */
-    public static function OpenTheCarbon($req) {
-        $gates = $req->userInfo->game->gates;
-        $openedcarbons = $gates->carbons->openedCarbons;
-# 提取参数
-        $carbonId = $req->paras[0];     # 副本ID
-        $difficulty = $req->paras[1];   # 难度等级 1,2,3
-        $key = "$carbonId-$difficulty"; # 键值
-        if (!($gates && $openedcarbons)) {
-            return Resp::err(ErrCode::err_innerfault);
-        }
-        if ($difficulty > 3 || $difficulty < 1) {
-            return Resp::err(ErrCode::carbon_wrongdifficult);
-        }
-
-        if (CommUtil::isPropertyExists($openedcarbons, $key)) {
-            $carbon = $openedcarbons->$key;
-        } else {
-            $carbon = new CarbonModel();
-        }
-        if ($carbon->closeTs > now()) {
-            return Resp::err(ErrCode::carbon_opened);
-        }
-        $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 常量
-# 扣除开启消耗的道具
-        $keyid = "keyId$difficulty";
-        $keynum = "keyNum$difficulty";
-        $costItemId = $carbonModel->$keyid;
-        $costItemNum = $carbonModel->$keynum;
-
-        $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, $costItemNum);
-        if ($err) { # 扣除失败
-            return Resp::err($err);
-        }
-        $carbon->closeTs = now() + $carbonModel->duration;    # 关闭倒计时
-        $carbon->curIndex = 0;                                # 索引重置为0
-        $openedcarbons->$key = $carbon;
-        $req->userInfo->game->gates->carbons->openedCarbons = $openedcarbons;
-        UserProc::updateUserInfo($req);
-        return Resp::ok(array('err' => 0, 'carbons' => $openedcarbons));
-    }
-
-    /**
-     * 挑战副本关卡
-     * @param Req $req
-     */
-    public static function ChallengeCarbon($req) {
-        $gates = $req->userInfo->game->gates;
-        $carbons = $gates->carbons->openedCarbons;
-# 提取参数
-        $carbonId = $req->paras[0];     # 副本ID
-        $difficulty = $req->paras[1];   # 难度等级 1,2,3
-        $gateindex = $req->paras[2];    # 关卡索引 0,1,2,...
-        $star = $req->paras[3];         # 战斗评价(几星)
-        $TeamObj = $req->paras[4];      # 队伍信息
-//        $bossId = $req->paras[5];       # 本关消灭的bossid (<=0代表本关卡未出现boss)
-        if ($difficulty > 3 || $difficulty < 1) {
-            return Resp::err(ErrCode::carbon_wrongdifficult);
-        }
-        $key = "$carbonId-$difficulty"; # 键值
-# 0 当前副本处于开启状态
-# 1 当前关卡索引,不能跳着打,
-# 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励
-# 3 决定掉落物品, 发给客户端
-# 4 发放对应的经验之类的东西
-# 5 检查是否最后一个关卡, 是, 关闭副本
-# 6 回存数据,返回
-
-        isEditor() && $carbon = new CarbonModel;
-        if (CommUtil::isPropertyExists($carbons, $key)) {
-            $carbon = $carbons->$key;
-        } else {
-            $carbon = null;
-        }
-        if (!$carbon || $carbon->closeTs < now()) {
-            return Resp::err(ErrCode::carbon_closed);
-        }
-
-        $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 副本常量数据
-        $gateIds = explode(',', $carbonModel->gateids);
-        if ($gateindex < 0 || $gateindex >= count($gateIds)) {
-            return Resp::err(ErrCode::carbon_gateIndex);
-        }
-        if ($carbon->curIndex == $gateindex || $gateindex == 0) {
-            $carbon->curIndex += 1; # 更新进度
-        } else { # 不能跳关
-            return Resp::err(ErrCode::carbon_gateIndex);
-        }
-
-        $gateId = $gateIds[$gateindex];    # 通过索引获得关卡ID
-        $tl = "tili$difficulty";           # 体力难度
-        $rwd = "reward$difficulty";        # 奖励难度
-        $arr = array("normal", 'hard', 'elite');  # 难度名称
-        $gt = $arr[$difficulty - 1];       # 关卡分类
-        $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据
-        $tili = $gateModel->$tl;                        # 扣除体力
-        $reward = $gateModel->$rwd;                     # 获得奖励
-#
-# 打副本呢也要扣除体力
-        ActiveProc::ChangeTili(-$tili, $req);
-# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109
-        UserGameModel::Add_Exp($req, $tili);
-# 增加英雄经验(也是依据扣除的体力数)
-        foreach ($TeamObj as $heroUID) {
-            HeroProc::HeroAddEXP($heroUID, $tili, $req);
-        }
-//        $carbon->stars;  暂不记录了
-# 掉落战利品->获取
-        $err = StoreProc::AddMultiItemInStore($req, $reward);
-        if ($err) {
-            return Resp::err($err);
-        }
-        if (count($gateIds) == $gateindex + 1) { # 最后一个关卡
-            unset($carbons->$key);               # 关闭掉关卡,或者是直接删掉
-        } else {
-            $carbons->$key = $carbon;            # 回存数据
-        }
-        $req->userInfo->game->gates->carbons->openedCarbons = $carbons;
-        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
-        # Ps.备注,奖品是固定的,所以不必返回
-        $result = array(
-            'store' => $req->userInfo->game->store,
-            'heros' => $req->userInfo->game->heros,
-            'gates' => $req->userInfo->game->gates,
-            'tili' => $req->userInfo->game->tili,
-            'time' => $req->userInfo->game->privateState->TiliTime
-        );
-        return Resp::ok($result);
-    }
-
-    /**
-     * [6809]新版本的挑战 副本胜利
-     * @param Req $req
-     */
-    public static function NewChallengeCarbon($req) {
-        $gates = $req->userInfo->game->gates;
-        $carbons = $gates->carbons->openedCarbons;
-# 提取参数
-        $carbonId = $req->paras[0];     # 副本ID
-        $gateId = $req->paras[1]; # 关卡ID
-        $difficulty = $req->paras[2];   # 难度等级 1,2,3
-
-        $star = $req->paras[3];         # 战斗评价(几星)
-        $TeamObj = $req->paras[4];      # 队伍信息
-
-        if ($difficulty > 3 || $difficulty < 1) {
-            return Resp::err(ErrCode::carbon_wrongdifficult);
-        }
-        $key = "$carbonId-$difficulty"; # 键值
-        # 0 当前副本处于开启状态
-        # 1 战斗胜利之后,副本直接关闭
-        # 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励
-        # 3 决定掉落物品, 发给客户端
-        # 4 发放对应的经验之类的东西
-        # 5 检查是否最后一个关卡, 是, 关闭副本
-        # 6 回存数据,返回
-
-        isEditor() && $carbon = new CarbonModel;
-        if (CommUtil::isPropertyExists($carbons, $key)) {
-            $carbon = $carbons->$key;
-        } else {
-            $carbon = null;
-        }
-        if (!$carbon || $carbon->closeTs < now()) {
-            return Resp::err(ErrCode::carbon_closed);
-        }
-        unset($carbons->$key);
-        $tl = "tili$difficulty";           # 体力难度
-        $rwd = "reward$difficulty";        # 奖励难度
-
-        $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据
-        $tili = $gateModel->$tl;                        # 扣除体力
-        $reward = $gateModel->$rwd;                     # 获得奖励
-        #
-        # 打副本呢也要扣除体力
-        ActiveProc::ChangeTili(-$tili, $req);
-
-        // 按照概率规则发放奖品
-        $rewardsArr = explode(";", $reward);
-        $rwds = array();
-        foreach ($rewardsArr as $r) {
-            $arr = explode(',', $r);
-            $itemid = intval($arr[0]);
-            $num = intval($arr[1]);
-            $probability = floatval($arr[2]);                                   # 掉落概率精度精确到±0.01%
-            if (CommUtil::randomPercent($probability)) {                        # 投色子
-                $err = StoreProc::AddMultiItemInStore($req, "$itemid,$num");
-                if ($err) {
-                    return Resp::err($err);
-                }
-                $rwds[] = "$itemid,$num";
-            }
-        }
-
-        if ($err) {
-            return Resp::err($err);
-        }
-
-        $req->userInfo->game->gates->carbons->openedCarbons = $carbons;
-        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
-        # Ps.备注,奖品是固定的,所以不必返回
-        SystemProc::Carbon_Win($req->zoneid, $req->userInfo->game, $carbonId, $difficulty); # 插入通过副本消息
-        $result = array(
-            'store' => $req->userInfo->game->store,
-            'heros' => $req->userInfo->game->heros,
-            'gates' => $req->userInfo->game->gates,
-            'tili' => $req->userInfo->game->tili,
-            'time' => $req->userInfo->game->privateState->TiliTime,
-            'gold' => 0,
-            'exp' => 0,
-            'rewardstr' => implode(';', $rwds)
-        );
-        return Resp::ok($result);
-    }
-
-    /**
-     * [6816] 挑战剧情关卡
-     * @param type $req
-     */
-    public static function ChallengeStoryGate($req) {
-        $gates = $req->userInfo->game->gates;
-# 提取参数
-        $storyId = $req->paras[0];      # 剧情ID
-        $difficulty = $req->paras[1];   # 难度等级 1,2,3
-        $star = $req->paras[2];         # 战斗评价(几星)
-        $TeamObj = $req->paras[3];      # 队伍信息
-        $bossId = $req->paras[4];       # 本关消灭的bossid (<=0代表本关卡未出现boss)
+//    /**
+//     * [6801] 开启副本
+//     * @param Req $req
+//     * @deprecated since version 0
+//     */
+//    public static function OpenTheCarbon($req) {
+//        $gates = $req->userInfo->game->gates;
+//        $openedcarbons = $gates->carbons->openedCarbons;
+//# 提取参数
+//        $carbonId = $req->paras[0];     # 副本ID
+//        $difficulty = $req->paras[1];   # 难度等级 1,2,3
+//        $key = "$carbonId-$difficulty"; # 键值
+//        if (!($gates && $openedcarbons)) {
+//            return Resp::err(ErrCode::err_innerfault);
+//        }
+//        if ($difficulty > 3 || $difficulty < 1) {
+//            return Resp::err(ErrCode::carbon_wrongdifficult);
+//        }
 //
-#1.   判断是否有记录过剧情的战斗信息
-        if (!CommUtil::isPropertyExists($gates, "story")) {
-            $gates->story = ObjectInit();
-            $gates->story->lastFinishedStoryGateId = 0;
-            $gates->story->allFinishedStoryGateIdList = ArrayInit();
-        }
-        $storrRecord = $gates->story;
-#2.取出模式下的奖励数据
-        $memStoryModel = GameConfig::gatestory_getItem($storyId);
-        $tili = 0;
-        $rewardStr = $memStoryModel->storyGateReward;
-
-#3 同步下剧情的推进进度数据
-        if ($storrRecord->lastFinishedStoryGateId == $storyId || in_array($storyId, $storrRecord->allFinishedStoryGateIdList)) {
-            return Resp::err(ErrCode::story_repeatfight); #剧情关卡不能重复战斗 只能打一次
-        } else {
-            $storrRecord->lastFinishedStoryGateId = $storyId;
-            $storrRecord->allFinishedStoryGateIdList[] = $storyId;
-        }
-#
-# 4 万一打剧情也扣除体力呢
-        if ($tili > 0) {
-            ActiveProc::ChangeTili(-$tili, $req);
-# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109
-            UserGameModel::Add_Exp($req, $tili);
-# 增加英雄经验(也是依据扣除的体力数)
-            foreach ($TeamObj as $heroUID) {
-                HeroProc::HeroAddEXP($heroUID, $tili, $req);
-            }
-        }# 5 玩家获得 剧情的战斗奖励
-        $err = StoreProc::AddMultiItemInStore($req, $rewardStr);
-        if ($err) {
-            return Resp::err($err);
-        }# 6 回存玩家的战斗记录
-        $req->userInfo->game->gates->story = $storrRecord;
-        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
-        # Ps.备注,奖品是固定的,所以不必返回
-        $result = array(
-            'store' => $req->userInfo->game->store,
-            'heros' => $req->userInfo->game->heros,
-            'gates' => $req->userInfo->game->gates,
-            'tili' => $req->userInfo->game->tili,
-            'time' => $req->userInfo->game->privateState->TiliTime
-        );
-        return Resp::ok($result);
-    }
-
+//        if (CommUtil::isPropertyExists($openedcarbons, $key)) {
+//            $carbon = $openedcarbons->$key;
+//        } else {
+//            $carbon = new CarbonModel();
+//        }
+//        if ($carbon->closeTs > now()) {
+//            return Resp::err(ErrCode::carbon_opened);
+//        }
+//        $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 常量
+//# 扣除开启消耗的道具
+//        $keyid = "keyId$difficulty";
+//        $keynum = "keyNum$difficulty";
+//        $costItemId = $carbonModel->$keyid;
+//        $costItemNum = $carbonModel->$keynum;
+//
+//        $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, $costItemNum);
+//        if ($err) { # 扣除失败
+//            return Resp::err($err);
+//        }
+//        $carbon->closeTs = now() + $carbonModel->duration;    # 关闭倒计时
+//        $carbon->curIndex = 0;                                # 索引重置为0
+//        $openedcarbons->$key = $carbon;
+//        $req->userInfo->game->gates->carbons->openedCarbons = $openedcarbons;
+//        UserProc::updateUserInfo($req);
+//        return Resp::ok(array('err' => 0, 'carbons' => $openedcarbons));
+//    }
+//    /**
+//     * 挑战副本关卡
+//     * @param Req $req
+//     * @deprecated since version number
+//     */
+//    public static function ChallengeCarbon($req) {
+//        $gates = $req->userInfo->game->gates;
+//        $carbons = $gates->carbons->openedCarbons;
+//# 提取参数
+//        $carbonId = $req->paras[0];     # 副本ID
+//        $difficulty = $req->paras[1];   # 难度等级 1,2,3
+//        $gateindex = $req->paras[2];    # 关卡索引 0,1,2,...
+//        $star = $req->paras[3];         # 战斗评价(几星)
+//        $TeamObj = $req->paras[4];      # 队伍信息
+////        $bossId = $req->paras[5];       # 本关消灭的bossid (<=0代表本关卡未出现boss)
+//        if ($difficulty > 3 || $difficulty < 1) {
+//            return Resp::err(ErrCode::carbon_wrongdifficult);
+//        }
+//        $key = "$carbonId-$difficulty"; # 键值
+//# 0 当前副本处于开启状态
+//# 1 当前关卡索引,不能跳着打,
+//# 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励
+//# 3 决定掉落物品, 发给客户端
+//# 4 发放对应的经验之类的东西
+//# 5 检查是否最后一个关卡, 是, 关闭副本
+//# 6 回存数据,返回
+//
+//        isEditor() && $carbon = new CarbonModel;
+//        if (CommUtil::isPropertyExists($carbons, $key)) {
+//            $carbon = $carbons->$key;
+//        } else {
+//            $carbon = null;
+//        }
+//        if (!$carbon || $carbon->closeTs < now()) {
+//            return Resp::err(ErrCode::carbon_closed);
+//        }
+//
+//        $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 副本常量数据
+//        $gateIds = explode(',', $carbonModel->gateids);
+//        if ($gateindex < 0 || $gateindex >= count($gateIds)) {
+//            return Resp::err(ErrCode::carbon_gateIndex);
+//        }
+//        if ($carbon->curIndex == $gateindex || $gateindex == 0) {
+//            $carbon->curIndex += 1; # 更新进度
+//        } else { # 不能跳关
+//            return Resp::err(ErrCode::carbon_gateIndex);
+//        }
+//
+//        $gateId = $gateIds[$gateindex];    # 通过索引获得关卡ID
+//        $tl = "tili$difficulty";           # 体力难度
+//        $rwd = "reward$difficulty";        # 奖励难度
+//        $arr = array("normal", 'hard', 'elite');  # 难度名称
+//        $gt = $arr[$difficulty - 1];       # 关卡分类
+//        $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据
+//        $tili = $gateModel->$tl;                        # 扣除体力
+//        $reward = $gateModel->$rwd;                     # 获得奖励
+//#
+//# 打副本呢也要扣除体力
+//        ActiveProc::ChangeTili(-$tili, $req);
+//# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109
+//        UserGameModel::Add_Exp($req, $tili);
+//# 增加英雄经验(也是依据扣除的体力数)
+//        foreach ($TeamObj as $heroUID) {
+//            HeroProc::HeroAddEXP($heroUID, $tili, $req);
+//        }
+////        $carbon->stars;  暂不记录了
+//# 掉落战利品->获取
+//        $err = StoreProc::AddMultiItemInStore($req, $reward);
+//        if ($err) {
+//            return Resp::err($err);
+//        }
+//        if (count($gateIds) == $gateindex + 1) { # 最后一个关卡
+//            unset($carbons->$key);               # 关闭掉关卡,或者是直接删掉
+//        } else {
+//            $carbons->$key = $carbon;            # 回存数据
+//        }
+//        $req->userInfo->game->gates->carbons->openedCarbons = $carbons;
+//        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
+//        # Ps.备注,奖品是固定的,所以不必返回
+//        $result = array(
+//            'store' => $req->userInfo->game->store,
+//            'heros' => $req->userInfo->game->heros,
+//            'gates' => $req->userInfo->game->gates,
+//            'tili' => $req->userInfo->game->tili,
+//            'time' => $req->userInfo->game->privateState->TiliTime
+//        );
+//        return Resp::ok($result);
+//    }
+//    /**
+//     * [6809]新版本的挑战 副本胜利
+//     * @param Req $req
+//     * @deprecated since version 0
+//     */
+//    public static function NewChallengeCarbon($req) {
+//        $gates = $req->userInfo->game->gates;
+//        $carbons = $gates->carbons->openedCarbons;
+//# 提取参数
+//        $carbonId = $req->paras[0];     # 副本ID
+//        $gateId = $req->paras[1]; # 关卡ID
+//        $difficulty = $req->paras[2];   # 难度等级 1,2,3
+//
+//        $star = $req->paras[3];         # 战斗评价(几星)
+//        $TeamObj = $req->paras[4];      # 队伍信息
+//
+//        if ($difficulty > 3 || $difficulty < 1) {
+//            return Resp::err(ErrCode::carbon_wrongdifficult);
+//        }
+//        $key = "$carbonId-$difficulty"; # 键值
+//        # 0 当前副本处于开启状态
+//        # 1 战斗胜利之后,副本直接关闭
+//        # 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励
+//        # 3 决定掉落物品, 发给客户端
+//        # 4 发放对应的经验之类的东西
+//        # 5 检查是否最后一个关卡, 是, 关闭副本
+//        # 6 回存数据,返回
+//
+//        isEditor() && $carbon = new CarbonModel;
+//        if (CommUtil::isPropertyExists($carbons, $key)) {
+//            $carbon = $carbons->$key;
+//        } else {
+//            $carbon = null;
+//        }
+//        if (!$carbon || $carbon->closeTs < now()) {
+//            return Resp::err(ErrCode::carbon_closed);
+//        }
+//        unset($carbons->$key);
+//        $tl = "tili$difficulty";           # 体力难度
+//        $rwd = "reward$difficulty";        # 奖励难度
+//
+//        $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据
+//        $tili = $gateModel->$tl;                        # 扣除体力
+//        $reward = $gateModel->$rwd;                     # 获得奖励
+//        #
+//        # 打副本呢也要扣除体力
+//        ActiveProc::ChangeTili(-$tili, $req);
+//
+//        // 按照概率规则发放奖品
+//        $rewardsArr = explode(";", $reward);
+//        $rwds = array();
+//        foreach ($rewardsArr as $r) {
+//            $arr = explode(',', $r);
+//            $itemid = intval($arr[0]);
+//            $num = intval($arr[1]);
+//            $probability = floatval($arr[2]);                                   # 掉落概率精度精确到±0.01%
+//            if (CommUtil::randomPercent($probability)) {                        # 投色子
+//                $err = StoreProc::AddMultiItemInStore($req, "$itemid,$num");
+//                if ($err) {
+//                    return Resp::err($err);
+//                }
+//                $rwds[] = "$itemid,$num";
+//            }
+//        }
+//
+//        if ($err) {
+//            return Resp::err($err);
+//        }
+//
+//        $req->userInfo->game->gates->carbons->openedCarbons = $carbons;
+//        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
+//        # Ps.备注,奖品是固定的,所以不必返回
+//        SystemProc::Carbon_Win($req->zoneid, $req->userInfo->game, $carbonId, $difficulty); # 插入通过副本消息
+//        $result = array(
+//            'store' => $req->userInfo->game->store,
+//            'heros' => $req->userInfo->game->heros,
+//            'gates' => $req->userInfo->game->gates,
+//            'tili' => $req->userInfo->game->tili,
+//            'time' => $req->userInfo->game->privateState->TiliTime,
+//            'gold' => 0,
+//            'exp' => 0,
+//            'rewardstr' => implode(';', $rwds)
+//        );
+//        return Resp::ok($result);
+//    }
+//    /**
+//     * [6816] 挑战剧情关卡
+//     * @param type $req
+//     * @deprecated since version 0
+//     */
+//    public static function ChallengeStoryGate($req) {
+//        $gates = $req->userInfo->game->gates;
+//# 提取参数
+//        $storyId = $req->paras[0];      # 剧情ID
+//        $difficulty = $req->paras[1];   # 难度等级 1,2,3
+//        $star = $req->paras[2];         # 战斗评价(几星)
+//        $TeamObj = $req->paras[3];      # 队伍信息
+//        $bossId = $req->paras[4];       # 本关消灭的bossid (<=0代表本关卡未出现boss)
+////
+//#1.   判断是否有记录过剧情的战斗信息
+//        if (!CommUtil::isPropertyExists($gates, "story")) {
+//            $gates->story = ObjectInit();
+//            $gates->story->lastFinishedStoryGateId = 0;
+//            $gates->story->allFinishedStoryGateIdList = ArrayInit();
+//        }
+//        $storrRecord = $gates->story;
+//#2.取出模式下的奖励数据
+//        $memStoryModel = GameConfig::gatestory_getItem($storyId);
+//        $tili = 0;
+//        $rewardStr = $memStoryModel->storyGateReward;
+//
+//#3 同步下剧情的推进进度数据
+//        if ($storrRecord->lastFinishedStoryGateId == $storyId || in_array($storyId, $storrRecord->allFinishedStoryGateIdList)) {
+//            return Resp::err(ErrCode::story_repeatfight); #剧情关卡不能重复战斗 只能打一次
+//        } else {
+//            $storrRecord->lastFinishedStoryGateId = $storyId;
+//            $storrRecord->allFinishedStoryGateIdList[] = $storyId;
+//        }
+//#
+//# 4 万一打剧情也扣除体力呢
+//        if ($tili > 0) {
+//            ActiveProc::ChangeTili(-$tili, $req);
+//# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109
+//            UserGameModel::Add_Exp($req, $tili);
+//# 增加英雄经验(也是依据扣除的体力数)
+//            foreach ($TeamObj as $heroUID) {
+//                HeroProc::HeroAddEXP($heroUID, $tili, $req);
+//            }
+//        }# 5 玩家获得 剧情的战斗奖励
+//        $err = StoreProc::AddMultiItemInStore($req, $rewardStr);
+//        if ($err) {
+//            return Resp::err($err);
+//        }# 6 回存玩家的战斗记录
+//        $req->userInfo->game->gates->story = $storrRecord;
+//        UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
+//        # Ps.备注,奖品是固定的,所以不必返回
+//        $result = array(
+//            'store' => $req->userInfo->game->store,
+//            'heros' => $req->userInfo->game->heros,
+//            'gates' => $req->userInfo->game->gates,
+//            'tili' => $req->userInfo->game->tili,
+//            'time' => $req->userInfo->game->privateState->TiliTime
+//        );
+//        return Resp::ok($result);
+//    }
 //
 // </editor-fold>
 //

+ 1 - 0
Gameserver/Amfphp/process/StoreProc.php

@@ -844,6 +844,7 @@ class StoreProc {
 
     /**
      * 解包多种物品到玩家身上 【警告】此函数的异常处理功能残废,不安全
+     * 检测如果当前物品格子大于物品总数,则可以获取战利品,否则不可以 
      * @param Req $req
      * @param string $goodsStr itemid,num;itemid,num;...
      * @param int $src 1:战斗奖励, 2: 任务奖励, 3: 抽奖奖品, 4: 邮件领取, 5: 现金充值

+ 4 - 2
Gameserver/nbproject/private/private.xml

@@ -12,9 +12,11 @@
     </editor-bookmarks>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
         <group>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Services/TestServer.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/model/User/UGateModel.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/UserProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/util/CLog.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Services/TestServer.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/FightProc/SweepGatesProc.php</file>
         </group>
     </open-files>
 </project-private>