|
@@ -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);
|
|
|
}
|
|
|
|