Преглед изворни кода

fixed: 角色升级的时候, 使用多个道具的情况下, 计算总经验未乘N.

gwang пре 5 година
родитељ
комит
3033cb7c42
2 измењених фајлова са 10 додато и 12 уклоњено
  1. 9 11
      Gameserver/Amfphp/process/HeroProc.php
  2. 1 1
      Gameserver/nbproject/private/private.xml

+ 9 - 11
Gameserver/Amfphp/process/HeroProc.php

@@ -195,25 +195,20 @@ class HeroProc {
      * @param Req $req
      */
     static function HeroLevelUpCostExpItem($req) {
-        $gcfg = glc();                                                          # 全局配置
+        list($heroUID, $costItemId, $costNumber) = $req->paras;                 # 提取参数: 玩家英雄实例编号, 消耗的道具ID, 消耗的道具数量 
         $user = $req->userInfo->game;                                           # user引用
-        $heroUID = $req->paras[0];                                              # 玩家英雄实例编号
-        $costItemId = $req->paras[1];                                           # 消耗的道具ID
-        $costNumber = $req->paras[2];                                           # 消耗的道具数量 
+        $maxLevel = glc()->Hero_Upgrade_BasicMaxLevel;                          # 全局设置限制了当前英雄的最高等级
         $collectHeros = $user->heros->collectHeros;                             # 1. 检查是否存在要升级的英雄
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
+        my_default_Obj($collectHeros);
+        my_Assert($costNumber >= 1, ErrCode::paras_err);                        # 参数合法性判断
         my_Assert(CommUtil::isPropertyExists($collectHeros, $heroUID), ErrCode::hero_no); # 玩家拥有此英雄
 //        isEditor() and $targetHero = new UserHeroModel;                         # 智能感知辅助
         $targetHero = $collectHeros->$heroUID;
-        $maxLevel = $gcfg->Hero_Upgrade_BasicMaxLevel;
         my_Assert($targetHero->level < $maxLevel, ErrCode::hero_upgrade_maxupgradelevel);  # 2. 检查玩家等级是否达到当前等级上限
-
+// todo: 指挥官等级也能限制英雄最高等级.
         $myPacketItems = $user->store->items;                                   # 检查道具的数量,在背包中是否充足
         my_Assert(CommUtil::isPropertyExists($myPacketItems, $costItemId), ErrCode::store_itemnotenough); # 
         my_Assert($myPacketItems->$costItemId >= $costNumber, ErrCode::store_itemnotenough);
-
         $totalEXP = 0;                                                          # 4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币 
         $costItemConst = GameConfig::item_stones_getItem($costItemId);
         my_Assert(null != $costItemConst, ErrCode::err_const_no);
@@ -225,13 +220,16 @@ class HeroProc {
                 && $costItemConst->element == $heroConst->element) {
             $totalEXP += $costItemConst->extraExp;
         }
+        if ($costNumber > 1) {                                                  # 消耗多个道具
+            $totalEXP *= $costNumber;
+        }
         self:: HeroAddEXP($heroUID, $totalEXP, $req);                           # 获得经验 
         $myPacketItems->$costItemId -= $costNumber;                             # 消耗道具
         if ($myPacketItems->$costItemId < 0) {
             $myPacketItems->$costItemId = 0;
         }
         $req->userInfo->game->store->items = $myPacketItems;                    # 更新背包数据
-        UserProc::updateUserInfo();                                         # 回写玩家数据
+        UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok($targetHero);
     }
 

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

@@ -22,8 +22,8 @@
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/configs/config_ios.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/service_call/cmemdata/kvflush.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/AutoLoad.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/PayProc.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/util/DebugHelper.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/process/SystemProc.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/main.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/configs/config_and.php</file>
         </group>