gwang 5 жил өмнө
parent
commit
adb7dbf752

+ 439 - 339
Gameserver/Amfphp/Process/HeroProc.php

@@ -16,59 +16,222 @@ class HeroProc {
      */
     static function procMain($req) {
         switch ($req->cmd) {
-            case CmdCode::cmd_hero_levelup:                  #  [6301] 英雄升级
+            case CmdCode::cmd_hero_levelup:                                     #  [6301] 英雄升级
                 return HeroProc::HeroLevelUpCostItem($req);
-//            case CmdCode::cmd_hero_changelockstate:          #  [6306] 英雄-修改锁定状态
+            case CmdCode::cmd_hero_stageup:                                     #  6304  英雄进阶 SABCD
+//            case CmdCode::cmd_hero_changelockstate:                           #  [6306] 英雄-修改锁定状态
 //                return HeroProc::HeroChangelockstate($req);
-//            case CmdCode::cmd_hero_gethero:                  #  [6308] 分解英雄
+//            case CmdCode::cmd_hero_gethero:                                   #  [6308] 分解英雄
 //                return HeroProc::GetHero($req);
-//            case CmdCode::cmd_hero_strength:                 #  [6309] 英雄升阶
+//            case CmdCode::cmd_hero_strength:                                  #  [6309] 英雄升阶
 //                return HeroProc::HeroStrength($req);
-//            case CmdCode::cmd_hero_upstar:                   #  [6305] 英雄升星
+//            case CmdCode::cmd_hero_upstar:                                    #  [6305] 英雄升星
 //                return HeroProc::HeroUpStarByPieces($req);
-//            case CmdCode::cmd_hero_openFavor:                #  [6310] 英雄好感度解锁
+//            case CmdCode::cmd_hero_openFavor:                                 #  [6310] 英雄好感度解锁
 //                return HeroProc::HeroOpenFavor($req);
-//            case CmdCode::cmd_hero_separate:                 #  [6311] 分解英雄
+//            case CmdCode::cmd_hero_separate:                                  #  [6311] 分解英雄
 //                return HeroProc::HeroSeparate($req);
-//            case CmdCode::cmd_hero_buyCollectHeroLimtCount:  #  [6312] 扩展英雄数量上限
+//            case CmdCode::cmd_hero_buyCollectHeroLimtCount:                   #  [6312] 扩展英雄数量上限
 //                return HeroProc::BuyHeroMaxCountLimt($req);
-//            case CmdCode::cmd_hero_changefriendsupport:      #  [6313] 更换支援好友
+//            case CmdCode::cmd_hero_changefriendsupport:                       #  [6313] 更换支援好友
 //                return HeroProc::ChangeFriendSupport($req);
-            case CmdCode::cmd_hero_upgradeSkillLevel:        #  [6314] 英雄的技能升级
+            case CmdCode::cmd_hero_upgradeSkillLevel:                           #  [6314] 英雄的技能升级
                 return HeroProc::UpgradeSkillLevel($req);
-            case CmdCode::cmd_hero_saveHeroTeamConfig:       #  [6315] 保存玩家战队数据
+            case CmdCode::cmd_hero_saveHeroTeamConfig:                          #  [6315] 保存玩家战队数据
                 return HeroProc::SaveHeroTeamConfig($req);
-            case CmdCode::cmd_hero_upGodBlood:               #  [6322] 神血升级
+            case CmdCode::cmd_hero_upGodBlood:                                  #  [6322] 神血升级
                 return HeroProc::UpGodBloodHeroByPieces($req);
-//            case CmdCode::cmd_hero_unlockByPieces:           #  [6323] 解锁碎片
+//            case CmdCode::cmd_hero_unlockByPieces:                            #  [6323] 解锁碎片
 //                return HeroProc::UnLockHeroByPieces($req);
 #  --------- 英雄评论 -----------
-            case CmdCode::cmd_hero_GetDiscuss:               #  [6316]拉取英雄评论
+            case CmdCode::cmd_hero_GetDiscuss:                                  #  [6316]拉取英雄评论
                 return HeroDiscussProc::GetDiscusses($req);
-            case CmdCode::cmd_hero_PostDiscuss:              #  [6317]对英雄发表评论
+            case CmdCode::cmd_hero_PostDiscuss:                                 #  [6317]对英雄发表评论
                 return HeroDiscussProc::Post($req);
-            case CmdCode::cmd_hero_DeleteDiscuss:            #  [6319]删除评论
+            case CmdCode::cmd_hero_DeleteDiscuss:                               #  [6319]删除评论
                 return HeroDiscussProc::DeletePost($req);
-            case CmdCode::cmd_hero_PraiseDiscuss:            #  [6318]给某条评论点赞
+            case CmdCode::cmd_hero_PraiseDiscuss:                               #  [6318]给某条评论点赞
                 return HeroDiscussProc::PriaseMsg($req);
-            case CmdCode::cmd_hero_scoreit:                  #  [6320]给某个英雄评分
+            case CmdCode::cmd_hero_scoreit:                                     #  [6320]给某个英雄评分
                 return HeroDiscussProc::Score($req);
 #----------------------------------------------
-            case CmdCode::cmd_hero_buyHero:                  #  [6321]购买英雄
+            case CmdCode::cmd_hero_buyHero:                                     #  [6321]购买英雄
                 return HeroProc::BuyHeroByCostPieces($req);
-            default:                                         #  err: 未知的命令码
+            default:                                                            #  err: 未知的命令码
                 return Resp::err(ErrCode::cmd_err);
         }
     }
 
     /**
-     * 解锁英雄
+     * 6304 英雄 升阶(消耗碎片)
+     * @param Req $req
+     */
+    static function HeroStageUp($req) {
+        $g = glc();
+        $user = $req->userInfo->game;                                           # user引用
+        $huid = $req->paras[0];                                                 # 英雄的UID
+        $costUID = $req->paras[1];                                              # 消耗掉的英雄UID
+        $costGold = $req->paras[2];
+# 1.检查是否存在要升级的英雄
+        $collectHeros = $user->heros->collectHeros;
+        if (!$collectHeros) {
+            $collectHeros = ObjectInit();
+        }
+        if (!CommUtil::isPropertyExists($collectHeros, $huid)) {
+            return Resp::err(ErrCode::hero_no);
+        }
+        isEditor() and $strengthHero = new UserHeroModel();
+        $strengthHero = $collectHeros->$huid;
+        if ($strengthHero->strengthLevel >= $g->Hero_Stength_MaxStrengthLevel) {
+            return Resp::err(ErrCode::hero_strength_maxstrengthlevel);
+        }
+# 1.检查是否存在这个升阶数据的模板
+        $heroStrengthCostCfg = GameConfig::heroextra_dengjie_getItem($strengthHero->strengthLevel);
+        if (!$heroStrengthCostCfg) {
+            return Resp::err(ErrCode::hero_strength_cost_const_no);
+        }
+
+# 2.检查要消耗的英雄是否存在
+        if (!CommUtil::isPropertyExists($collectHeros, $costUID)) {
+            return Resp::err(ErrCode::hero_no);
+        }
+# 3.检查金币是否正确,以及玩家账户金币是否充足
+        $queryCostGold = $heroStrengthCostCfg->cost;
+        $bDeal = false;  # 成交
+# 4.消耗金币和英雄
+        if ($bDeal) {
+            unset($collectHeros->$costUID);
+# 5.强化英雄进行成功升阶 //6.数据回存
+            $strengthHero->strengthLevel += 1;
+            UserProc::updateUserInfo($req);
+            $resp = Resp::ok($strengthHero);
+            SystemProc::insertHero_StageUp($req->zoneid, $req->uid, $user->name, #
+                    GameConfig::hero_getItem($strengthHero->modelId)->name, $strengthHero->strengthLevel);
+        }
+
+        return $resp;
+    }
+
+    /**
+     * [6301] 英雄升级 - 消耗经验道具,获得经验(按照经验提升等级)
+     * @param type $req
+     */
+    static function HeroLevelUpCostExpItem($req) {
+        $gcfg = glc();
+        $user = $req->userInfo->game;                                           # user引用
+        $heroUID = $req->paras[0];                                              # 玩家英雄实例编号
+        $costItemIds = $req->paras[1];                                          # 消耗的道具ID
+        $costGold = $req->paras[2];
+
+        $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;
+        $targetHero = $collectHeros->$heroUID;
+
+        $maxLevel = $gcfg->Hero_Upgrade_BasicMaxLevel;
+        if ($targetHero->level >= $maxLevel) {                                  // 2. 检查玩家等级是否达到当前等级上限
+            return Resp::err(ErrCode::hero_upgrade_maxupgradelevel);
+        }
+        $arr_costUID = explode(",", $costItemIds);                              // 3. 检查消耗的道具是否是都存在的
+        $isAllExist = true;
+        $itemObj = ObjectInit();
+
+        foreach ($arr_costUID as $value) {
+            if ($value == "") {
+                continue;
+            }
+            if (!CommUtil::isPropertyExists($itemObj, $value)) {
+                $itemObj->$value = 1;
+            } else {
+                $itemObj->$value += 1;
+            }
+        }
+//以上是统计各种道具的消耗数量
+//下面是检查道具的数量,在背包中是否充足
+        $myPacketItems = $user->store->items;
+        foreach ($itemObj as $key => $value) {
+            if ($value > 0) {
+                if (!CommUtil::isPropertyExists($myPacketItems, $key)) {
+                    $isAllExist = false;
+                    break;
+                } else {
+                    if ($myPacketItems->$key < $value) {
+                        $isAllExist = false;
+                        break;
+                    }
+                }
+            }
+        }
+        if (!$isAllExist) {
+            return Resp::err(ErrCode::hero_upgrade_cost);
+        }
+//4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币
+        $totalEXP = 0;
+        $realCostGold = 0;
+        foreach ($arr_costUID as $value) {
+            if ($value == "") {
+                continue;
+            }
+            isEditor() and $costItemConst = new sm_hero_levelexp_costitem;
+            $costItemConst = GameConfig::hero_levelexp_costitem_getItem($value);
+            if (!$costItemConst) {
+                return Resp::err(ErrCode::hero_upgrade_cost_const_no);
+            } else {
+                $totalEXP += $costItemConst->dogExp;
+                $realCostGold += $costItemConst->costGold;
+            }
+        }
+// 5.取升级消耗数据,提取消耗的金币数量,判断金币是否充足
+        $bDeal = false;                                                         # 成交标志
+        if ($costGold != $realCostGold) {
+            return Resp::err(ErrCode ::paras_err, $errMsg);
+        } else {
+            if ($costGold > 0) {
+                if ($user->gold < $costGold) {
+                    return Resp::err(ErrCode::notenough_gold_msg);
+                } else {
+                    $bDeal = UserGameModel:: Consume_Gold($user, $costGold);
+                }
+            } else if ($costGold == 0) {
+                $bDeal = true;
+            } else {
+                return Resp::err(ErrCode::paras_err);
+            }
+        }
+        if ($bDeal) {
+            self:: HeroAddEXP($heroUID, $totalEXP, $req);                       # 获得经验
+            foreach ($itemObj as $key => $value) {                              # 消耗道具
+                $myPacketItems->$key -= $value;
+                if ($myPacketItems->$key < 0) {
+                    $myPacketItems->$key = 0;
+                }
+            }
+
+            $req->userInfo->game->store->items = $myPacketItems;
+            UserProc::updateUserInfo($req);
+            $resp = Resp::ok($targetHero);
+        }
+        ActiveProc::ChangeTaskCount($req);
+
+        return $resp;
+    }
+
+// <editor-fold defaultstate="collapsed" desc="已过时代码">
+
+    /**
+     * 6323 解锁英雄
      * @param type $req
      */
     static function UnLockHeroByPieces($req) {
-        $user = $req->userInfo->game; # user引用
+        $user = $req->userInfo->game;                                           # user引用
         $heroModelId = $req->paras[0];
-        $piecesId = $req->paras[1]; # 英雄碎片的ID
+        $piecesId = $req->paras[1];                                             # 英雄碎片的ID
         $piecesNum = $req->paras[2];
         if (!CommUtil::isPropertyExists($user->heros, "recordUnLockHeroDic")) {
             $user->heros->recordUnLockHeroDic = ObjectInit();
@@ -101,8 +264,7 @@ class HeroProc {
         # 检查道具数量是否充足
         $enoughPieces = false;
         if ($heroModelId == $piecesCfg->prototypeData && $requirePiecesNum == $piecesNum) {
-            #检查碎片
-            if (!CommUtil::isPropertyExists($myPacketItems, $piecesId)) {
+            if (!CommUtil::isPropertyExists($myPacketItems, $piecesId)) {       # 检查碎片
                 $enoughPieces = false;
             } else {
                 if ($myPacketItems->$piecesId < $requirePiecesNum) {
@@ -115,8 +277,7 @@ class HeroProc {
             return Resp::err(ErrCode ::paras_err, "error pieces para" . "req" . $piecesId . "_" . $requirePiecesNum . "/" . $piecesId . "_" . $piecesNum);
         }
         if ($enoughPieces === true) {
-            # 6.进行
-            # # 消耗道具
+            # 6.进行 # # 消耗道具           
             $myPacketItems->$piecesId -= $requirePiecesNum;
             if ($myPacketItems->$piecesId < 0) {
                 $myPacketItems->$piecesId = 0;
@@ -124,131 +285,13 @@ class HeroProc {
             $recordUnLockHeroDic->$heroModelId = 1;
             $req->user->heros->recordUnLockHeroDic = $recordUnLockHeroDic;
             $req->userInfo->game->store->segement = $myPacketItems;
-            # 回写数据
-            UserProc::updateUserInfo($req);
-            //返回OK
-            return Resp::ok(array('result' => "OK"));
+            UserProc::updateUserInfo($req);                                     # 回写数据
+            return Resp::ok(array('result' => "OK"));                           //返回OK
         } else {
             return Resp::err(ErrCode::hero_godblood_notengoughitem);
         }
     }
 
-    /**
-     * 购买英雄 消耗碎片
-     * @param type $req
-     */
-    static function BuyHeroByCostPieces($req) {
-        $user = $req->userInfo->game; # user引用
-        $heroModelId = $req->paras[0];
-        $costType = $req->paras[1];
-        $costMoneyNum = $req->paras[2];
-        $piecesId = $req->paras[3];
-        $piecesNum = $req->paras[4];
-#1 检查玩家是否已经拥有此类英雄
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-        foreach ($collectHeros as $key => $value) {
-            isEditor() and $value = new UserHeroModel();
-            if ($value->modelId == $heroModelId) {
-                return Resp::err(ErrCode::hero_existSameHero_err);
-            }
-        }
-
-
-#2 检查账户余额是否充足
-        $heroCfg = GameConfig::hero_getItem($heroModelId);
-        if (!$heroCfg) {
-            return Resp::err(ErrCode::hero_const_no_err);
-        }
-        if ($heroCfg->isCanBuy == 0) {
-            return Resp::err(ErrCode::paras_err);
-        }
-#3检查碎片是否对不对
-        #检查需要消耗的碎片的常量配置是否存在
-        $piecesCfg = GameConfig::segment_getItem($piecesId);
-        if (!$piecesCfg) {
-            return Resp::err(ErrCode::err_store_itemnoconst);
-        }
-        # 5.检查道具的数量是否充足
-        $myPacketItems = $user->store->segement;
-        $requirePiecesNum = $piecesCfg->mergePrototypeNeedNum;
-        # 检查道具数量是否充足
-        $enoughPieces = false;
-        if ($heroModelId == $piecesCfg->prototypeData && $requirePiecesNum == $piecesNum) {
-            #检查碎片
-            if (!CommUtil::isPropertyExists($myPacketItems, $piecesId)) {
-                $enoughPieces = false;
-            } else {
-                if ($myPacketItems->$piecesId < $requirePiecesNum) {
-                    $enoughPieces = false;
-                } else {
-                    $enoughPieces = true;
-                }
-            }
-        } else {
-            return Resp::err(ErrCode ::paras_err, "error pieces para" . "req" . $piecesId . "_" . $requirePiecesNum . "/" . $piecesId . "_" . $piecesNum);
-        }
-        if ($enoughPieces == true) {
-            
-        } else {
-            return Resp::err(ErrCode::hero_godblood_notengoughitem);
-        }
-        $bDeal = false;  # 成交
-        if ($costType == "cash") {
-            $realPrice = $heroCfg->cashPrice;
-            if ($realPrice != $costMoneyNum) {
-                return Resp::err(ErrCode::paras_err, "costCASH error! server need:" . $realPrice);
-            } else {
-                if ($costMoneyNum > 0) {
-                    if ($user->cash < $costMoneyNum) {
-                        return Resp::err(ErrCode::err_msg_cashnotenough);
-                    } else {
-                        $bDeal = UserGameModel::Consume_Cash($user, $costMoneyNum);
-                    }
-                } else if ($costMoneyNum == 0) {
-                    $bDeal = true;
-                } else {
-                    return Resp::err(ErrCode::paras_err);
-                }
-            }
-        } else if ($costType == "gold") {
-            $realPrice = $heroCfg->goldPrice;
-            if ($realPrice != $costMoneyNum) {
-                return Resp::err(ErrCode::paras_err, "costGold error! server need:" . $realPrice);
-            } else {
-                if ($costMoneyNum > 0) {
-                    if ($user->gold < $costMoneyNum) {
-                        return Resp::err(ErrCode::err_msg_goldnotenough);
-                    } else {
-                        $bDeal = UserGameModel::Consume_Gold($user, $costMoneyNum);
-                    }
-                } else if ($costMoneyNum == 0) {
-                    $bDeal = true;
-                } else {
-                    return Resp::err(ErrCode::paras_err);
-                }
-            }
-        }
-        # 4.消耗来获得英雄
-        if ($bDeal) {
-            # 6.进行
-            # # 消耗道具
-            $myPacketItems->$piecesId -= $requirePiecesNum;
-            if ($myPacketItems->$piecesId < 0) {
-                $myPacketItems->$piecesId = 0;
-            }
-
-            $req->userInfo->game->store->segement = $myPacketItems;
-            # 回写数据
-            UserProc::updateUserInfo($req);
-            $resp = HeroProc::GetHero($req);
-            SystemProc::GetHero($req->zoneid, $user, $heroModelId);
-        }
-        return $resp;
-    }
-
     /**
      * 购买英雄
      * @param type $req
@@ -335,19 +378,6 @@ class HeroProc {
         return $resp;
     }
 
-    /**
-     * [6315]保持队伍的战斗配置信息
-     * @param Req $req
-     */
-    static function SaveHeroTeamConfig($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"));
-    }
-
     /**
      * 英雄技能升级
      * @param type $req
@@ -457,45 +487,6 @@ class HeroProc {
         return Resp::ok(array('firendSupportHeroUID' => $friendSupportHeroUids));
     }
 
-    /**
-     * 购买玩家可以收集的英雄的数量上限
-     * @param type $req
-     * @return type
-     */
-    static function BuyHeroMaxCountLimt($req) {
-        $g = glc();
-        $user = $req->userInfo->game;                                # user引用
-        if (!CommUtil::isPropertyExists($user->heros, "maxCollectCount")) {
-            $user->heros->maxCollectCount = $g->Game_CollectHero_BasicMaxCount;
-        }
-        $buyNum = $req->paras[0];
-        $costCash = $req->paras[1];
-
-        $index = ceil(($user->heros->maxCollectCount - $g->Game_CollectHero_BasicMaxCount) #
-                / $g->Game_CollectHero_OneBuyLimtNum);
-        $arr = explode(",", $g->Game_CollectHero_BasicMaxPrice);
-        if ($index >= count($arr)) {
-            return Resp::err(ErrCode::paras_err, "yi da shang xian");
-        }
-        $realCost = $arr[$index];
-
-        if ($realCost != $costCash) {
-            return Resp::err(ErrCode::paras_err, "costCash error! server need:" . $realCost);
-        }
-        if ($costCash <= 0) {
-            return Resp::err(ErrCode::paras_err);
-        }
-        if ($user->cash < $costCash) {
-            return Resp::err(ErrCode::notenough_spar);
-        }
-        UserGameModel::Consume_Cash($user, $costCash);               # 扣除宝石
-        $user->heros->maxCollectCount += $buyNum;                    # 修改上限
-        UserProc::updateUserInfo($req);
-        return Resp::ok(array(
-                    'maxCollectCount' => $user->heros->maxCollectCount
-        ));
-    }
-
     /**
      * 英雄的分解获得晶石
      * @param type $req
@@ -1085,125 +1076,227 @@ class HeroProc {
                     }
                 }
             }
-        }
-
-        if (!$checkHasEnoughItem) {
-            return Resp::err(ErrCode::hero_star_notengoughitem);
-        }
-# 5.检查金币是否充足
-        $bDeal = false;  # 成交
-        if ($queryCostGold != $costGold) {
-            return Resp::err(ErrCode::paras_err);
-        } else {
-            if ($costGold > 0) {
-                if ($user->gold < $costGold) {
-                    return Resp::err(ErrCode::notenough_gold_msg);
+        }
+
+        if (!$checkHasEnoughItem) {
+            return Resp::err(ErrCode::hero_star_notengoughitem);
+        }
+# 5.检查金币是否充足
+        $bDeal = false;  # 成交
+        if ($queryCostGold != $costGold) {
+            return Resp::err(ErrCode::paras_err);
+        } else {
+            if ($costGold > 0) {
+                if ($user->gold < $costGold) {
+                    return Resp::err(ErrCode::notenough_gold_msg);
+                } else {
+                    $bDeal = UserGameModel:: Consume_Gold($user, $costGold);
+                }
+            } else if ($costGold == 0) {
+                $bDeal = true;
+            } else {
+                return Resp::err(ErrCode::paras_err);
+            }
+        }
+
+# 6.进行消耗升星
+        if ($bDeal) {
+            $strengthHero->curStar += 1;
+# 消耗卡牌
+            foreach ($arr_costUID as $value) {
+                if ($value == "") {
+                    continue;
+                }
+                unset($collectHeros->$value);
+            }
+# # 消耗道具
+            foreach ($record as $key => $value) {
+                $myPacketItems->$key -= $value;
+                if ($myPacketItems->$key < 0) {
+                    $myPacketItems->$key = 0;
+                }
+            }
+
+            $req->userInfo->game->store->items = $myPacketItems;
+# 回写数据
+            UserProc::updateUserInfo($req);
+            $resp = Resp::ok($strengthHero);
+#  推送系统消息
+//            SystemProc::insertHero_Star($req->zoneid, $req->uid, $user->name, $heroCfg->name, $strengthHero->curStar);
+        }
+        ActiveProc::ChangeTaskCount($req);
+
+        return $resp;
+    }
+
+// </editor-fold>
+
+    /**
+     * 6321 购买英雄 消耗碎片
+     * @param type $req
+     */
+    static function BuyHeroByCostPieces($req) {
+        $user = $req->userInfo->game; # user引用
+        $heroModelId = $req->paras[0];
+        $costType = $req->paras[1];
+        $costMoneyNum = $req->paras[2];
+        $piecesId = $req->paras[3];
+        $piecesNum = $req->paras[4];
+        #1 检查玩家是否已经拥有此类英雄
+        $collectHeros = $user->heros->collectHeros;
+        if (!$collectHeros) {
+            $collectHeros = ObjectInit();
+        }
+        foreach ($collectHeros as $key => $value) {
+            isEditor() and $value = new UserHeroModel();
+            if ($value->modelId == $heroModelId) {
+                return Resp::err(ErrCode::hero_existSameHero_err);
+            }
+        }
+
+
+#2 检查账户余额是否充足
+        $heroCfg = GameConfig::hero_getItem($heroModelId);
+        if (!$heroCfg) {
+            return Resp::err(ErrCode::hero_const_no_err);
+        }
+        if ($heroCfg->isCanBuy == 0) {
+            return Resp::err(ErrCode::paras_err);
+        }
+#3检查碎片是否对不对
+
+        $piecesCfg = GameConfig::segment_getItem($piecesId);                    # 检查需要消耗的碎片的常量配置是否存在
+        if (!$piecesCfg) {
+            return Resp::err(ErrCode::err_store_itemnoconst);
+        }
+        # 5.检查道具的数量是否充足
+        $myPacketItems = $user->store->segement;
+        $requirePiecesNum = $piecesCfg->mergePrototypeNeedNum;
+        # 检查道具数量是否充足
+        $enoughPieces = false;
+        if ($heroModelId == $piecesCfg->prototypeData && $requirePiecesNum == $piecesNum) {
+
+            if (!CommUtil::isPropertyExists($myPacketItems, $piecesId)) {       # 检查碎片
+                $enoughPieces = false;
+            } else {
+                if ($myPacketItems->$piecesId < $requirePiecesNum) {
+                    $enoughPieces = false;
+                } else {
+                    $enoughPieces = true;
+                }
+            }
+        } else {
+            return Resp::err(ErrCode ::paras_err, "error pieces para" . "req" . $piecesId . "_" . $requirePiecesNum . "/" . $piecesId . "_" . $piecesNum);
+        }
+        if ($enoughPieces == true) {
+            
+        } else {
+            return Resp::err(ErrCode::hero_godblood_notengoughitem);
+        }
+        $bDeal = false;                                                         # 成交
+        if ($costType == "cash") {
+            $realPrice = $heroCfg->cashPrice;
+            if ($realPrice != $costMoneyNum) {
+                return Resp::err(ErrCode::paras_err, "costCASH error! server need:" . $realPrice);
+            } else {
+                if ($costMoneyNum > 0) {
+                    if ($user->cash < $costMoneyNum) {
+                        return Resp::err(ErrCode::err_msg_cashnotenough);
+                    } else {
+                        $bDeal = UserGameModel::Consume_Cash($user, $costMoneyNum);
+                    }
+                } else if ($costMoneyNum == 0) {
+                    $bDeal = true;
+                } else {
+                    return Resp::err(ErrCode::paras_err);
+                }
+            }
+        } else if ($costType == "gold") {
+            $realPrice = $heroCfg->goldPrice;
+            if ($realPrice != $costMoneyNum) {
+                return Resp::err(ErrCode::paras_err, "costGold error! server need:" . $realPrice);
+            } else {
+                if ($costMoneyNum > 0) {
+                    if ($user->gold < $costMoneyNum) {
+                        return Resp::err(ErrCode::err_msg_goldnotenough);
+                    } else {
+                        $bDeal = UserGameModel::Consume_Gold($user, $costMoneyNum);
+                    }
+                } else if ($costMoneyNum == 0) {
+                    $bDeal = true;
                 } else {
-                    $bDeal = UserGameModel:: Consume_Gold($user, $costGold);
+                    return Resp::err(ErrCode::paras_err);
                 }
-            } else if ($costGold == 0) {
-                $bDeal = true;
-            } else {
-                return Resp::err(ErrCode::paras_err);
             }
         }
-
-# 6.进行消耗升星
+        # 4.消耗来获得英雄
         if ($bDeal) {
-            $strengthHero->curStar += 1;
-# 消耗卡牌
-            foreach ($arr_costUID as $value) {
-                if ($value == "") {
-                    continue;
-                }
-                unset($collectHeros->$value);
-            }
-# # 消耗道具
-            foreach ($record as $key => $value) {
-                $myPacketItems->$key -= $value;
-                if ($myPacketItems->$key < 0) {
-                    $myPacketItems->$key = 0;
-                }
+            # 6.进行
+            # # 消耗道具
+            $myPacketItems->$piecesId -= $requirePiecesNum;
+            if ($myPacketItems->$piecesId < 0) {
+                $myPacketItems->$piecesId = 0;
             }
 
-            $req->userInfo->game->store->items = $myPacketItems;
-# 回写数据
+            $req->userInfo->game->store->segement = $myPacketItems;
+            # 回写数据
             UserProc::updateUserInfo($req);
-            $resp = Resp::ok($strengthHero);
-#  推送系统消息
-//            SystemProc::insertHero_Star($req->zoneid, $req->uid, $user->name, $heroCfg->name, $strengthHero->curStar);
+            $resp = HeroProc::GetHero($req);
+            SystemProc::GetHero($req->zoneid, $user, $heroModelId);
         }
-        ActiveProc::ChangeTaskCount($req);
-
         return $resp;
     }
 
     /**
-     * 英雄 强化 突破升阶
+     * [6315]保存队伍的战斗配置信息
      * @param Req $req
      */
-    static function HeroStrength($req) {
+    static function SaveHeroTeamConfig($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"));
+    }
+
+    /**
+     * 购买玩家可以收集的英雄的数量上限
+     * @param type $req
+     * @return type
+     */
+    static function BuyHeroMaxCountLimt($req) {
         $g = glc();
-#         $resp = ResponseVo::ErrResponse($req, ErrCode::msg_methodnotimplement);
-        $user = $req->userInfo->game; # user引用
-        $huid = $req->paras[0]; # 英雄的UID
-        $costUID = $req->paras[1]; # 消耗掉的英雄UID
-        $costGold = $req->paras[2];
-# 1.检查是否存在要升级的英雄
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-        if (!CommUtil::isPropertyExists($collectHeros, $huid)) {
-            return Resp::err(ErrCode::hero_no);
-        }
-        isEditor() and $strengthHero = new UserHeroModel();
-        $strengthHero = $collectHeros->$huid;
-        if ($strengthHero->strengthLevel >= $g->Hero_Stength_MaxStrengthLevel) {
-            return Resp::err(ErrCode::hero_strength_maxstrengthlevel);
-        }
-# 1.检查是否存在这个升阶数据的模板
-        $heroStrengthCostCfg = GameConfig::heroextra_dengjie_getItem($strengthHero->strengthLevel);
-        if (!$heroStrengthCostCfg) {
-            return Resp::err(ErrCode::hero_strength_cost_const_no);
+        $user = $req->userInfo->game;                                # user引用
+        if (!CommUtil::isPropertyExists($user->heros, "maxCollectCount")) {
+            $user->heros->maxCollectCount = $g->Game_CollectHero_BasicMaxCount;
         }
+        $buyNum = $req->paras[0];
+        $costCash = $req->paras[1];
 
-# 2.检查要消耗的英雄是否存在
-        if (!CommUtil::isPropertyExists($collectHeros, $costUID)) {
-            return Resp::err(ErrCode::hero_no);
+        $index = ceil(($user->heros->maxCollectCount - $g->Game_CollectHero_BasicMaxCount) #
+                / $g->Game_CollectHero_OneBuyLimtNum);
+        $arr = explode(",", $g->Game_CollectHero_BasicMaxPrice);
+        if ($index >= count($arr)) {
+            return Resp::err(ErrCode::paras_err, "yi da shang xian");
         }
-# 3.检查金币是否正确,以及玩家账户金币是否充足
-        $queryCostGold = $heroStrengthCostCfg->cost;
-        $bDeal = false;  # 成交
+        $realCost = $arr[$index];
 
-        if ($queryCostGold != $costGold) {
+        if ($realCost != $costCash) {
+            return Resp::err(ErrCode::paras_err, "costCash error! server need:" . $realCost);
+        }
+        if ($costCash <= 0) {
             return Resp::err(ErrCode::paras_err);
-        } else {
-            if ($costGold > 0) {
-                if ($user->gold < $costGold) {
-                    return Resp::err(ErrCode::notenough_gold_msg);
-                } else {
-                    $bDeal = UserGameModel:: Consume_Gold($user, $costGold);
-                }
-            } else if ($costGold == 0) {
-                $bDeal = true;
-            } else {
-                return Resp::err(ErrCode::paras_err);
-            }
         }
-# 4.消耗金币和英雄
-        if ($bDeal) {
-            unset($collectHeros->$costUID);
-# 5.强化英雄进行成功升阶 //6.数据回存
-            $strengthHero->strengthLevel += 1;
-            UserProc::updateUserInfo($req);
-            $resp = Resp::ok($strengthHero);
-            SystemProc::insertHero_StageUp($req->zoneid, $req->uid, $user->name, #
-                    GameConfig::hero_getItem($strengthHero->modelId)->name, $strengthHero->strengthLevel);
+        if ($user->cash < $costCash) {
+            return Resp::err(ErrCode::notenough_spar);
         }
-        ActiveProc::ChangeTaskCount($req);
-
-        return $resp;
+        UserGameModel::Consume_Cash($user, $costCash);               # 扣除宝石
+        $user->heros->maxCollectCount += $buyNum;                    # 修改上限
+        UserProc::updateUserInfo($req);
+        return Resp::ok(array(
+                    'maxCollectCount' => $user->heros->maxCollectCount
+        ));
     }
 
     /**
@@ -1226,6 +1319,8 @@ class HeroProc {
 #         return $resp;
     }
 
+// <editor-fold defaultstate="collapsed" desc="辅助方法">
+
     /**
      * 尝试图鉴整合
      * @param CredisUtil $mem
@@ -1379,6 +1474,54 @@ class HeroProc {
         return $max + 1;
     }
 
+    /**
+     * 一个英雄卡牌获得一点经验值
+     * @param string $heroUID
+     * @param int $totalEXP
+     * @param Req $req
+     */
+    static function HeroAddEXP($heroUID, $totalEXP, $req) {
+        $g = glc();
+        $collectHeros = $req->userInfo->game->heros->collectHeros;
+        if (!$collectHeros) {
+            $collectHeros = ObjectInit();
+        }
+        if (!CommUtil::isPropertyExists($collectHeros, $heroUID)) {
+            return;                                         # 要升级的英雄不存在
+        }
+        isEditor() and $targetHero = new UserHeroModel;
+        $targetHero = $collectHeros->$heroUID;
+
+        //$strengthconst = GameConfig::heroextra_dengjie_getItem($targetHero->strengthLevel);
+        $maxLevel = $g->Hero_Upgrade_BasicMaxLevel; //$strengthconst->maxLevel;
+        if ($targetHero->level >= $maxLevel) {
+            return;                                         # 已达顶级
+        }
+        $lvs = GameConfig::hero_levelexp_getItem($targetHero->level);
+        $targetHero->xp += $totalEXP;
+        CLog:: Assert("HeroProc", $targetHero->xp >= 0, #
+                "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
+
+        while ($targetHero->xp >= $targetHero->maxXp) {
+            if ($targetHero->level < $maxLevel) {           # 如果未到达最大等级
+                $nowlv = $targetHero->level + 1;
+                $nextlv = $nowlv + 1;
+                $targetHero->level = $nowlv;
+                $lvs = GameConfig::hero_levelexp_getItem($nextlv);
+                if ($nowlv >= $maxLevel) {
+                    $targetHero->xp = $targetHero->maxXp;
+                }
+                $targetHero->maxXp = $lvs->requiredExp;
+            } else {                                        # 如果已到达最大等级则仅补齐缺失的经验即可
+                $targetHero->xp = $targetHero->maxXp;       # 经验不能超过最大值
+                break;
+            }
+        }
+    }
+
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="废弃代码">
+
     /**
      * [6301] 英雄升级 - 消耗经验道具书,获得经验
      * @param type $req
@@ -1590,50 +1733,7 @@ class HeroProc {
         return $resp;
     }
 
-    /**
-     * 一个英雄卡牌获得一点经验值
-     * @param string $heroUID
-     * @param int $totalEXP
-     * @param Req $req
-     */
-    static function HeroAddEXP($heroUID, $totalEXP, $req) {
-        $g = glc();
-        $collectHeros = $req->userInfo->game->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-        if (!CommUtil::isPropertyExists($collectHeros, $heroUID)) {
-            return;                                         # 要升级的英雄不存在
-        }
-        isEditor() and $targetHero = new UserHeroModel;
-        $targetHero = $collectHeros->$heroUID;
-
-        //$strengthconst = GameConfig::heroextra_dengjie_getItem($targetHero->strengthLevel);
-        $maxLevel = $g->Hero_Upgrade_BasicMaxLevel; //$strengthconst->maxLevel;
-        if ($targetHero->level >= $maxLevel) {
-            return;                                         # 已达顶级
-        }
-        $lvs = GameConfig::hero_levelexp_getItem($targetHero->level);
-        $targetHero->xp += $totalEXP;
-        CLog:: Assert("HeroProc", $targetHero->xp >= 0, #
-                "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
-
-        while ($targetHero->xp >= $targetHero->maxXp) {
-            if ($targetHero->level < $maxLevel) {           # 如果未到达最大等级
-                $nowlv = $targetHero->level + 1;
-                $nextlv = $nowlv + 1;
-                $targetHero->level = $nowlv;
-                $lvs = GameConfig::hero_levelexp_getItem($nextlv);
-                if ($nowlv >= $maxLevel) {
-                    $targetHero->xp = $targetHero->maxXp;
-                }
-                $targetHero->maxXp = $lvs->requiredExp;
-            } else {                                        # 如果已到达最大等级则仅补齐缺失的经验即可
-                $targetHero->xp = $targetHero->maxXp;       # 经验不能超过最大值
-                break;
-            }
-        }
-    }
+// </editor-fold>
 
     /**
      * [6306] 英雄-更改英雄的锁定状态

+ 1 - 1
Gameserver/Amfphp/Process/StoreProc.php

@@ -446,7 +446,7 @@ class StoreProc {
     }
 
     /**
-     * [6409] 合成碎片
+     * [6409] 合成碎片(几个碎片合成获得同品质或者更高品质的新碎片)
      * @param Req $req
      */
     static public function composePieces($req) {

+ 5 - 5
Gameserver/Amfphp/service_call/pay/Mo/payRequest.php

@@ -70,7 +70,7 @@ class PayRequest extends loyalsoft\Object_ext {
      * @return array 订单写入数据库
      */
     public function InserDataBase() {
-        return false;                                                           # 2019.10.9 关闭充值
+//        return false;                                                           # 2019.10.9 关闭充值
         $arr = get_object_vars($this);                                          # 转为数组
         $arr["uid"] = $arr["accountId"];                                        # 转换下变量名称
         $arr["amount"] = $arr["amount"] * 100;                                  # 拉起平台时传的单位是元,比如UC还有易接,而游戏后台存储的是分
@@ -149,10 +149,10 @@ class PayRequest extends loyalsoft\Object_ext {
 
         if ($this->amount) {
             $this->amount = number_format($this->amount, 2, '.', '');
-//            if ('soft' == $this->channel) {                                   # 2018年1月15号以前固定为1分钱测试
-//                $this->amount = number_format(0.01, 2, '.', '');
-//                $this->product_price = 0.01;
-//            } else  //
+            if ('soft' == $this->channel) {                                   # 2018年1月15号以前固定为1分钱测试
+                $this->amount = number_format(0.01, 2, '.', '');
+                $this->product_price = 0.01;
+            } else  //
             if ($this->amount != loyalsoft\GameConfig::shop_getItem($this->product_id)->price) {
                 var_dump($this->product_id);
                 var_dump(loyalsoft\GameConfig::shop_getItem($this->product_id)->price);

+ 3 - 2
Gameserver/Amfphp/service_call/pay/official/wxpay/lib/WxPay.Api.php

@@ -55,8 +55,9 @@ class WxPayApi {
         $inputObj->SetNonce_str(self::getNonceStr()); //随机字符串
         //签名
         $inputObj->SetSign();
+//        \loyalsoft\CLog::pay($inputObj);
         $xml = $inputObj->ToXml();
-
+//        \loyalsoft\CLog::pay($xml);
         $startTimeStamp = self::getMillisecond(); //请求开始时间
         $response = self::postXmlCurl($xml, $url, false, $timeOut);
         $result = WxPayResults::Init($response);
@@ -506,7 +507,7 @@ class WxPayApi {
      * @throws WxPayException
      */
     private static function postXmlCurl($xml, $url, $useCert = false, $second = 30) {
-        var_dump($url);
+//        var_dump($url);
         $ch = curl_init();
         //设置超时
         curl_setopt($ch, CURLOPT_TIMEOUT, $second);

+ 2 - 0
Gameserver/Amfphp/service_call/pay/official/wxpay/lib/WxPay.Data.php

@@ -105,10 +105,12 @@ class WxPayDataBase {
         $string = $this->ToUrlParams();
         //签名步骤二:在string后加入KEY
         $string = $string . "&key=" . WxPayConfig::KEY;
+//        \loyalsoft\CLog::pay($string);
         //签名步骤三:MD5加密
         $string = md5($string);
         //签名步骤四:所有字符转为大写
         $result = strtoupper($string);
+//        \loyalsoft\CLog::pay($result);
         return $result;
     }
 

+ 1 - 0
Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php

@@ -63,6 +63,7 @@ if ($req->InserDataBase()) {
             echo Resp::err($order['err_code'], $order['err_code_des']);
         }
     } else {
+        CLog::pay($order);
         CLog::pay("[$tag.pay]向$tag 后台推送订单失败, 通讯失败.");
         echo Resp::err(1, "微信统一下单请求,通讯失败!");
     }

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

@@ -12,10 +12,12 @@
     </editor-bookmarks>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
         <group>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Model/User/UserGatesModel.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Model/User/PrivateStateModel.php</file>
+            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Process/FightProc/SweepGatesProc.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Process/UserProc.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Process/vo/CmdCode.php</file>
             <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Process/StoreProc.php</file>
-            <file>file:/E:/www/ylsj2019/Gameserver/Amfphp/Process/HeroProc.php</file>
         </group>
     </open-files>
 </project-private>