gwang 5 år sedan
förälder
incheckning
f5c39d20e7
1 ändrade filer med 34 tillägg och 43 borttagningar
  1. 34 43
      Gameserver/Amfphp/Process/HeroProc.php

+ 34 - 43
Gameserver/Amfphp/Process/HeroProc.php

@@ -90,11 +90,11 @@ class HeroProc {
             return Resp::err(ErrCode::hero_strength_cost_const_no);
         }
         $needSeg = $heroUpgradeCostCfg->segNum;                                 # 2 
-//        if ($user->Consume_HeroSegment($user, #                                 # 扣除碎片
-//                        $heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum)) {
-        if (true) {                                                             # 扣除碎片直接成功
+        if ($user->Consume_HeroSegment($user, #                                 # 扣除碎片
+                        $heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum)) {
+//        if (true) {                                                             # 扣除碎片直接成功
             $upHero->grade = $nextGrade;                                        # 5.强化英雄进行成功升阶 
-            UserProc::updateUserInfo($req);                                     //6.数据回存
+            UserProc::updateUserInfo($req);                                     # 6.数据回存
             $resp = Resp::ok($upHero);
             SystemProc::insertHero_StageUp($req->zoneid, $req->uid, $user->name, #
                     GameConfig::hero_getItem($upHero->typeId)->name, $upHero->grade);
@@ -109,62 +109,53 @@ class HeroProc {
      * @param Req $req
      */
     static function HeroLevelUpCostExpItem($req) {
-        $gcfg = glc();
+        $gcfg = glc();                                                          # 全局配置
         $user = $req->userInfo->game;                                           # user引用
         $heroUID = $req->paras[0];                                              # 玩家英雄实例编号
         $costItemId = $req->paras[1];                                           # 消耗的道具ID
         $costNumber = $req->paras[2];                                           # 消耗的道具数量
 
-        $collectHeros = $user->heros->collectHeros;                             // 1. 检查是否存在要升级的英雄
+        $collectHeros = $user->heros->collectHeros;                             # 1. 检查是否存在要升级的英雄
         if (!$collectHeros) {
             $collectHeros = ObjectInit();
         }
         if (!CommUtil::isPropertyExists($collectHeros, $heroUID)) {
             return Resp::err(ErrCode::hero_no);
         }
-
-        isEditor() and $targetHero = new UserHeroModel;
+        isEditor() and $targetHero = new UserHeroModel;                         # 智能感知辅助
         $targetHero = $collectHeros->$heroUID;
 
         $maxLevel = $gcfg->Hero_Upgrade_BasicMaxLevel;
-        if ($targetHero->level >= $maxLevel) {                                  // 2. 检查玩家等级是否达到当前等级上限
+        if ($targetHero->level >= $maxLevel) {                                  # 2. 检查玩家等级是否达到当前等级上限
             return Resp::err(ErrCode::hero_upgrade_maxupgradelevel);
         }
-
-
-// 下面是检查道具的数量,在背包中是否充足
-        $myPacketItems = $user->store->items;                                   # 道具包裹
-        if (!CommUtil::isPropertyExists($myPacketItems, $costItemId) || $myPacketItems->$costItemId < $costNumber) {
+        $myPacketItems = $user->store->items;                                   # 检查道具的数量,在背包中是否充足
+        if (!CommUtil::isPropertyExists($myPacketItems, $costItemId) #
+                || $myPacketItems->$costItemId < $costNumber) {
             return Resp::err(ErrCode::store_itemnotenough);
         }
-
-        //4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币
-        $totalEXP = 0;
-
+        $totalEXP = 0;                                                          # 4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币 
         $costItemConst = GameConfig::item_stones_getItem($costItemId);
         if (!$costItemConst) {
             return Resp::err(ErrCode::err_const_no);
         } else {
             $totalEXP += $costItemConst->baseExp;
         }
-        $heroConst = GameConfig::hero_getItem($targetHero->typeId);             #
+        $heroConst = GameConfig::hero_getItem($targetHero->typeId);             # 英雄模板数据
         if (null == $heroConst) {
             return \Resp::err(ErrCode::err_const_no, "英雄 模板数据");
         }
-        if ($costItemConst->element != 0 #                                     # 相同元素加成
+        if ($costItemConst->element != 0 #                                      # 相同元素加成
                 && $costItemConst->element == $heroConst->element) {
             $totalEXP += $costItemConst->extraExp;
         }
-
-        self:: HeroAddEXP($heroUID, $totalEXP, $req);                           # 获得经验
-
+        self:: HeroAddEXP($heroUID, $totalEXP, $req);                           # 获得经验 
         $myPacketItems->$costItemId -= $costNumber;                             # 消耗道具
         if ($myPacketItems->$costItemId < 0) {
             $myPacketItems->$costItemId = 0;
         }
-
-        $req->userInfo->game->store->items = $myPacketItems;
-        UserProc::updateUserInfo($req);
+        $req->userInfo->game->store->items = $myPacketItems;                    # 更新背包数据
+        UserProc::updateUserInfo($req);                                         # 回写玩家数据
         return Resp::ok($targetHero);
     }
 
@@ -1198,9 +1189,9 @@ class HeroProc {
      * @param Req $req
      */
     static function SaveHeroTeamConfig($req) {
-        $teamsetting = $req->paras[0];  # 配置信息json文件
-        $req->userInfo->game->heroTeamConfig = $teamsetting; # 更新配置
-        UserProc::updateUserInfo($req); # 回写数据
+        $teamsetting = $req->paras[0];                                          # 配置信息json文件
+        $req->userInfo->game->heroTeamConfig = $teamsetting;                    # 更新配置
+        UserProc::updateUserInfo($req);                                         # 回写数据
 #       # 添加到战斗力隐藏榜单中, for pvp back matchers, -wg 2017.07.13
         self::CalcTeamFightPower($req->zoneid, $req->uid, $req->userInfo->game);
         return Resp::ok(array('result' => "succeed"));
@@ -1213,7 +1204,7 @@ class HeroProc {
      */
     static function BuyHeroMaxCountLimt($req) {
         $g = glc();
-        $user = $req->userInfo->game;                                # user引用
+        $user = $req->userInfo->game;                                           # user引用
         if (!CommUtil::isPropertyExists($user->heros, "maxCollectCount")) {
             $user->heros->maxCollectCount = $g->Game_CollectHero_BasicMaxCount;
         }
@@ -1237,8 +1228,8 @@ class HeroProc {
         if ($user->cash < $costCash) {
             return Resp::err(ErrCode::notenough_spar);
         }
-        UserGameModel::Consume_Cash($user, $costCash);               # 扣除宝石
-        $user->heros->maxCollectCount += $buyNum;                    # 修改上限
+        UserGameModel::Consume_Cash($user, $costCash);                          # 扣除宝石
+        $user->heros->maxCollectCount += $buyNum;                               # 修改上限
         UserProc::updateUserInfo($req);
         return Resp::ok(array(
                     'maxCollectCount' => $user->heros->maxCollectCount
@@ -1313,8 +1304,8 @@ class HeroProc {
         if (!$user) {
             return null;
         }
-        $heroCfg = GameConfig::hero_getItem($heromodelId); # 检查是否存在这个英雄的模板
-        if (!$heroCfg) {                                   # 这里能不能附加错误信息给外面
+        $heroCfg = GameConfig::hero_getItem($heromodelId);                      # 检查是否存在这个英雄的模板
+        if (!$heroCfg) {                                                        # 这里能不能附加错误信息给外面
             return null;
         }
 # 先生成一个hero的UID
@@ -1322,9 +1313,9 @@ class HeroProc {
         $uid = self::CreateNewGameHeroUID($collectHeros, $user->heros->recordMaxUID);
         $user->heros->recordMaxUID = $uid;
         $hero = self::getGameHeroModelInstance($heroCfg, $heromodelId, $uid);
-        $hero->curStar = $star;                            # 设定star
-        $collectHeros->$uid = $hero;                       # 回写
-        $user->heros->collectHeros = $collectHeros;        # 回写
+        $hero->curStar = $star;                                                 # 设定star
+        $collectHeros->$uid = $hero;                                            # 回写
+        $user->heros->collectHeros = $collectHeros;                             # 回写
 # 更新 图鉴
         if (!CommUtil::isPropertyExists($user, "heroManual")) {
             $user->heroManual = new HeroManualModel();
@@ -1334,7 +1325,7 @@ class HeroProc {
         self:: tryNewManual($req->mem, $manual, $hero);
 
 
-        return $hero;                                       # 返回
+        return $hero;                                                           # 返回
     }
 
     /**
@@ -1688,8 +1679,8 @@ class HeroProc {
      */
     static function HeroChangelockstate($req) {
         $gamedata = $req->userInfo->game;
-        $heroUID = $req->paras[0];                          # 玩家英雄实例编号
-        $lockstate = $req->paras[1];                        # 玩家英雄锁定状态
+        $heroUID = $req->paras[0];                                              # 玩家英雄实例编号
+        $lockstate = $req->paras[1];                                            # 玩家英雄锁定状态
         $collectHeros = $gamedata->heros->collectHeros;
         if (!$collectHeros) {
             $collectHeros = ObjectInit();
@@ -1698,9 +1689,9 @@ class HeroProc {
             return Resp::err(ErrCode::hero_no);
         }
         isEditor() and $hero = new UserHeroModel;
-        $hero = $collectHeros->$heroUID;                    # 1. 获取这个英雄的实例数据是
-        $hero->isLocked = $lockstate;                       # 2. 修改英雄状态
-        UserProc::updateUserInfo($req);                     # 3. 保存玩家数据
+        $hero = $collectHeros->$heroUID;                                        # 1. 获取这个英雄的实例数据是
+        $hero->isLocked = $lockstate;                                           # 2. 修改英雄状态
+        UserProc::updateUserInfo($req);                                         # 3. 保存玩家数据
         return Resp::ok(ObjectInit()); # 4. 设置返回值
     }