gwang пре 4 година
родитељ
комит
0954c65fc6
2 измењених фајлова са 132 додато и 135 уклоњено
  1. 26 26
      Gameserver/Amfphp/process/FightProc/SweepGatesProc.php
  2. 106 109
      Gameserver/Amfphp/process/HeroProc.php

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

@@ -26,12 +26,12 @@ class SweepGatesProc {
     }
 
     /**
-     * [6800] 关卡战斗 - 预计算掉落 
+     * [6800] 关卡战斗 - 预计算掉落
      */
     public static function Arenas_preFight() {
-        list($gateId, $difficulty) = req()->paras;                               # 提取参数 
+        list($gateId, $difficulty) = req()->paras;                               # 提取参数
         my_Assert($gateId > 0, "关卡id非法");
-        $isFirst = self::isFirstChallenge($gateId, $difficulty);                # 是否首次通关 
+        $isFirst = self::isFirstChallenge($gateId, $difficulty);                # 是否首次通关
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $i = $difficulty + 1;                                                   # 按三个难度取不同的值.
 //        $tili = self::getProperty_n($smGate, "tili", $i);                     # 体力暂时未用上
@@ -84,9 +84,9 @@ class SweepGatesProc {
         if (!property_exists($chapterInfo, $hard)) {                            # 防御当前难度数据未创建
             $chapterInfo->$hard = array();
         }
-        $starsArr = $chapterInfo->$hard;                                        # 当前章节,当前难度的领取记录 
+        $starsArr = $chapterInfo->$hard;                                        # 当前章节,当前难度的领取记录
         my_Assert(!in_array($stars, $starsArr), ErrCode::err_arenas_hasgetstarreward); # 奖励已领取
-        $rwdCfgArr = GameConfig::gate_starreward_getItem($chapterId, $hard);    # 奖励配置数组 
+        $rwdCfgArr = GameConfig::gate_starreward_getItem($chapterId, $hard);    # 奖励配置数组
         $starCfg = StlUtil::arrayFind($rwdCfgArr, function ($v, $k)use ($stars) { # 在数组中查找到对应星数的奖励
                     return ($v->star == $stars);
                 });
@@ -106,7 +106,7 @@ class SweepGatesProc {
             default:
                 break;
         }
-        my_Assert(null != $userGateL, ErrCode::err_innerfault);                 # 玩家数据有问题 
+        my_Assert(null != $userGateL, ErrCode::err_innerfault);                 # 玩家数据有问题
         array_walk($userGateL->gates, function ($v, $k)use (&$sumOfStars) {     # 累加星数
             $sinfo = new GateStar($v->star);
             $sumOfStars += $sinfo->Stars();
@@ -120,11 +120,11 @@ class SweepGatesProc {
         return Resp::ok(array("store" => ctx()->store(),
                     'gold' => ctx()->base()->gold,
                     'cash' => ctx()->base()->cash
-        ));         # 返回值  
+        ));         # 返回值
     }
 
     /**
-     * [6801] 关卡挑战1次 
+     * [6801] 关卡挑战1次
      */
     public static function Arenas_Fight() {
         $gateId = req()->paras[0];
@@ -172,14 +172,14 @@ class SweepGatesProc {
     }
 
     /**
-     * 通关普通关卡 
+     * 通关普通关卡
      */
     private static function _NormalGate() {
         list($gateId, $difficulty, $star, $TeamObj) = req()->paras;             # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍, 奖励字符串
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $isFirst = false;                                                       # 是否首次通关
-        self::recordFight($gateId, $difficulty, $star, $isFirst);               # 更新挑战记录 
-        $i = $difficulty + 1;                                                   # 按三个难度取不同的值. 
+        self::recordFight($gateId, $difficulty, $star, $isFirst);               # 更新挑战记录
+        $i = $difficulty + 1;                                                   # 按三个难度取不同的值.
 //        $gold = self::getProperty_n($smGate, "gold", $i);
         $exp = self::getProperty_n($smGate, "exp", $i);
         $firstExp = self::getProperty_n($smGate, "first_exp", $i);
@@ -188,18 +188,18 @@ class SweepGatesProc {
         if ($isFirst) {                                                         # 是否首次通关切换奖励内容
             $exp = $firstExp;
             if ($firstHero > 0) {                                               # 首次通关解锁英雄
-                HeroProc::AddHeroWithStar(req(), $firstHero, 0);                 # 添加英雄
+                HeroProc::AddHeroWithStar($firstHero, 0);                       # 添加英雄
             }
         }
 
-//        $rewardArr = self::SetRewards($req, $rewardStr);                        # 发通关奖励 
+//        $rewardArr = self::SetRewards($req, $rewardStr);                        # 发通关奖励
 //        Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold);         # 发金币
 //        Data_UserGame::Add_Exp(req()->userInfo->game->baseInfo, $exp);           # 给玩家(指挥官)增加经验
         req()->userInfo->game->base()->Add_Exp($exp);                           # 给玩家(指挥官)增加经验
         foreach ($TeamObj as $heroUID) {
             if ($heroUID > 0) {
                 echoLine("$heroUID");
-                HeroProc::HeroAddEXP($heroUID, $heroExp);                       # 增加英雄经验 
+                HeroProc::HeroAddEXP($heroUID, $heroExp);                       # 增加英雄经验
             }
         }
         UserProc::updateUserInfo();                                             # 回写玩家数据.
@@ -230,7 +230,7 @@ class SweepGatesProc {
     public static function SetRewards($rewardStr) {
         $getedArr = array();                                                    # 统计所获奖励物品
         $rewardsArr = explode(";", $rewardStr);
-        foreach ($rewardsArr as $r) {                                           #    
+        foreach ($rewardsArr as $r) {                                           #
             if (strlen($r) > 0) {
 //            $percentStr = explode(',', $r)[2];
 //            $percent = intval(trim($percentStr, "%"));                          # 剔除%
@@ -245,7 +245,7 @@ class SweepGatesProc {
     }
 
     /**
-     * 更新战斗记录 
+     * 更新战斗记录
      * @param type $gateId
      * @param type $difficulty
      * @param type $star
@@ -279,7 +279,7 @@ class SweepGatesProc {
     }
 
     /**
-     * 更新战斗记录 
+     * 更新战斗记录
      * @param type $gateId
      * @param type $difficulty
      * @param type $star
@@ -316,20 +316,20 @@ class SweepGatesProc {
             $uGate = $diffCult->gates->$gateId;
         }
         $uGate->challengeTimes++;                                               # 当前关卡挑战次数
-        $uGate->star |= $star;                                                  # 当前关卡得分评星 
+        $uGate->star |= $star;                                                  # 当前关卡得分评星
         if (!$uGate->cleared) {
-            $uGate->cleared = 1;                                                # 当前关卡是否已通关     
+            $uGate->cleared = 1;                                                # 当前关卡是否已通关
             $isFirst = true;
         }
         $diffCult->gates->$gateId = $uGate;                                     # 回写关卡记录
 
-        $userGates->TotalNum++;                                                 # 总战斗次数+1 
+        $userGates->TotalNum++;                                                 # 总战斗次数+1
         $userGates->Times++;
         req()->userInfo->game->gates = $userGates;                               # 回写数据
     }
 
     /**
-     * 清理每个难度副本的每日战斗次数 
+     * 清理每个难度副本的每日战斗次数
      */
     public static function ClearGateTimes() {
         req()->userInfo->game->gates->Times = 0;
@@ -339,7 +339,7 @@ class SweepGatesProc {
 // <editor-fold defaultstate="collapsed" desc=" 扫荡  ">
 
     /**
-     * [6802]新扫荡 
+     * [6802]新扫荡
      */
     public static function Arenas_NewSweepFight() {
         Err(ErrCode::err_method_obsoleted);                                     # 没开扫荡功能
@@ -380,7 +380,7 @@ class SweepGatesProc {
                 $rwds[] = "$itemid,$num";
             }
         }
-        $user->base()->Add_Gold($gold);                                         # 发放金币奖励 
+        $user->base()->Add_Gold($gold);                                         # 发放金币奖励
         my_Assert(ErrCode::ok == $err, $err);                                   # 失败
 //        Data_UserGame::Add_Exp($user->baseInfo, $exp);                          # 发放经验奖励
         $user->base()->Add_Exp($exp);                                           # 发放经验奖励
@@ -399,7 +399,7 @@ class SweepGatesProc {
     }
 
     /**
-     * 是否可以战斗 
+     * 是否可以战斗
      * @param $gateId
      * @param $difficulty
      * @return type
@@ -454,7 +454,7 @@ class SweepGatesProc {
         return null;   // false
     }
 
-// </editor-fold> 
+// </editor-fold>
 //
 // <editor-fold defaultstate="collapsed" desc="    好友租借   ">
 //    /**
@@ -533,7 +533,7 @@ class SweepGatesProc {
 //        return Resp::ok(array('err' => 0, 'curgold' => $user->gold));
 //    }
 // </editor-fold>
-// 
+//
 // <editor-fold defaultstate="collapsed" desc="黄金挑战">
 //    /**
 //     * [6804] 扣除买buffer的费用

+ 106 - 109
Gameserver/Amfphp/process/HeroProc.php

@@ -10,7 +10,7 @@ class HeroProc {
 
     /**
      * 英雄处理逻辑分发
-     * 所有的Proc中必须有这样一个方法 
+     * 所有的Proc中必须有这样一个方法
      */
     static function procMain() {
         switch (req()->cmd) {
@@ -18,17 +18,17 @@ class HeroProc {
                 return HeroProc::HeroLevelUpCostExpItem();
             case CmdCode::cmd_hero_tupo:                                        #  [6301] 英雄升级
                 return HeroProc::tupo();
-                
-            // <editor-fold defaultstate="collapsed" desc="过时 接口">                
+
+            // <editor-fold defaultstate="collapsed" desc="过时 接口">
             case CmdCode::cmd_hero_stageup:                                     #  [6304] 英雄进阶 SABCD
                 return HeroProc::HeroStageUp();
 
 //            case CmdCode::cmd_hero_upstar:                                    #  [6305] 英雄升星
 //                return HeroProc::HeroUpStarByPieces();
 //            case CmdCode::cmd_hero_changelockstate:                           #  [6306] 英雄-修改锁定状态
-//                return HeroProc::HeroChangelockstate(); 
+//                return HeroProc::HeroChangelockstate();
 //            case CmdCode::cmd_hero_buyCollectHeroLimtCount:                   #  [6312] 扩展英雄数量上限
-//                return HeroProc::BuyHeroMaxCountLimt(); 
+//                return HeroProc::BuyHeroMaxCountLimt();
             // <editor-fold defaultstate="collapsed" desc="---------------英雄评论----------------">
 //            case CmdCode::cmd_hero_GetDiscuss:                                  #  [6316]拉取英雄评论
 //                return HeroDiscussProc::GetDiscusses();
@@ -47,13 +47,13 @@ class HeroProc {
 //            case CmdCode::cmd_hero_upGodBlood:                                  #  [6322] 神血升级
 //                return HeroProc::UpGodBloodHeroByPieces();
 //            case CmdCode::cmd_hero_unlockByPieces:                            #  [6323] 解锁碎片
-//                return HeroProc::UnLockHeroByPieces();                
+//                return HeroProc::UnLockHeroByPieces();
 // </editor-fold>
             // </editor-fold>
-# --------- 英雄技能 -----------                
+# --------- 英雄技能 -----------
             case CmdCode::cmd_hero_upgradeSkillLevel:                           #  [6314] 英雄的技能升级
                 return HeroProc::UpgradeSkillLevel();
-            case CmdCode::cmd_hero_unlockSkill:                                 #  [6324] 英雄技能 - 解锁技能 
+            case CmdCode::cmd_hero_unlockSkill:                                 #  [6324] 英雄技能 - 解锁技能
                 return HeroProc::UnlockSkill();
             case CmdCode::cmd_hero_skillLevel_onekeyupgrade:                    #  [6325] 英雄技能 - 一键升级
                 return HeroProc::OnekeyUpgradeSkillLevel();
@@ -76,20 +76,20 @@ class HeroProc {
 // <editor-fold defaultstate="collapsed" desc="技能升级与解锁">
 
     /**
-     * [6324] 英雄技能解锁 
+     * [6324] 英雄技能解锁
      * @version  2020.1.13  至今未进行对接, 再次整理版
-     *            2019.12.10 加班弄完第一版 
+     *            2019.12.10 加班弄完第一版
      */
     static function UnlockSkill() {
-        list($huid, $mainSkillId, $subSkillId) = req()->paras;                   # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能ID 
+        list($huid, $mainSkillId, $subSkillId) = req()->paras;                   # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能ID
 
-        $user = req()->userInfo->game;                                           # user引用 
+        $user = req()->userInfo->game;                                           # user引用
         $cHeros = $user->heros->collectHeros;
         my_default_Obj($cHeros);
         my_Assert(CommUtil::isPropertyExists($cHeros, $huid), ErrCode::hero_no); # 1.检查是否存在要解锁的英雄
-#                                                                               # 2.判断英雄的该技能能否升级.... 
-        $targetHero = new Ins_UserHero($cHeros->$huid);                        # 直接类型识别 
-        $targteHeroSkills = $targetHero->subSkills;                             # 取出这个英雄的技能数据 
+#                                                                               # 2.判断英雄的该技能能否升级....
+        $targetHero = new Ins_UserHero($cHeros->$huid);                        # 直接类型识别
+        $targteHeroSkills = $targetHero->subSkills;                             # 取出这个英雄的技能数据
         my_default_Arr($targteHeroSkills->$mainSkillId);                        # 保护子技能数组数据结构
         my_Assert(!CommUtil::isInArray($targteHeroSkills->$mainSkillId, $subSkillId), "子技能已解锁"); # 子技能已经解锁
 //        if (!$targetHero->IsSkillUnlockAble($mainSkillId, $subSkillId)) {       # 3.判断技能是否处于待解锁状态
@@ -97,7 +97,7 @@ class HeroProc {
 //        }
 
         $sm = GameConfig::subSkill_getItem($subSkillId);                        # 4.取出该技能升级消耗的常量数据
-        my_Assert(null != $sm, ErrCode::err_const_no);                          # 找不到子技能配置数据 
+        my_Assert(null != $sm, ErrCode::err_const_no);                          # 找不到子技能配置数据
 //        my_Assert(Data_UserGame::Consume_Gold($user->baseInfo, $sm->unlockCost), #        # 5. 扣除金币消耗
 //                ErrCode::notenough_gold_msg);
         my_Assert($user->base()->Consume_Gold($sm->unlockCost), #               # 5. 扣除金币消耗
@@ -116,13 +116,13 @@ class HeroProc {
     static function OnekeyUpgradeSkillLevel() {
         list($huid, $mainSkillId, $subSkillId, $targetSubSkillId, $costGold) = req()->paras; # 提取参数: 英雄的UID, 主技能ID, 要升级的子技能ID, 升级到的子技能ID, 升级要消耗的金币
 
-        $user = req()->userInfo->game;                                           # user引用#                                                                            
+        $user = req()->userInfo->game;                                           # user引用#
         $collectHeros = $user->heros->collectHeros;
         my_default_Obj($collectHeros);                                          # 防御变量为空
         my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no);   # 1.检查是否存在要升级的英雄
 #                                                                               # 2.判断英雄的该技能能否升级....
         $targetHero = new Ins_UserHero($collectHeros->$huid);                   # 直接类型识别
-        $targteHeroSkills = $targetHero->subSkills;                            # 取出这个英雄的技能数据 
+        $targteHeroSkills = $targetHero->subSkills;                            # 取出这个英雄的技能数据
         my_default_Arr($targteHeroSkills->$mainSkillId);                       # 保护数据结构
         my_Assert(CommUtil::isInArray($targteHeroSkills->$mainSkillId, $subSkillId), "子技能id错误");     # 子技能id
 //        if (!$targetHero->IsSkillUpdateAble($mainSkillId, $subSkillId)) {       # 3.判断技能等级能否在继续升级了
@@ -142,17 +142,17 @@ class HeroProc {
     }
 
     /**
-     * [6314]英雄技能升级 
+     * [6314]英雄技能升级
      */
     static function UpgradeSkillLevel() {
-        list($huid, $mainSkillId, $subSkillId) = req()->paras;                   # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能Id 
+        list($huid, $mainSkillId, $subSkillId) = req()->paras;                   # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能Id
         $user = req()->userInfo->game;                                           # user引用
 
         $collectHeros = $user->heros->collectHeros;
         my_default_Obj($collectHeros);                                          # 防御变量为空
         my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no);   # 1.检查是否存在要升级的英雄
         $targetHero = new Ins_UserHero($collectHeros->$huid);
-        $targteHeroSkills = $targetHero->subSkills;                             # 取出这个英雄的技能数据 
+        $targteHeroSkills = $targetHero->subSkills;                             # 取出这个英雄的技能数据
         my_Assert(CommUtil::isPropertyExists($targteHeroSkills, $mainSkillId), "玩家数据结构有问题.");     # 主技能Id.
         my_Assert(CommUtil::isInArray($targteHeroSkills->$mainSkillId, $subSkillId), "子技能id错误");     # 子技能id
         my_Assert($targetHero->IsSkillUpdateAble($mainSkillId, $subSkillId), ErrCode::hero_upgradeSkill_maxLevel);       # 3.判断技能等级能否在继续升级了
@@ -174,25 +174,25 @@ class HeroProc {
     // <editor-fold defaultstate="collapsed" desc="英雄 强化">
 
     /**
-     * 6304 英雄 升阶(消耗碎片) 
+     * 6304 英雄 升阶(消耗碎片)
      */
     static function HeroStageUp() {
         list($huid, $nextGrade) = req()->paras;                                  # 提取参数: 英雄的UID,下一阶
         $user = req()->userInfo->game;                                           # user引用
         $collectHeros = $user->heros->collectHeros;                             # 角色容器
         my_default_Obj($collectHeros);                                          # 保证不为null
-        my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no);  # 1.检查是否存在要升级的英雄 
+        my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no);  # 1.检查是否存在要升级的英雄
         $upHero = new Ins_UserHero($collectHeros->$huid);                      # 直接类型识别
-        my_Assert($upHero->grade < "S", ErrCode::hero_strength_maxstrengthlevel); # 已经达到S级 
+        my_Assert($upHero->grade < "S", ErrCode::hero_strength_maxstrengthlevel); # 已经达到S级
         $heroUpgradeCostCfg = GameConfig::heroextra_level_getItem($upHero->typeId, $nextGrade);
 
         my_Assert($heroUpgradeCostCfg, ErrCode::hero_strength_cost_const_no);    # 1.检查是否存在这个升阶数据的模板
-//        my_Assert(Data_UserGame::Consume_HeroSegment($user, #                    # 扣除碎片  
+//        my_Assert(Data_UserGame::Consume_HeroSegment($user, #                    # 扣除碎片
 //                        $heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum), ErrCode::hero_segment_not_enough);
-        my_Assert($user->store()->Consume_HeroSegment($heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum), # 扣除碎片  
+        my_Assert($user->store()->Consume_HeroSegment($heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum), # 扣除碎片
                 ErrCode::hero_segment_not_enough); # 碎片数量不足
         # 扣除碎片成功
-        $upHero->grade = $nextGrade;                                            # 5.强化英雄进行成功升阶 
+        $upHero->grade = $nextGrade;                                            # 5.强化英雄进行成功升阶
         $collectHeros->$huid = $upHero;                                         # 更新Hero数据
         UserProc::updateUserInfo();                                             # 6.数据回存
         $resp = Resp::ok($upHero);
@@ -206,29 +206,29 @@ class HeroProc {
     }
 
     /**
-     * [6301] 英雄升级 - 消耗经验道具,获得经验(按照经验提升等级) 
+     * [6301] 英雄升级 - 消耗经验道具,获得经验(按照经验提升等级)
      */
-    static function HeroLevelUpCostExpItem() {            
-        list($huid, $costItemId, $costNumber) = req()->paras;                    # 提取参数: 玩家英雄实例编号, 消耗的道具ID, 消耗的道具数量 
-        $user = req()->userInfo->game;                                           # user引用 
+    static function HeroLevelUpCostExpItem() {
+        list($huid, $costItemId, $costNumber) = req()->paras;                    # 提取参数: 玩家英雄实例编号, 消耗的道具ID, 消耗的道具数量
+        $user = req()->userInfo->game;                                           # user引用
         $collectHeros = $user->heros->collectHeros;                             # 1. 检查是否存在要升级的英雄
         my_default_Obj($collectHeros);
         my_Assert(is_int($costNumber) && $costNumber >= 1, ErrCode::paras_err); # 参数合法性判断
         my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no); # 玩家拥有此英雄
-        $targetHero = new Ins_UserHero($collectHeros->$huid);                   #  
+        $targetHero = new Ins_UserHero($collectHeros->$huid);                   #
         //my_Assert($targetHero->HeroCanLevelUp(), "请提升指挥官等级.");            # 2. 检查玩家等级是否可以继续升级, Ps. 全局限制 + 指挥官等级限制
         $myPacketItems = $user->store->items;                                   # 检查道具的数量,在背包中是否充足
-        my_Assert(CommUtil::isPropertyExists($myPacketItems, $costItemId), ErrCode::store_itemnotenough); # 
-        my_Assert($myPacketItems->$costItemId >= $costNumber, ErrCode::store_itemnotenough);                    
+        my_Assert(CommUtil::isPropertyExists($myPacketItems, $costItemId), ErrCode::store_itemnotenough); #
+        my_Assert($myPacketItems->$costItemId >= $costNumber, ErrCode::store_itemnotenough);
         $initLevel = $targetHero->level;                                        # 初始等级
-        $totalEXP = 0;                                                          # 4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币 
+        $totalEXP = 0;                                                          # 4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币
         $costItemConst = GameConfig::item_stones_getItem($costItemId);
         my_Assert(null != $costItemConst, ErrCode::err_const_no);
-        
+
         $totalGold = $costItemConst->costGold * $costNumber;                    #验证金币是否充足
         my_Assert($user->baseInfo->gold >= $totalGold, ErrCode::notenough_gold_msg);
         $user->baseInfo->gold -= $totalGold;
-        
+
         $totalEXP += $costItemConst->baseExp;
         $heroConst = GameConfig::hero_getItem($targetHero->typeId);             # 英雄模板数据
         my_Assert(null != $heroConst, ErrCode::err_const_no, "英雄 模板数据");
@@ -236,8 +236,8 @@ class HeroProc {
 //                && $costItemConst->element == $heroConst->element) {
 //            $totalEXP += $costItemConst->extraExp;
 //        }
-        $totalEXP *= $costNumber;                                               # 消耗N个道具 
-        $targetHero = self:: HeroAddEXP($huid, $totalEXP);                      # 获得经验 
+        $totalEXP *= $costNumber;                                               # 消耗N个道具
+        $targetHero = self:: HeroAddEXP($huid, $totalEXP);                      # 获得经验
         $myPacketItems->$costItemId -= $costNumber;                             # 消耗道具
         if ($myPacketItems->$costItemId < 0) {
             $myPacketItems->$costItemId = 0;
@@ -252,7 +252,7 @@ class HeroProc {
         $ret = array(
             'hero' => $targetHero,
             'store' => $user->store,
-            'gold'=>$user->baseInfo->gold,    
+            'gold' => $user->baseInfo->gold,
         );
         return Resp::ok($ret);
     }
@@ -260,43 +260,43 @@ class HeroProc {
     /**
      * 唤灵师突破
      */
-    static function tupo() {   
+    static function tupo() {
         list($uid) = req()->paras;
         $user = req()->userInfo->game;
         $collectHeros = $user->heros->collectHeros;                             # 1. 检查是否存在要升级的英雄
-        my_default_Obj($collectHeros);       
+        my_default_Obj($collectHeros);
         my_Assert(StlUtil::dictHasProperty($collectHeros, $uid), ErrCode::hero_no); # 参数合法性判断
-             
+
         $typeId = $collectHeros->$uid->typeId;
         $curStar = $collectHeros->$uid->curStar;
         my_Assert($curStar < 5, ErrCode::hero_yanling_canotTupo);
-        
-        $mo = GameConfig::heroextra_level_tupo_getItem($typeId, $curStar+1);
+
+        $mo = GameConfig::heroextra_level_tupo_getItem($typeId, $curStar + 1);
         my_Assert($mo != null, ErrCode::err_const_no);
-        
+
         my_Assert($collectHeros->$uid->level >= $mo->starlimitLv, ErrCode::hero_yanling_canotTupo);
         my_Assert($user->baseInfo->level >= $mo->userlvLimit, ErrCode::hero_yanling_canotTupo);
-        my_Assert($user->baseInfo->gold >= $mo->gold , ErrCode::notenough_gold_msg); 
+        my_Assert($user->baseInfo->gold >= $mo->gold, ErrCode::notenough_gold_msg);
         $segID = $mo->segID;
-        my_Assert(StlUtil::dictHasProperty($user->store->items,$segID) , ErrCode::store_itemnotenough); 
-        my_Assert($user->store->items->$segID>=$mo->segNum , ErrCode::store_itemnotenough); 
-        
-        $costItemsList = explode(';',$mo->costItems);   
+        my_Assert(StlUtil::dictHasProperty($user->store->items, $segID), ErrCode::store_itemnotenough);
+        my_Assert($user->store->items->$segID >= $mo->segNum, ErrCode::store_itemnotenough);
+
+        $costItemsList = explode(';', $mo->costItems);
         foreach ($costItemsList as $value) {
             $list = explode(',', $value);
-            StoreProc::removeItemFromStore($user->store, $list[0], $list[1]);          
+            StoreProc::removeItemFromStore($user->store, $list[0], $list[1]);
         }
         $user->store->items->$segID -= $mo->segNum;
         $user->baseInfo->gold -= $mo->gold;
-        $collectHeros->$uid->curStar+=1;
-        
+        $collectHeros->$uid->curStar += 1;
+
         NormalEventProc::OnHeroTuPo($uid, $collectHeros->$uid->curStar);         # 广播英雄升级事件
-        
-        $user->heros->collectHeros=$collectHeros;
-        req()->userInfo->game = $user;                     
+
+        $user->heros->collectHeros = $collectHeros;
+        req()->userInfo->game = $user;
         $targetHero = new Ins_UserHero($collectHeros->$uid);
-        
-        UserProc::updateUserInfo();# 回写玩家数据
+
+        UserProc::updateUserInfo(); # 回写玩家数据
         $ret = array(
             'hero' => $targetHero,
             'store' => $user->store,
@@ -305,9 +305,8 @@ class HeroProc {
         return Resp::ok($ret);
     }
 
-
 // </editor-fold>
-// 
+//
 // <editor-fold defaultstate="collapsed" desc="队伍配置">
 
     /**
@@ -323,11 +322,11 @@ class HeroProc {
     }
 
 // </editor-fold>
-// 
+//
 // <editor-fold defaultstate="collapsed" desc="已过时代码">
 
     /**
-     * 6323 解锁英雄 
+     * 6323 解锁英雄
      */
     static function UnLockHeroByPieces() {
         Err(ErrCode::err_method_obsoleted, "策划未设定解锁功能-2021.5.6");
@@ -337,7 +336,7 @@ class HeroProc {
         $piecesNum = req()->paras[2];
         my_default_Obj($user->heros->recordUnLockHeroDic);                      # 防御解锁列表未初始化,空对象
         $recordUnLockHeroDic = $user->heros->recordUnLockHeroDic;               # 已解锁记录
-        if (!CommUtil::isPropertyExists($recordUnLockHeroDic, $heroModelId)) {  # 检查是不是已经解锁过了 
+        if (!CommUtil::isPropertyExists($recordUnLockHeroDic, $heroModelId)) {  # 检查是不是已经解锁过了
             $recordUnLockHeroDic->$heroModelId = 0;
         }
         my_Assert(0 == $recordUnLockHeroDic->$heroModelId, ErrCode::hero_lockState); # 防御英雄已经解锁
@@ -361,7 +360,7 @@ class HeroProc {
         }
         my_Assert($enoughPieces, ErrCode::hero_godblood_notengoughitem);
         $myPacketItems->$piecesId -= $requirePiecesNum;
-        if ($myPacketItems->$piecesId < 0) {                                    # 6.进行 # # 消耗道具        
+        if ($myPacketItems->$piecesId < 0) {                                    # 6.进行 # # 消耗道具
             $myPacketItems->$piecesId = 0;
         }
         $recordUnLockHeroDic->$heroModelId = 1;
@@ -397,7 +396,7 @@ class HeroProc {
 // </editor-fold>
 
     /**
-     * 6321 购买英雄 消耗碎片 
+     * 6321 购买英雄 消耗碎片
      */
     static function BuyHeroByCostPieces() {
         Err(ErrCode::err_method_obsoleted, "策划未设定碎片功能-2021.5.6");
@@ -436,8 +435,8 @@ class HeroProc {
                 Err(ErrCode::paras_err, "参数错误: [costType] " . $costType);
         }
 
-        # 4.消耗来获得英雄 
-        $myPacketItems->$piecesId -= $requirePiecesNum;                         # 消耗道具 
+        # 4.消耗来获得英雄
+        $myPacketItems->$piecesId -= $requirePiecesNum;                         # 消耗道具
         req()->userInfo->game->store->items = $myPacketItems;                    # 回存背包
         UserProc::updateUserInfo();                                             # 回写数据
         $resp = HeroProc::GetHero();
@@ -446,7 +445,7 @@ class HeroProc {
     }
 
     /**
-     * 购买玩家可以收集的英雄的数量上限 
+     * 购买玩家可以收集的英雄的数量上限
      * @return type
      */
     static function BuyHeroMaxCountLimt() {
@@ -472,13 +471,13 @@ class HeroProc {
     }
 
     /**
-     * 获得英雄(测试已经OK) 
+     * 获得英雄(测试已经OK)
      */
     static function GetHero() {
-        $heroModelId = req()->paras[0];                                          # 英雄的模板ID 
+        $heroModelId = req()->paras[0];                                         # 英雄的模板ID
         $heroCfg = GameConfig::hero_getItem($heroModelId);                      # 1.检查是否存在这个英雄的模板
         my_Assert(null != $heroCfg, ErrCode::hero_const_no_err);
-        $hero = self::AddHeroTFromStore(req(), $heroModelId);                    # 创建英雄
+        $hero = self::AddHeroTFromStore($heroModelId);                          # 创建英雄
         UserProc::updateUserInfo();
         $result = array('result' => "succeed", 'heros' => $hero);               #  4. 设置返回值
         return Resp::ok($result);
@@ -488,23 +487,21 @@ class HeroProc {
 
     /**
      * 获得一个英雄, 并且给他指定星级
-     * @param Req $req
      * @param int $heromodelId 原型数据id
      * @param int $star        星级
      * @return Ins_UserHero
      */
-    static function AddHeroWithStar(&$req, $heromodelId, $star) {
-        $user = $req->userInfo->game;
-        my_Assert(null != $user, ErrCode::err_innerfault);
-        $collectHeros = $user->heros->collectHeros;
-        $uid = self::CreateNewGameHeroUID($collectHeros, $user->heros->recordMaxUID); # 先生成一个hero的UID
-        $user->heros->recordMaxUID = $uid;
+    static function AddHeroWithStar($heromodelId, $star) {
+        my_Assert(null != ctx(), ErrCode::err_innerfault);
+        $collectHeros = ctx()->heros()->collectHeros;
+        $uid = self::CreateNewGameHeroUID($collectHeros, ctx()->heros()->recordMaxUID); # 先生成一个hero的UID
+        ctx()->heros()->recordMaxUID = $uid;
         $hero = self::getGameHeroModelInstance($heromodelId, $uid);
         if ($star > 0) {
-            $hero->curStar = $star;                                               # 设定star
+            $hero->curStar = $star;                                             # 设定star
         }
         $collectHeros->$uid = $hero;                                            # 回写
-        $user->heros->collectHeros = $collectHeros;                             # 回写 
+        ctx()->heros()->collectHeros = $collectHeros;                           # 回写
         return $hero;                                                           # 返回
     }
 
@@ -514,20 +511,20 @@ class HeroProc {
      * @param int $heromodelId
      * @return type
      */
-    static function AddHeroTFromStore(&$req, $heromodelId) {
-        $user = $req->userInfo->game;                                           # 玩家数据
-        $collectHeros = $user->heros->collectHeros;                             # 
+    static function AddHeroTFromStore($heromodelId) {
+        $user = ctx();                                                          # 玩家数据
+        $collectHeros = ctx()->heros()->collectHeros;                           #
         my_default_Obj($collectHeros);
-        $uid = self::CreateNewGameHeroUID($collectHeros, $user->heros->recordMaxUID); # 先生成一个UID
+        $uid = self::CreateNewGameHeroUID($collectHeros, ctx()->heros()->recordMaxUID); # 先生成一个UID
         $user->heros->recordMaxUID = $uid;                                      # 更新最大编号记录
         $hero = self::getGameHeroModelInstance($heromodelId, $uid);             # 3.创建英雄实例
         $collectHeros->$uid = $hero;
-        $user->heros->collectHeros = $collectHeros;
+        ctx()->heros()->collectHeros = $collectHeros;
         return $hero;
     }
 
     /**
-     * 根据一个英雄的模板id,来获得一个英雄的实例数据 
+     * 根据一个英雄的模板id,来获得一个英雄的实例数据
      * @param string $heroModelId 模板数据ID
      * @param string $uid 唯一ID
      * @return Ins_UserHero
@@ -584,50 +581,50 @@ class HeroProc {
     /**
      *  英雄卡牌增加经验值
      * @param string $heroUID
-     * @param int $totalEXP 
+     * @param int $totalEXP
      */
     static function HeroAddEXP($heroUID, $totalEXP) {
         $req = req();
         $collectHeros = $req->userInfo->game->heros->collectHeros;
         my_default_Obj($collectHeros);
         my_Assert(CommUtil::isPropertyExists($collectHeros, $heroUID), ErrCode::hero_no); # 要升级的英雄不存在
-        $targetHero = new Ins_UserHero($collectHeros->$heroUID);                # 英雄对象 
+        $targetHero = new Ins_UserHero($collectHeros->$heroUID);                # 英雄对象
 //        $playerLimit = GameConfig::playerlevel_getItem(ctx()->base()->level)->hero_max_level;
 //        $maxLevel = min(glc()->Hero_Upgrade_BasicMaxLevel, $playerLimit);       # 最大等级= max(英雄最高等级上限,玩家等级限制的上限)
 //        if ($targetHero->level >= $maxLevel) {
 //            return;                                                             # 已达顶级
 //        }
-        //$lvs = GameConfig::hero_levelexp_getItem($targetHero->level + 1);            
-        $targetHero->xp += $totalEXP;                            
+        //$lvs = GameConfig::hero_levelexp_getItem($targetHero->level + 1);
+        $targetHero->xp += $totalEXP;
         my_Assert($targetHero->xp >= 0, "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
         $initLevel = $targetHero->level;
         $curLv = 0;
         $heroLvDic = GameConfig::hero_levelexp();
-        $f = (array) $heroLvDic;     
-        ksort($f); 
+        $f = (array) $heroLvDic;
+        ksort($f);
         foreach ($f as $lv => $mo) {
-            if($targetHero->xp < $mo->needExp){
-                $curLv = $lv-1;
+            if ($targetHero->xp < $mo->needExp) {
+                $curLv = $lv - 1;
                 break;
             }
-            
-            if($lv>=glc()->Hero_Upgrade_BasicMaxLevel){
+
+            if ($lv >= glc()->Hero_Upgrade_BasicMaxLevel) {
                 $curLv = glc()->Hero_Upgrade_BasicMaxLevel;
                 break;
             }
         }
         $targetHero->level = $curLv;
-        
-        $curStar = $targetHero->curStar;#当前星级   
-        if($curStar < 5){
-            $starlimitLv = GameConfig::heroextra_level_tupo_getItem($targetHero->typeId, $curStar +1)->starlimitLv; 
-            if($starlimitLv < $curLv){
+
+        $curStar = $targetHero->curStar; #当前星级
+        if ($curStar < 5) {
+            $starlimitLv = GameConfig::heroextra_level_tupo_getItem($targetHero->typeId, $curStar + 1)->starlimitLv;
+            if ($starlimitLv < $curLv) {
                 $targetHero->level = $starlimitLv;
                 $targetHero->xp = GameConfig::hero_levelexp_getItem($starlimitLv)->needExp;
             }
         }
-        
-        
+
+
 //        while ($targetHero->xp >= $lvs->needExp) {
 //            if ($targetHero->level < $maxLevel) {                               # 如果未到达最大等级
 //                $targetHero->level += 1;
@@ -643,7 +640,7 @@ class HeroProc {
 //            }
 //        } // end while
         my_Assert($targetHero->xp >= 0, "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
-        $collectHeros->$heroUID = $targetHero;                                  # 更新英雄的数据 
+        $collectHeros->$heroUID = $targetHero;                                  # 更新英雄的数据
         if ($targetHero->level != $initLevel) {
             NormalEventProc::OnHeroLvlUp($targetHero->uid, $initLevel);         # 广播英雄升级事件
         }
@@ -655,7 +652,7 @@ class HeroProc {
 
     /**
      * [6306] 英雄-更改英雄的锁定状态
-     * (测试已经OK) 
+     * (测试已经OK)
      */
     static function HeroChangelockstate() {
         $gamedata = req()->userInfo->game;
@@ -691,8 +688,8 @@ class HeroProc {
                     $tag = false;
                     break;
                 }
-                
-                if($store->yanling->$costUid->herouid != 0){
+
+                if ($store->yanling->$costUid->herouid != 0) {
                     $tag = false;
                     break;
                 }
@@ -794,7 +791,7 @@ class HeroProc {
                     }
                 }
             }
-            //todo: 这里的战斗力榜被总战力榜征用了key, 重启PVP机制时再 
+            //todo: 这里的战斗力榜被总战力榜征用了key, 重启PVP机制时再
         }
         return $fp;
     }