Browse Source

代码整理

gwang 5 years ago
parent
commit
ba59856be3
1 changed files with 6 additions and 322 deletions
  1. 6 322
      Gameserver/Amfphp/process/HeroProc.php

+ 6 - 322
Gameserver/Amfphp/process/HeroProc.php

@@ -23,19 +23,9 @@ class HeroProc {
 //            case CmdCode::cmd_hero_upstar:                                    #  [6305] 英雄升星
 //                return HeroProc::HeroUpStarByPieces($req);
 //            case CmdCode::cmd_hero_changelockstate:                           #  [6306] 英雄-修改锁定状态
-//                return HeroProc::HeroChangelockstate($req);
-//            case CmdCode::cmd_hero_gethero:                                   #  [6308] 分解英雄
-//                return HeroProc::GetHero($req);
-//            case CmdCode::cmd_hero_strength:                                  #  [6309] 英雄升阶
-//                return HeroProc::HeroStrength($req);
-//            case CmdCode::cmd_hero_openFavor:                                 #  [6310] 英雄好感度解锁
-//                return HeroProc::HeroOpenFavor($req);
-//            case CmdCode::cmd_hero_separate:                                  #  [6311] 分解英雄
-//                return HeroProc::HeroSeparate($req);
+//                return HeroProc::HeroChangelockstate($req); 
 //            case CmdCode::cmd_hero_buyCollectHeroLimtCount:                   #  [6312] 扩展英雄数量上限
-//                return HeroProc::BuyHeroMaxCountLimt($req);
-//            case CmdCode::cmd_hero_changefriendsupport:                       #  [6313] 更换支援好友
-//                return HeroProc::ChangeFriendSupport($req);
+//                return HeroProc::BuyHeroMaxCountLimt($req); 
             // </editor-fold>
 # --------- 英雄技能 -----------                
             case CmdCode::cmd_hero_upgradeSkillLevel:                           #  [6314] 英雄的技能升级
@@ -266,93 +256,6 @@ class HeroProc {
 // 
 // <editor-fold defaultstate="collapsed" desc="已过时代码">
 
-    /**
-     * [6314]英雄技能升级
-     * @param req $req
-     */
-    static function _UpgradeSkillLevel($req) {
-#         $resp = ResponseVo::ErrResponse($req, ErrCode::msg_methodnotimplement);
-        $user = $req->userInfo->game; # user引用
-        $huid = $req->paras[0];                                                 # 英雄的UID
-        $skillId = $req->paras[1];                                              # 要升级的技能
-        $skillType = $req->paras[2];                                            # 要升级的技能
-        $costGold = $req->paras[3];                                             # 要升级的消耗金币
-#                                                                               # 1.检查是否存在要升级的英雄
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-        if (!CommUtil::isPropertyExists($collectHeros, $huid)) {
-            return Resp::err(ErrCode::hero_no);
-        }
-#                                                                               # 2.判断英雄的该技能能否升级....
-        isEditor() and $strengthHero = new UserHeroModel();
-        $strengthHero = $collectHeros->$huid;
-#                                                                               # 取出这个英雄的技能数据
-        $targteHeroSkills = ObjectInit();
-        if (CommUtil::isPropertyExists($strengthHero, "skills")) {
-            $targteHeroSkills = $strengthHero->skills;
-        }
-
-        if (!CommUtil::isPropertyExists($targteHeroSkills, $skillType)) {       # 如果不存在这个类型的技能,则 初始化一个.
-            $targteHeroSkills->$skillType = JsonUtil::decode('{"level":1}');
-        }
-        $curSkillInfo = $targteHeroSkills->$skillType;
-        $curSkillLevel = $curSkillInfo->level;
-# 3.判断技能等级能否在继续升级了
-        if ($curSkillLevel >= $strengthHero->level) {
-            return Resp::err(ErrCode::hero_upgradeSkill_maxLevel);
-        }
-# 4.取出该技能升级消耗的常量数据
-# 检查是否存在当前技能的消耗常量数据
-//        $lvs = GameConfig::skill_shengji_getItem($skillId);
-        $lvs = GameConfig::skill_upgrade_cost_getItem($skillId);
-        if (!$lvs) {
-            return Resp::err(ErrCode::hero_upgradeSkill_cost_const_no);
-        }
-        $realGold = $lvs->basic + ($curSkillLevel - 1) * $lvs->xishu;
-        $arr_extracost = explode(";", $lvs->extra);
-        foreach ($arr_extracost as $value) {
-            $arr = explode(",", $value);
-            if (count($arr) == 2) {
-                $extraLevel = $arr[0];
-                $extraGold = $arr[1];
-                if ($extraLevel == $curSkillLevel + 1) {
-                    $realGold += $extraGold;
-                    break;
-                }
-            }
-        }
-
-# 判断金币是否充足
-        $bDeal = false;  # 成交
-        if ($realGold != $costGold) {
-            return Resp::err(ErrCode::paras_err, "costGold error! server need:" . $realGold);
-        } 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) {
-            $targteHeroSkills->$skillType->level += 1;
-            $strengthHero->skills = $targteHeroSkills;
-            ActiveProc::ChangeTaskCount($req);
-# 回写数据
-            UserProc::updateUserInfo();
-            $resp = Resp::ok($strengthHero);
-        }
-        return $resp;
-    }
-
     /**
      * 6323 解锁英雄
      * @param type $req
@@ -422,224 +325,7 @@ class HeroProc {
     }
 
     /**
-     * 购买英雄
-     * @param type $req
-     */
-    static function BuyHero($req) {
-        $user = $req->userInfo->game; # user引用
-        $heroModelId = $req->paras[0];
-        $costType = $req->paras[1];
-        $costMoneyNum = $req->paras[2];
-#1 检查玩家是否已经拥有此类英雄
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-        foreach ($collectHeros as $key => $value) {
-            isEditor() and $value = new UserHeroModel();
-            if ($value->typeId == $heroModelId) {
-                return Resp::err(ErrCode::hero_existSameHero_err);
-            }
-        }
-        $recordUnLockHeroDic = $user->heros->recordUnLockHeroDic;
-        if (!$recordUnLockHeroDic) {
-            $recordUnLockHeroDic = ObjectInit();
-        }
-        #检查是不是已经解锁过了
-        $flag = 0;
-        if (!CommUtil::isPropertyExists($recordUnLockHeroDic, $heroModelId)) {
-            $recordUnLockHeroDic->$heroModelId = 0;
-        }
-        $flag = $recordUnLockHeroDic->$heroModelId;
-        if ($flag == 0) {
-            return Resp::err(ErrCode::hero_lockState);
-        }
-
-#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);
-        }
-
-        $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::notenough_cash_msg);
-                    } 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::notenough_gold_msg);
-                    } else {
-                        $bDeal = UserGameModel::Consume_Gold($user, $costMoneyNum);
-                    }
-                } else if ($costMoneyNum == 0) {
-                    $bDeal = true;
-                } else {
-                    return Resp::err(ErrCode::paras_err);
-                }
-            }
-        }
-# 4.消耗来获得英雄
-        if ($bDeal) {
-            $resp = HeroProc::GetHero($req);
-        }
-        return $resp;
-    }
-
-    /**
-     * 更改好友支援
-     * @param type $req
-     */
-    static function ChangeFriendSupport($req) {
-        $user = $req->userInfo->game;            # user引用
-        if (!CommUtil::isPropertyExists($user->heros, "firendSupportHeroUID")) {
-            $user->heros->firendSupportHeroUID = "";
-        }
-        $friendSupportHeroUids = $req->paras[0]; # 设置支援好友的英雄UID
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }                                        # 1.检查玩家存在指定的英雄
-        if (!CommUtil::isPropertyExists($collectHeros, $friendSupportHeroUids)) {
-            return Resp::err(ErrCode::hero_separate_cost_hero);
-        }
-        $user->heros->firendSupportHeroUID = $friendSupportHeroUids;
-        UserProc::updateUserInfo();          # 回存数据
-        return Resp::ok(array('firendSupportHeroUID' => $friendSupportHeroUids));
-    }
-
-    /**
-     * 英雄的分解获得晶石
-     * @param type $req
-     * @return type
-     */
-    static function HeroSeparate($req) {
-        $g = glc();
-        $user = $req->userInfo->game; # user引用
-        $costHeroUids = $req->paras[0]; # 消耗掉的英雄UID
-# 1.检查是玩家的英雄数据
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-# 3.检查消耗的英雄数量,以及玩家是否都存在这些英雄UID.
-        $arr_costUID = explode(",", $costHeroUids);
-        $isAllExist = true;
-        foreach ($arr_costUID as $value) {
-            if ($value == "") {
-                continue;
-            }
-            if (!CommUtil::isPropertyExists($collectHeros, $value)) {
-                $isAllExist = false;
-                break;
-            }
-        }
-        if (!$isAllExist) {
-            return Resp::err(ErrCode::hero_separate_cost_hero);
-        }
-# 4.统计下这些个英雄都能获得多少晶石
-# 消耗卡牌
-        $spar = 0;
-        $starToSparCfgArr = explode(",", $g->Hero_Star_SeparateToSpar);
-        foreach ($arr_costUID as $huid) {
-            if ($huid == "") {
-                continue;
-            }
-            isEditor() and $strengthHero = new UserHeroModel();
-            $strengthHero = $collectHeros->$huid;
-            $index = $strengthHero->curStar - 1;
-            if ($index >= 0 && $index < count($starToSparCfgArr)) {
-                $spar += $starToSparCfgArr[$index];
-            }
-            unset($collectHeros->$huid);
-        }
-#  发物品到玩家包裹
-        $req->userInfo->game->spar += $spar; # 入账能量块
-#  回存数据
-        UserProc::updateUserInfo();
-        return Resp::ok(array('num' => $spar));
-    }
-
-    /**
-     * 英雄好感度解锁
-     * @param type $req
-     */
-    static function HeroOpenFavor($req) {
-        $user = $req->userInfo->game;     # user引用
-        $huid = $req->paras[0];           # 英雄的UID
-        $targetFavorId = $req->paras[1];  # 目标好感度 索引id
-# 1.检查是否存在要升级的英雄
-        $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            $collectHeros = ObjectInit();
-        }
-        if (!CommUtil::isPropertyExists($collectHeros, $huid)) {
-            return Resp::err(ErrCode::hero_no);
-        }
-# 2.检查目标好感度的常量数据是否存在
-        $favorCfg = GameConfig::heroextra_favor_getItem($targetFavorId);
-        if (!$favorCfg) {
-            return Resp::err(ErrCode::hero_favor_cost_const_no);
-        }
-# 3.检查英雄是否已经解锁了目标好感度
-        $strengthHero = $collectHeros->$huid;
-        if (!$strengthHero->curMainFavor) {
-            $strengthHero->curMainFavor = 'E';
-        }
-        if (!$strengthHero->favors) {
-            $strengthHero->favors = ArrayInit();
-            $strengthHero->favors[] = 'E';
-        }
-        if (CommUtil::isInArray($strengthHero->favors, $favorCfg->name)) {
-            return Resp::err(ErrCode::hero_favor_targetfavor_para);
-        }
-#  4.检查消耗道具是否充足
-        $costSpar = $favorCfg->cost;
-        $bDeal = false;  # 成交
-        if ($costSpar > 0) {
-            if ($user->spar < $costSpar) {
-                return Resp::err(ErrCode::notenough_spar);
-            } else {
-                $bDeal = UserGameModel::Consume_Spar($user, $costSpar);
-            }
-        } else {
-            return Resp::err(ErrCode::paras_err);
-        }
-# 6.进行消耗升星
-        if ($bDeal) {
-            if ($favorCfg->isMain) {
-                $strengthHero->curMainFavor = $favorCfg->name;
-            }
-            $strengthHero->favors[] = $favorCfg->name;
-            UserProc::updateUserInfo();
-            $resp = Resp::ok($strengthHero);
-        }
-        return $resp;
-    }
-
-    /**
-     * 英雄神血
+     * [6322] 英雄神血
      * @param Req $req
      */
     static function UpGodBloodHeroByPieces($req) {
@@ -1308,7 +994,7 @@ class HeroProc {
      */
     static function GetHero($req) {
         $heroModelId = $req->paras[0];                                          // 英雄的模板ID 
-        $heroCfg = GameConfig::hero_getItem($heroModelId);                      //1.检查是否存在这个英雄的模板
+        $heroCfg = GameConfig::hero_getItem($heroModelId);                      // 1.检查是否存在这个英雄的模板
         my_Assert(null != $heroCfg, ErrCode::hero_const_no_err);
         $hero = self::AddHeroTFromStore($req, $heroModelId);
         UserProc::updateUserInfo();
@@ -1528,13 +1214,11 @@ class HeroProc {
         $lockstate = $req->paras[1];                                            # 玩家英雄锁定状态
         $collectHeros = $gamedata->heros->collectHeros;
         my_default_Obj($collectHeros);                                          # 默认值
-        if (!CommUtil::isPropertyExists($collectHeros, $heroUID)) {
-            Err(ErrCode::hero_no);
-        }
+        my_Assert(CommUtil::isPropertyExists($collectHeros, $heroUID), ErrCode::hero_no);
 //        isEditor() and $hero = new UserHeroModel;
         $hero = $collectHeros->$heroUID;                                        # 1. 获取这个英雄的实例数据是
         $hero->isLocked = $lockstate;                                           # 2. 修改英雄状态
-        UserProc::updateUserInfo();                                         # 3. 保存玩家数据
+        UserProc::updateUserInfo();                                             # 3. 保存玩家数据
         return Resp::ok(ObjectInit()); # 4. 设置返回值
     }