|
@@ -7,7 +7,6 @@ namespace loyalsoft;
|
|
|
* @author gwang
|
|
|
*/
|
|
|
class HeroProc {
|
|
|
-//put your code here
|
|
|
|
|
|
/**
|
|
|
* 英雄处理逻辑分发
|
|
@@ -20,6 +19,7 @@ class HeroProc {
|
|
|
return HeroProc::HeroLevelUpCostExpItem($req);
|
|
|
case CmdCode::cmd_hero_stageup: # [6304] 英雄进阶 SABCD
|
|
|
return HeroProc::HeroStageUp($req);
|
|
|
+ // <editor-fold defaultstate="collapsed" desc="过时 接口">
|
|
|
// case CmdCode::cmd_hero_upstar: # [6305] 英雄升星
|
|
|
// return HeroProc::HeroUpStarByPieces($req);
|
|
|
// case CmdCode::cmd_hero_changelockstate: # [6306] 英雄-修改锁定状态
|
|
@@ -36,13 +36,14 @@ class HeroProc {
|
|
|
// return HeroProc::BuyHeroMaxCountLimt($req);
|
|
|
// case CmdCode::cmd_hero_changefriendsupport: # [6313] 更换支援好友
|
|
|
// return HeroProc::ChangeFriendSupport($req);
|
|
|
+ // </editor-fold>
|
|
|
# --------- 英雄技能 -----------
|
|
|
case CmdCode::cmd_hero_upgradeSkillLevel: # [6314] 英雄的技能升级
|
|
|
return HeroProc::UpgradeSkillLevel($req);
|
|
|
case CmdCode::cmd_hero_unlockSkill: # [6324] 英雄技能 - 解锁技能
|
|
|
- return;
|
|
|
+ return HeroProc::UnlockSkill($req);
|
|
|
case CmdCode::cmd_hero_skillLevel_onekeyupgrade: # [6325] 英雄技能 - 一键升级
|
|
|
- return;
|
|
|
+ return HeroProc::OnekeyUpgradeSkillLevel($req);
|
|
|
case CmdCode::cmd_hero_saveHeroTeamConfig: # [6315] 保存玩家战队数据
|
|
|
return HeroProc::SaveHeroTeamConfig($req);
|
|
|
# --------- 英雄评论 -----------
|
|
@@ -56,7 +57,7 @@ class HeroProc {
|
|
|
return HeroDiscussProc::DeletePost($req);
|
|
|
case CmdCode::cmd_hero_scoreit: # [6320]给某个英雄评分
|
|
|
return HeroDiscussProc::Score($req);
|
|
|
-#----------------------------------------------
|
|
|
+#----------- 英雄的解锁与购买 --------------
|
|
|
case CmdCode::cmd_hero_buyHero: # [6321]购买英雄
|
|
|
return HeroProc::BuyHeroByCostPieces($req);
|
|
|
case CmdCode::cmd_hero_upGodBlood: # [6322] 神血升级
|
|
@@ -69,11 +70,154 @@ class HeroProc {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// <editor-fold defaultstate="collapsed" desc="技能升级与解锁">
|
|
|
+
|
|
|
/**
|
|
|
- * 英雄技能升级
|
|
|
- * @param type $req
|
|
|
+ * [6324] 英雄技能解锁
|
|
|
+ * @param req $req
|
|
|
+ */
|
|
|
+ static function UnlockSkill($req) {
|
|
|
+ $user = $req->userInfo->game; # user引用
|
|
|
+ $huid = $req->paras[0]; # 英雄的UID
|
|
|
+ $mainSkillId = $req->paras[1]; # 主技能Id
|
|
|
+ $subSkillId = $req->paras[2]; # 要升级的子技能ID
|
|
|
+// $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 $targetHero = new UserHeroModel();
|
|
|
+ $targetHero = $collectHeros->$huid;
|
|
|
+# # 取出这个英雄的技能数据
|
|
|
+ $targteHeroSkills = $targetHero->subSkills;
|
|
|
+ if (!CommUtil::isPropertyExists($targteHeroSkills, $mainSkillId)) { # 主技能Id.
|
|
|
+ return \Resp::err(ErrCode::err_unknownn, "玩家数据结构问题");
|
|
|
+ }
|
|
|
+ if (CommUtil::isPropertyExists($targteHeroSkills->$mainSkillId, $subSkillId)) { # 子技能已经解锁
|
|
|
+ return \Resp::err(ErrCode::err_unknownn, "子技能已解锁");
|
|
|
+ }
|
|
|
+// if (!$targetHero->IsSkillUnlockAble($mainSkillId, $subSkillId)) { # 3.判断技能是否处于待解锁状态
|
|
|
+// return Resp::err(ErrCode::hero_upgradeSkill_maxLevel);
|
|
|
+// }
|
|
|
+
|
|
|
+ $sm = GameConfig::subSkill_getItem($subSkillId); # 4.取出该技能升级消耗的常量数据
|
|
|
+ if (null == $sm) {
|
|
|
+ return \Resp::err(ErrCode::err_const_no, '找不到子技能配置数据');
|
|
|
+ }
|
|
|
+ if (!UserGameModel::Consume_Gold($user, $sm->unlockCost)) { # 5. 扣除金币消耗
|
|
|
+ return Resp::err(ErrCode::notenough_gold_msg);
|
|
|
+ }
|
|
|
+ $targteHeroSkills->$mainSkillId[] = $subSkillId; # 添加技能
|
|
|
+ $targetHero->subSkills = $targteHeroSkills;
|
|
|
+ UserProc::updateUserInfo($req); # 回写数据
|
|
|
+ return Resp::ok($targetHero);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [6325] 英雄技能一键升级
|
|
|
+ * @param req $req
|
|
|
+ */
|
|
|
+ static function OnekeyUpgradeSkillLevel($req) {
|
|
|
+ $user = $req->userInfo->game; # user引用
|
|
|
+ $huid = $req->paras[0]; # 英雄的UID
|
|
|
+ $mainSkillId = $req->paras[1]; # 主技能Id
|
|
|
+ $subSkillId = $req->paras[2]; # 要升级的子技能ID
|
|
|
+ $targetSubSkillId = $req->paras[3]; # 升级到的子技能Id
|
|
|
+ $costGold = $req->paras[4]; # 要升级的消耗金币
|
|
|
+# # 1.检查是否存在要升级的英雄
|
|
|
+ $collectHeros = $user->heros->collectHeros;
|
|
|
+ if (!$collectHeros) {
|
|
|
+ $collectHeros = ObjectInit();
|
|
|
+ }
|
|
|
+ if (!CommUtil::isPropertyExists($collectHeros, $huid)) {
|
|
|
+ return Resp::err(ErrCode::hero_no);
|
|
|
+ }
|
|
|
+# # 2.判断英雄的该技能能否升级....
|
|
|
+ isEditor() and $targetHero = new UserHeroModel();
|
|
|
+ $targetHero = $collectHeros->$huid;
|
|
|
+# # 取出这个英雄的技能数据
|
|
|
+ $targteHeroSkills = $targetHero->subSkills;
|
|
|
+ if (!CommUtil::isPropertyExists($targteHeroSkills, $mainSkillId)) { # 主技能Id.
|
|
|
+ return \Resp::err(ErrCode::err_unknownn, "玩家数据结构问题");
|
|
|
+ }
|
|
|
+ if (!CommUtil::isPropertyExists($targteHeroSkills->$mainSkillId, $subSkillId)) {
|
|
|
+ return \Resp::err(ErrCode::err_unknownn, "子技能id错误");
|
|
|
+ }
|
|
|
+
|
|
|
+// if (!$targetHero->IsSkillUpdateAble($mainSkillId, $subSkillId)) { # 3.判断技能等级能否在继续升级了
|
|
|
+// return Resp::err(ErrCode::hero_upgradeSkill_maxLevel);
|
|
|
+// }
|
|
|
+// $sm = GameConfig::subSkill_getItem($subSkillId); # 4.取出该技能升级消耗的常量数据
|
|
|
+// if (null == $sm) {
|
|
|
+// return \Resp::err(ErrCode::err_const_no, '找不到子技能配置数据');
|
|
|
+// }
|
|
|
+ if (!UserGameModel::Consume_Gold($user, $costGold)) { # 5. 扣除金币消耗
|
|
|
+ return Resp::err(ErrCode::notenough_gold_msg);
|
|
|
+ }
|
|
|
+ unset($targteHeroSkills->$mainSkillId, $subSkillId); # 替换技能
|
|
|
+ $targteHeroSkills->$mainSkillId[] = $targetSubSkillId;
|
|
|
+ $targetHero->subSkills = $targteHeroSkills;
|
|
|
+ UserProc::updateUserInfo($req); # 回写数据
|
|
|
+ return Resp::ok($targetHero);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [6314]英雄技能升级
|
|
|
+ * @param req $req
|
|
|
*/
|
|
|
static function UpgradeSkillLevel($req) {
|
|
|
+ $user = $req->userInfo->game; # user引用
|
|
|
+ $huid = $req->paras[0]; # 英雄的UID
|
|
|
+ $mainSkillId = $req->paras[1]; # 主技能Id
|
|
|
+ $subSkillId = $req->paras[2]; # 要升级的子技能ID
|
|
|
+// $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 $targetHero = new UserHeroModel();
|
|
|
+ $targetHero = $collectHeros->$huid;
|
|
|
+# # 取出这个英雄的技能数据
|
|
|
+ $targteHeroSkills = $targetHero->subSkills;
|
|
|
+ if (!CommUtil::isPropertyExists($targteHeroSkills, $mainSkillId)) { # 主技能Id.
|
|
|
+ return \Resp::err(ErrCode::err_unknownn, "玩家数据结构问题");
|
|
|
+ }
|
|
|
+ if (!CommUtil::isPropertyExists($targteHeroSkills->$mainSkillId, $subSkillId)) {
|
|
|
+ return \Resp::err(ErrCode::err_unknownn, "子技能id错误");
|
|
|
+ }
|
|
|
+ if (!$targetHero->IsSkillUpdateAble($mainSkillId, $subSkillId)) { # 3.判断技能等级能否在继续升级了
|
|
|
+ return Resp::err(ErrCode::hero_upgradeSkill_maxLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ $sm = GameConfig::subSkill_getItem($subSkillId); # 4.取出该技能升级消耗的常量数据
|
|
|
+ if (null == $sm) {
|
|
|
+ return \Resp::err(ErrCode::err_const_no, '找不到子技能配置数据');
|
|
|
+ }
|
|
|
+ if (!UserGameModel::Consume_Gold($user, $sm->upgradeCost)) { # 5. 扣除金币消耗
|
|
|
+ return Resp::err(ErrCode::notenough_gold_msg);
|
|
|
+ }
|
|
|
+ unset($targteHeroSkills->$mainSkillId, $subSkillId); # 替换技能
|
|
|
+ $targteHeroSkills->$mainSkillId[] = $sm->nextLevel_Id;
|
|
|
+ $targetHero->subSkills = $targteHeroSkills;
|
|
|
+ UserProc::updateUserInfo($req); # 回写数据
|
|
|
+ return Resp::ok($targetHero);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [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
|
|
@@ -96,8 +240,8 @@ class HeroProc {
|
|
|
if (CommUtil::isPropertyExists($strengthHero, "skills")) {
|
|
|
$targteHeroSkills = $strengthHero->skills;
|
|
|
}
|
|
|
-# 如果不存在这个类型的技能,则 初始化一个.
|
|
|
- if (!CommUtil::isPropertyExists($targteHeroSkills, $skillType)) {
|
|
|
+
|
|
|
+ if (!CommUtil::isPropertyExists($targteHeroSkills, $skillType)) { # 如果不存在这个类型的技能,则 初始化一个.
|
|
|
$targteHeroSkills->$skillType = JsonUtil::decode('{"level":1}');
|
|
|
}
|
|
|
$curSkillInfo = $targteHeroSkills->$skillType;
|
|
@@ -156,6 +300,7 @@ class HeroProc {
|
|
|
return $resp;
|
|
|
}
|
|
|
|
|
|
+// </editor-fold>
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc="英雄 强化">
|
|
|
|
|
@@ -1238,19 +1383,15 @@ class HeroProc {
|
|
|
* @param type $req
|
|
|
*/
|
|
|
static function GetHero($req) {
|
|
|
- $heroModelId = $req->paras[0]; //英雄的模板ID
|
|
|
-//1.检查是否存在这个英雄的模板
|
|
|
- $heroCfg = GameConfig::hero_getItem($heroModelId);
|
|
|
+ $heroModelId = $req->paras[0]; // 英雄的模板ID
|
|
|
+ $heroCfg = GameConfig::hero_getItem($heroModelId); //1.检查是否存在这个英雄的模板
|
|
|
if (!$heroCfg) {
|
|
|
return Resp::err(ErrCode::hero_const_no_err);
|
|
|
}
|
|
|
$hero = self::AddHeroTFromStore($req, $heroModelId);
|
|
|
UserProc::updateUserInfo($req);
|
|
|
-# 4. 设置返回值
|
|
|
- $result = array('result' => "succeed",
|
|
|
- 'heros' => $hero);
|
|
|
+ $result = array('result' => "succeed", 'heros' => $hero); # 4. 设置返回值
|
|
|
return Resp::ok($result);
|
|
|
-# return $resp;
|
|
|
}
|
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="辅助方法">
|
|
@@ -1329,47 +1470,41 @@ class HeroProc {
|
|
|
*/
|
|
|
static function AddHeroTFromStore(&$req, $heromodelId) {
|
|
|
$gamedata = $req->userInfo->game;
|
|
|
- if (!CommUtil::isPropertyExists($gamedata, "heroManual")) {
|
|
|
- $gamedata->heroManual = new HeroManualModel();
|
|
|
- $gamedata->heroManual->initInstance();
|
|
|
- }
|
|
|
- $manual = $gamedata->heroManual;
|
|
|
-
|
|
|
- $heroCfg = GameConfig::hero_getItem($heromodelId); //1.检查是否存在这个英雄的模板
|
|
|
+// if (!CommUtil::isPropertyExists($gamedata, "heroManual")) {
|
|
|
+// $gamedata->heroManual = new HeroManualModel();
|
|
|
+// $gamedata->heroManual->initInstance();
|
|
|
+// }
|
|
|
+// $manual = $gamedata->heroManual;
|
|
|
+ $heroCfg = GameConfig::hero_getItem($heromodelId); // 1.检查是否存在这个英雄的模板
|
|
|
if (!$heroCfg) {
|
|
|
return Resp::err(ErrCode::hero_const_no_err);
|
|
|
}
|
|
|
- $collectHeros = $gamedata->heros->collectHeros; //2.存在的话,先生成一个UID
|
|
|
+ $collectHeros = $gamedata->heros->collectHeros; // 2.存在的话,先生成一个UID
|
|
|
$uid = self::CreateNewGameHeroUID($collectHeros, $gamedata->heros->recordMaxUID);
|
|
|
$gamedata->heros->recordMaxUID = $uid;
|
|
|
- $hero = self::getGameHeroModelInstance($heroCfg, $heromodelId, $uid);
|
|
|
+ $hero = self::getGameHeroModelInstance($heroCfg, $heromodelId, $uid); // 3.创建英雄实例
|
|
|
$collectHeros->$uid = $hero;
|
|
|
$gamedata->heros->collectHeros = $collectHeros;
|
|
|
- self:: tryNewManual($req->mem, $manual, $hero);
|
|
|
+// self:: tryNewManual($req->mem, $manual, $hero); // 更新图鉴
|
|
|
return $hero;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据一个英雄的模板id,来获得一个英雄的实例数据
|
|
|
- * @param HeroModel $heroCfg 模板数据
|
|
|
+ * @param \sm_hero $heroCfg 模板数据
|
|
|
* @param string $heroModelId 模板数据ID
|
|
|
* @param string $uid 唯一ID
|
|
|
* @return UserHeroModel
|
|
|
*/
|
|
|
static function getGameHeroModelInstance($heroCfg, $heroModelId, $uid) {
|
|
|
$hero = new UserHeroModel();
|
|
|
-////取常量数据理的默认的等阶和星级
|
|
|
- $sour = $heroCfg; //GameConfig::hero_getItem($heroModelId);
|
|
|
- $hero->strengthLevel = $sour->dengjie;
|
|
|
- $hero->curStar = $sour->xingji;
|
|
|
-
|
|
|
-//查找mem中此英雄的模板数据
|
|
|
- $hero->typeId = $heroModelId;
|
|
|
+// $hero->strengthLevel = $heroCfg->dengjie;
|
|
|
+// $hero->curStar = $heroCfg->xingji;
|
|
|
+ $hero->typeId = $heroCfg->heroId;
|
|
|
$hero->uid = $uid;
|
|
|
$hero->xp = 0;
|
|
|
$lvs = GameConfig::hero_levelexp_getItem($hero->level + 1);
|
|
|
$hero->maxXp = $lvs->requiredExp;
|
|
|
-
|
|
|
return $hero;
|
|
|
}
|
|
|
|