12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001 |
- <?php
- namespace loyalsoft;
- /**
- * 英雄处理逻辑
- * @author gwang
- */
- class HeroProc {
- /**
- * 英雄处理逻辑分发
- * 所有的Proc中必须有这样一个方法
- */
- static function procMain() {
- switch (req()->cmd) {
- case CmdCode::cmd_hero_levelup: # [6301] 英雄升级
- return HeroProc::HeroLevelUpCostExpItem();
- case CmdCode::cmd_hero_tupo: # [6328] 英雄突破
- return HeroProc::tupo();
- // <editor-fold defaultstate="collapsed" desc="过时 接口">
- case CmdCode::cmd_hero_stageup: # [6304] 英雄进阶 SABCD
- return HeroProc::HeroStageUp();
- // case CmdCode::cmd_hero_upstar: # [6305] 英雄升星
- // return HeroProc::HeroUpStarByPieces();
- // case CmdCode::cmd_hero_changelockstate: # [6306] 英雄-修改锁定状态
- // return HeroProc::HeroChangelockstate();
- // case CmdCode::cmd_hero_buyCollectHeroLimtCount: # [6312] 扩展英雄数量上限
- // return HeroProc::BuyHeroMaxCountLimt();
- // <editor-fold defaultstate="collapsed" desc="---------------英雄评论----------------">
- // case CmdCode::cmd_hero_GetDiscuss: # [6316]拉取英雄评论
- // return HeroDiscussProc::GetDiscusses();
- // case CmdCode::cmd_hero_PostDiscuss: # [6317]对英雄发表评论
- // return HeroDiscussProc::Post();
- // case CmdCode::cmd_hero_PraiseDiscuss: # [6318]给某条评论点赞
- // return HeroDiscussProc::PriaseMsg();
- // case CmdCode::cmd_hero_DeleteDiscuss: # [6319]删除评论
- // return HeroDiscussProc::DeletePost();
- // case CmdCode::cmd_hero_scoreit: # [6320]给某个英雄评分
- // return HeroDiscussProc::Score();
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc=" 英雄的解锁与购买 ">
- // case CmdCode::cmd_hero_buyHero: # [6321]购买英雄
- // return HeroProc::BuyHeroByCostPieces();
- // case CmdCode::cmd_hero_upGodBlood: # [6322] 神血升级
- // return HeroProc::UpGodBloodHeroByPieces();
- // case CmdCode::cmd_hero_unlockByPieces: # [6323] 解锁碎片
- // return HeroProc::UnLockHeroByPieces();
- // </editor-fold>
- // </editor-fold>
- # --------- 英雄技能 -----------
- case CmdCode::cmd_hero_upgradeSkillLevel: # [6314] 英雄的技能升级
- return HeroProc::UpgradeSkillLevel();
- case CmdCode::cmd_hero_unlockSkill: # [6324] 英雄技能 - 解锁技能
- return HeroProc::UnlockSkill();
- case CmdCode::cmd_hero_skillLevel_onekeyupgrade: # [6325] 英雄技能 - 一键升级
- return HeroProc::OnekeyUpgradeSkillLevel();
- case CmdCode::cmd_hero_saveHeroTeamConfig: # [6315] 保存玩家战队数据
- return HeroProc::SaveHeroTeamConfig();
- // <editor-fold defaultstate="collapsed" desc=" 英雄升级 cyzhao ">
- case CmdCode::cmd_hero_StrengthenStar: # [6326] 升星cmd_hero_YanlinUpLevel
- return HeroProc::StrengthenStar();
- case CmdCode::cmd_hero_YanlinUpLevel: # [6327] 升级
- return HeroProc::YanlinUpLevel();
- case CmdCode::cmd_hero_YanLingReplace: # [6329] 言灵替换
- return HeroProc::YanLingReplace();
- // </editor-fold>
- default: # err: 未知的命令码
- return Resp::err(ErrCode::cmd_err);
- }
- }
- // <editor-fold defaultstate="collapsed" desc="技能升级与解锁">
- /**
- * [6324] 英雄技能解锁
- * @version 2020.1.13 至今未进行对接, 再次整理版
- * 2019.12.10 加班弄完第一版
- */
- static function UnlockSkill() {
- list($huid, $mainSkillId, $subSkillId) = req()->paras; # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能ID
- $user = req()->userInfo->game; # user引用
- $cHeros = $user->heros->collectHeros;
- my_default_Obj($cHeros);
- my_Assert(CommUtil::isPropertyExists($cHeros, $huid), ErrCode::hero_no); # 1.检查是否存在要解锁的英雄
- # # 2.判断英雄的该技能能否升级....
- $targetHero = new Ins_UserHero($cHeros->$huid); # 直接类型识别
- $targteHeroSkills = $targetHero->subSkills; # 取出这个英雄的技能数据
- my_default_Arr($targteHeroSkills->$mainSkillId); # 保护子技能数组数据结构
- my_Assert(!CommUtil::isInArray($targteHeroSkills->$mainSkillId, $subSkillId), "子技能已解锁"); # 子技能已经解锁
- // if (!$targetHero->IsSkillUnlockAble($mainSkillId, $subSkillId)) { # 3.判断技能是否处于待解锁状态
- // return Resp::err(ErrCode::hero_upgradeSkill_maxLevel);
- // }
- $sm = GameConfig::subSkill_getItem($subSkillId); # 4.取出该技能升级消耗的常量数据
- my_Assert(null != $sm, ErrCode::err_const_no); # 找不到子技能配置数据
- // my_Assert(Data_UserGame::Consume_Gold($user->baseInfo, $sm->unlockCost), # # 5. 扣除金币消耗
- // ErrCode::notenough_gold_msg);
- my_Assert($user->base()->Consume_Gold($sm->unlockCost), # # 5. 扣除金币消耗
- ErrCode::notenough_gold_msg);
- array_push($targteHeroSkills->$mainSkillId, $subSkillId); # 添加技能
- $targetHero->subSkills = $targteHeroSkills;
- $cHeros->$huid = $targetHero; # 回存Hero对象
- UserProc::updateUserInfo(); # 回写数据
- TaskProc::OnHeroUnlocSkill($targetHero->typeId, $subSkillId);
- return Resp::ok($targetHero);
- }
- /**
- * [6325] 英雄技能一键升级
- */
- static function OnekeyUpgradeSkillLevel() {
- list($huid, $mainSkillId, $subSkillId, $targetSubSkillId, $costGold) = req()->paras; # 提取参数: 英雄的UID, 主技能ID, 要升级的子技能ID, 升级到的子技能ID, 升级要消耗的金币
- $user = req()->userInfo->game; # user引用#
- $collectHeros = $user->heros->collectHeros;
- my_default_Obj($collectHeros); # 防御变量为空
- my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no); # 1.检查是否存在要升级的英雄
- # # 2.判断英雄的该技能能否升级....
- $targetHero = new Ins_UserHero($collectHeros->$huid); # 直接类型识别
- $targteHeroSkills = $targetHero->subSkills; # 取出这个英雄的技能数据
- my_default_Arr($targteHeroSkills->$mainSkillId); # 保护数据结构
- my_Assert(CommUtil::isInArray($targteHeroSkills->$mainSkillId, $subSkillId), "子技能id错误"); # 子技能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, '找不到子技能配置数据');
- // }
- my_Assert($user->base()->Consume_Gold($costGold), ErrCode::notenough_gold_msg); # 5. 扣除金币消耗
- unset($targteHeroSkills->$mainSkillId, $subSkillId); # 替换技能
- array_push($targteHeroSkills->$mainSkillId, $targetSubSkillId);
- $targetHero->subSkills = $targteHeroSkills;
- $collectHeros->$huid = $targetHero; # 更新Hero数据
- UserProc::updateUserInfo(); # 回写数据
- return Resp::ok($targetHero);
- }
- /**
- * [6314]英雄技能升级
- */
- static function UpgradeSkillLevel() {
- list($huid, $mainSkillId, $subSkillId) = req()->paras; # 提取参数: 英雄的UID, 主技能Id, 要升级的子技能Id
- $user = req()->userInfo->game; # user引用
- $collectHeros = $user->heros->collectHeros;
- my_default_Obj($collectHeros); # 防御变量为空
- my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no); # 1.检查是否存在要升级的英雄
- $targetHero = new Ins_UserHero($collectHeros->$huid);
- $targteHeroSkills = $targetHero->subSkills; # 取出这个英雄的技能数据
- my_Assert(CommUtil::isPropertyExists($targteHeroSkills, $mainSkillId), "玩家数据结构有问题."); # 主技能Id.
- my_Assert(CommUtil::isInArray($targteHeroSkills->$mainSkillId, $subSkillId), "子技能id错误"); # 子技能id
- my_Assert($targetHero->IsSkillUpdateAble($mainSkillId, $subSkillId), ErrCode::hero_upgradeSkill_maxLevel); # 3.判断技能等级能否在继续升级了
- $sm = GameConfig::subSkill_getItem($subSkillId); # 4.取出该技能升级消耗的常量数据
- my_Assert(null != $sm, ErrCode::err_const_no); # 找不到子技能配置数据
- my_Assert($user->base()->Consume_Gold($sm->upgradeCost), ErrCode::notenough_gold_msg); # 5. 扣除金币消耗
- unset($targteHeroSkills->$mainSkillId, $subSkillId); # 替换技能
- array_push($targteHeroSkills->$mainSkillId, $sm->nextLevel_Id);
- $targetHero->subSkills = $targteHeroSkills;
- $collectHeros->$huid = $targetHero; # 更新hero数据
- UserProc::updateUserInfo(); # 回写数据
- return Resp::ok($targetHero);
- }
- // </editor-fold>
- //
- // <editor-fold defaultstate="collapsed" desc="英雄 强化">
- /**
- * 6304 英雄 升阶(消耗碎片)
- */
- static function HeroStageUp() {
- list($huid, $nextGrade) = req()->paras; # 提取参数: 英雄的UID,下一阶
- $user = req()->userInfo->game; # user引用
- $collectHeros = $user->heros->collectHeros; # 角色容器
- my_default_Obj($collectHeros); # 保证不为null
- my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no); # 1.检查是否存在要升级的英雄
- $upHero = new Ins_UserHero($collectHeros->$huid); # 直接类型识别
- my_Assert($upHero->grade < "S", ErrCode::hero_strength_maxstrengthlevel); # 已经达到S级
- $heroUpgradeCostCfg = GameConfig::heroextra_level_getItem($upHero->typeId, $nextGrade);
- my_Assert($heroUpgradeCostCfg, ErrCode::hero_strength_cost_const_no); # 1.检查是否存在这个升阶数据的模板
- // my_Assert(Data_UserGame::Consume_HeroSegment($user, # # 扣除碎片
- // $heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum), ErrCode::hero_segment_not_enough);
- my_Assert($user->store()->Consume_HeroSegment($heroUpgradeCostCfg->segID, $heroUpgradeCostCfg->segNum), # 扣除碎片
- ErrCode::hero_segment_not_enough); # 碎片数量不足
- # 扣除碎片成功
- $upHero->grade = $nextGrade; # 5.强化英雄进行成功升阶
- $collectHeros->$huid = $upHero; # 更新Hero数据
- UserProc::updateUserInfo(); # 6.数据回存
- $resp = Resp::ok($upHero);
- SystemProc::insertHero_StageUp(req()->zoneid, req()->uid, $user->base()->name, # # 插入系统广播
- GameConfig::hero_getItem($upHero->typeId)->name, $upHero->grade);
- self::CalcUserFightPower(req()->zoneid, req()->uid, req()->userInfo->game); # 跟新战力统计
- TaskProc::OnHeroGradeUp($upHero->typeId, $upHero->grade);
- //StoreProc::addSegmentIntoStore($store, $segmentId, $num);
- // var_dump($user->task->taskListDaily);
- return $resp;
- }
- /**
- * [6301] 英雄升级 - 消耗经验道具,获得经验(按照经验提升等级)
- */
- static function HeroLevelUpCostExpItem() {
- list($huid, $costItemId, $costNumber) = req()->paras; # 提取参数: 玩家英雄实例编号, 消耗的道具ID, 消耗的道具数量
- $user = req()->userInfo->game; # user引用
- $collectHeros = $user->heros->collectHeros; # 1. 检查是否存在要升级的英雄
- my_default_Obj($collectHeros);
- my_Assert(is_int($costNumber) && $costNumber >= 1, ErrCode::paras_err); # 参数合法性判断
- my_Assert(CommUtil::isPropertyExists($collectHeros, $huid), ErrCode::hero_no); # 玩家拥有此英雄
- $targetHero = new Ins_UserHero($collectHeros->$huid); #
- //my_Assert($targetHero->HeroCanLevelUp(), "请提升指挥官等级."); # 2. 检查玩家等级是否可以继续升级, Ps. 全局限制 + 指挥官等级限制
- $myPacketItems = $user->store->items; # 检查道具的数量,在背包中是否充足
- my_Assert(CommUtil::isPropertyExists($myPacketItems, $costItemId), ErrCode::store_itemnotenough); #
- my_Assert($myPacketItems->$costItemId >= $costNumber, ErrCode::store_itemnotenough);
- $initLevel = $targetHero->level; # 初始等级
- $totalEXP = 0; # 4.计算消耗的道具一共给多少经验值以及 一共要消耗多少金币
- $costItemConst = GameConfig::item_stones_getItem($costItemId);
- my_Assert(null != $costItemConst, ErrCode::err_const_no);
- $totalGold = $costItemConst->costGold * $costNumber; #验证金币是否充足
- my_Assert($user->baseInfo->gold >= $totalGold, ErrCode::notenough_gold_msg);
- $user->baseInfo->gold -= $totalGold;
- $totalEXP += $costItemConst->baseExp;
- $heroConst = GameConfig::hero_getItem($targetHero->typeId); # 英雄模板数据
- my_Assert(null != $heroConst, ErrCode::err_const_no, "英雄 模板数据");
- // if ($costItemConst->element != 0 # # 相同元素加成
- // && $costItemConst->element == $heroConst->element) {
- // $totalEXP += $costItemConst->extraExp;
- // }
- $totalEXP *= $costNumber; # 消耗N个道具
- $targetHero = self:: HeroAddEXP($huid, $totalEXP); # 获得经验
- $myPacketItems->$costItemId -= $costNumber; # 消耗道具
- if ($myPacketItems->$costItemId < 0) {
- $myPacketItems->$costItemId = 0;
- }
- req()->userInfo->game->store->items = $myPacketItems; # 更新背包数据
- my_Assert($targetHero->xp >= 0, "英雄经验出错");
- UserProc::updateUserInfo(); # 回写玩家数据
- TaskProc::OnHeroImprove(); # 事件检测
- self::CalcUserFightPower(req()->zoneid, req()->uid, req()->userInfo->game); # 跟新战力统计
- $ret = array(
- 'hero' => $targetHero,
- 'store' => $user->store,
- 'gold' => $user->baseInfo->gold,
- );
- return Resp::ok($ret);
- }
- /**
- * 唤灵师突破
- */
- static function tupo() {
- list($uid) = req()->paras;
- $user = req()->userInfo->game;
- $collectHeros = $user->heros->collectHeros; # 1. 检查是否存在要升级的英雄
- my_default_Obj($collectHeros);
- my_Assert(StlUtil::dictHasProperty($collectHeros, $uid), ErrCode::hero_no); # 参数合法性判断
- $typeId = $collectHeros->$uid->typeId;
- $curStar = $collectHeros->$uid->curStar;
- my_Assert($curStar < 5, ErrCode::hero_yanling_canotTupo);
- $mo = GameConfig::heroextra_level_tupo_getItem($typeId, $curStar + 1);
- my_Assert($mo != null, ErrCode::err_const_no);
- my_Assert($collectHeros->$uid->level >= $mo->starlimitLv, ErrCode::hero_yanling_canotTupo);
- my_Assert($user->baseInfo->level >= $mo->userlvLimit, ErrCode::hero_yanling_canotTupo);
- my_Assert($user->baseInfo->gold >= $mo->gold, ErrCode::notenough_gold_msg);
- $segID = $mo->segID;
- my_Assert(StlUtil::dictHasProperty($user->store->items, $segID), ErrCode::store_itemnotenough);
- my_Assert($user->store->items->$segID >= $mo->segNum, ErrCode::store_itemnotenough);
- $costItemsList = explode(';', $mo->costItems);
- foreach ($costItemsList as $value) {
- $list = explode(',', $value);
- StoreProc::removeItemFromStore($user->store, $list[0], $list[1]);
- }
- $user->store->items->$segID -= $mo->segNum;
- $user->baseInfo->gold -= $mo->gold;
- $collectHeros->$uid->curStar += 1;
- NormalEventProc::OnHeroTuPo($uid, $collectHeros->$uid->curStar); # 广播英雄升级事件
- $user->heros->collectHeros = $collectHeros;
- req()->userInfo->game = $user;
- $targetHero = new Ins_UserHero($collectHeros->$uid);
- UserProc::updateUserInfo(); # 回写玩家数据
- $ret = array(
- 'hero' => $targetHero,
- 'store' => $user->store,
- 'gold' => req()->userInfo->game->baseInfo->gold,
- );
- return Resp::ok($ret);
- }
-
- /**
- * 武器替换
- * @return type
- */
- static function YanLingReplace() {
- list($uid ,$replaceId) = req()->paras; # 参数 言灵uid(指定进阶的言灵实例id)
- $user = req()->userInfo->game;
- $yanling = $user->store->yanling;
- my_Assert(property_exists($yanling, $uid), "找不到这个言灵");
- my_Assert(property_exists($yanling, $replaceId), "找不到这个言灵");
-
-
- $herouid = $yanling->$uid->herouid;
- $herouid_replace = $yanling->$replaceId->herouid;
- $yanling->$replaceId->herouid = $herouid;
- $yanling->$uid->herouid = $herouid_replace;
- $user->store->equipment = $yanling;
- req()->userInfo->game = $user;
-
- UserProc::updateUserInfo(); # 回写玩家数据
- return Resp::ok(array(
- "store" => $user->store, # # 目前来看只涉及到items变化
- ));
- }
- // </editor-fold>
- //
- // <editor-fold defaultstate="collapsed" desc="队伍配置">
- /**
- * [6315]保存队伍的战斗配置信息
- */
- static function SaveHeroTeamConfig() {
- $teamsetting = req()->paras[0]; # 配置信息json文件
- req()->userInfo->game->heroTeamConfig = $teamsetting; # 更新配置
- UserProc::updateUserInfo(); # 回写数据
- # # 添加到战斗力隐藏榜单中, for pvp back matchers, -wg 2017.07.13
- self::CalcTeamFightPower(req()->zoneid, req()->uid, req()->userInfo->game);
- return Resp::ok(array('result' => "succeed"));
- }
- // </editor-fold>
- //
- // <editor-fold defaultstate="collapsed" desc="已过时代码">
- /**
- * 6323 解锁英雄
- */
- static function UnLockHeroByPieces() {
- Err(ErrCode::err_method_obsoleted, "策划未设定解锁功能-2021.5.6");
- $user = req()->userInfo->game; # user引用
- $heroModelId = req()->paras[0];
- $piecesId = req()->paras[1]; # 英雄碎片的ID
- $piecesNum = req()->paras[2];
- my_default_Obj($user->heros->recordUnLockHeroDic); # 防御解锁列表未初始化,空对象
- $recordUnLockHeroDic = $user->heros->recordUnLockHeroDic; # 已解锁记录
- if (!CommUtil::isPropertyExists($recordUnLockHeroDic, $heroModelId)) { # 检查是不是已经解锁过了
- $recordUnLockHeroDic->$heroModelId = 0;
- }
- my_Assert(0 == $recordUnLockHeroDic->$heroModelId, ErrCode::hero_lockState); # 防御英雄已经解锁
- $heroCfg = GameConfig::hero_getItem($heroModelId);
- my_Assert(isset($heroCfg), ErrCode::hero_const_no_err); # 检查要解锁的英雄的常量配置是否存在
- $piecesCfg = GameConfig::segment_getItem($piecesId);
- my_Assert(isset($piecesCfg), ErrCode::err_const_no); # 检查需要消耗的碎片的常量配置是否存在
- $myPacketItems = $user->store->segement;
- $requirePiecesNum = $heroCfg->unlockConditionId;
- $enoughPieces = false; # 检查道具数量是否充足
- my_Assert($heroModelId == $piecesCfg->prototypeData && $requirePiecesNum == $piecesNum, ErrCode ::paras_err);
- if (!CommUtil::isPropertyExists($myPacketItems, $piecesId)) { # 检查碎片
- $enoughPieces = false;
- } else {
- if ($myPacketItems->$piecesId < $requirePiecesNum) { # 5.检查道具的数量是否充足
- $enoughPieces = false;
- } else {
- $enoughPieces = true;
- }
- }
- my_Assert($enoughPieces, ErrCode::hero_godblood_notengoughitem);
- $myPacketItems->$piecesId -= $requirePiecesNum;
- if ($myPacketItems->$piecesId < 0) { # 6.进行 # # 消耗道具
- $myPacketItems->$piecesId = 0;
- }
- $recordUnLockHeroDic->$heroModelId = 1;
- req()->userInfo->game->heros->recordUnLockHeroDic = $recordUnLockHeroDic;
- req()->userInfo->game->store->segement = $myPacketItems;
- UserProc::updateUserInfo(); # 回写数据
- return Resp::ok(array('result' => "OK")); # 返回OK
- }
- /**
- * [6322] 英雄神血
- */
- static function UpGodBloodHeroByPieces() {
- Err(ErrCode::err_method_obsoleted, "策划未设定神血功能-2021.5.6");
- }
- /**
- * 英雄消耗碎片道具来升星
- * @param req $req
- */
- static function HeroUpStarByPieces() {
- Err(ErrCode::err_method_obsoleted, "策划未设定碎片升级功能-2021.5.6");
- }
- /**
- * 英雄升星
- * @param Req $req
- */
- static function HeroUpStar() {
- Err(ErrCode::err_method_obsoleted, "策划未设定升星功能-2021.5.6");
- }
- // </editor-fold>
- /**
- * 6321 购买英雄 消耗碎片
- */
- static function BuyHeroByCostPieces() {
- Err(ErrCode::err_method_obsoleted, "策划未设定碎片功能-2021.5.6");
- list($heroModelId, $costType, $costMoneyNum, $piecesId, $piecesNum) = req()->paras; # 提取参数
- $user = req()->userInfo->game; # user引用
- $collectHeros = $user->heros->collectHeros;
- my_default_Obj($collectHeros);
- foreach ($collectHeros as $key => $value) { # 检查玩家是否已经拥有此类英雄
- my_Assert($value->typeId != $heroModelId, ErrCode::hero_existSameHero_err);
- }
- $heroCfg = GameConfig::hero_getItem($heroModelId); # 英雄模板数据
- my_Assert(null != $heroCfg, ErrCode::hero_const_no_err);
- my_Assert($heroCfg->isCanBuy != 0, ErrCode::paras_err); # 是否可以直接购买
- $piecesCfg = GameConfig::segment_getItem($piecesId); # 检查需要消耗的碎片的常量配置是否存在
- my_Assert(null != $piecesCfg, ErrCode::err_store_itemnoconst);
- $myPacketItems = $user->store->items;
- $requirePiecesNum = $piecesCfg->mergePrototypeNeedNum;
- my_Assert($heroModelId == $piecesCfg->prototypeData && $requirePiecesNum == $piecesNum, ErrCode::paras_err);
- my_Assert(CommUtil::isPropertyExists($myPacketItems, $piecesId), ErrCode::hero_godblood_notengoughitem);
- my_Assert($myPacketItems->$piecesId > $requirePiecesNum, ErrCode::hero_godblood_notengoughitem); # 检查碎片道具数量是否充足
- switch ($costType) {
- case "cash":
- $realPrice = $heroCfg->cashPrice;
- my_Assert($realPrice == $costMoneyNum, ErrCode::paras_err);
- my_Assert($costMoneyNum >= 0, ErrCode::paras_err);
- my_Assert($user->base()->Consume_Cash($costMoneyNum), ErrCode::err_msg_cashnotenough);
- break;
- case "gold":
- $realPrice = $heroCfg->goldPrice;
- my_Assert($realPrice == $costMoneyNum, ErrCode::paras_err);
- my_Assert($costMoneyNum >= 0, ErrCode::paras_err);
- my_Assert($user->base()->Consume_Gold($costMoneyNum), ErrCode::err_msg_goldnotenough);
- break;
- default :
- Err(ErrCode::paras_err, "参数错误: [costType] " . $costType);
- }
- # 4.消耗来获得英雄
- $myPacketItems->$piecesId -= $requirePiecesNum; # 消耗道具
- req()->userInfo->game->store->items = $myPacketItems; # 回存背包
- UserProc::updateUserInfo(); # 回写数据
- $resp = HeroProc::GetHero();
- SystemProc::GetHero(req()->zoneid, $user->base(), $heroModelId); # 插入系统广播消息
- return $resp;
- }
- /**
- * 购买玩家可以收集的英雄的数量上限
- * @return type
- */
- static function BuyHeroMaxCountLimt() {
- list($buyNum, $costCash) = req()->paras; # 提取参数: 数量, 花费钻石
- $g = glc();
- $user = req()->userInfo->game; # user引用
- if (!CommUtil::isPropertyExists($user->heros, "maxCollectCount")) {
- $user->heros->maxCollectCount = $g->Game_CollectHero_BasicMaxCount;
- }
- $index = ceil(($user->heros->maxCollectCount - $g->Game_CollectHero_BasicMaxCount) #
- / $g->Game_CollectHero_OneBuyLimtNum);
- $arr = explode(",", $g->Game_CollectHero_BasicMaxPrice);
- my_Assert($index < count($arr), "已达上限");
- $realCost = $arr[$index];
- my_Assert($realCost == $costCash, ErrCode::paras_err); # 参数错误
- my_Assert($costCash >= 0, ErrCode::paras_err);
- my_Assert($user->base()->Consume_Cash($costCash), ErrCode::err_msg_goldnotenough); # 扣除宝石
- $user->heros->maxCollectCount += $buyNum; # 修改上限
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'maxCollectCount' => $user->heros->maxCollectCount
- ));
- }
- /**
- * 获得英雄(测试已经OK)
- */
- static function GetHero() {
- $heroModelId = req()->paras[0]; # 英雄的模板ID
- $heroCfg = GameConfig::hero_getItem($heroModelId); # 1.检查是否存在这个英雄的模板
- my_Assert(null != $heroCfg, ErrCode::hero_const_no_err);
- $hero = self::AddHeroTFromStore($heroModelId); # 创建英雄
- UserProc::updateUserInfo();
- $result = array('result' => "succeed", 'heros' => $hero); # 4. 设置返回值
- return Resp::ok($result);
- }
- // <editor-fold defaultstate="collapsed" desc="辅助方法">
- /**
- * 获得一个英雄, 并且给他指定星级
- * @param int $heromodelId 原型数据id
- * @param int $star 星级
- * @return Ins_UserHero
- */
- static function AddHeroWithStar($heromodelId, $star) {
- my_Assert(null != ctx(), ErrCode::err_innerfault);
- $collectHeros = ctx()->heros()->collectHeros;
- $uid = self::CreateNewGameHeroUID($collectHeros, ctx()->heros()->recordMaxUID); # 先生成一个hero的UID
- ctx()->heros()->recordMaxUID = $uid;
- $hero = self::getGameHeroModelInstance($heromodelId, $uid);
- if ($star > 0) {
- $hero->curStar = $star; # 设定star
- }
- $collectHeros->$uid = $hero; # 回写
- ctx()->heros()->collectHeros = $collectHeros; # 回写
- return $hero; # 返回
- }
- /**
- * 获得一个英雄(实例)
- * @param req $req
- * @param int $heromodelId
- * @return type
- */
- static function AddHeroTFromStore($heromodelId) {
- $user = ctx(); # 玩家数据
- $collectHeros = ctx()->heros()->collectHeros; #
- my_default_Obj($collectHeros);
- $uid = self::CreateNewGameHeroUID($collectHeros, ctx()->heros()->recordMaxUID); # 先生成一个UID
- $user->heros->recordMaxUID = $uid; # 更新最大编号记录
- $hero = self::getGameHeroModelInstance($heromodelId, $uid); # 3.创建英雄实例
- $collectHeros->$uid = $hero;
- ctx()->heros()->collectHeros = $collectHeros;
- return $hero;
- }
- /**
- * 根据一个英雄的模板id,来获得一个英雄的实例数据
- * @param string $heroModelId 模板数据ID
- * @param string $uid 唯一ID
- * @return Ins_UserHero
- */
- static function getGameHeroModelInstance($heroModelId, $uid) {
- $heroCfg = GameConfig::hero_getItem($heroModelId);
- my_Assert(null != $heroCfg, ErrCode::err_const_no); # 检查是否存在这个英雄的模板
- $hero = new Ins_UserHero();
- // $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;
- // 取可用武器中第一个初始化 -- 策划要求初始英雄要带有武器 -- 王刚 2020年1月
- $wp = null;
- $arr = (array) GameConfig::item_weapon();
- ksort($arr); // todo: 排序不正常
- foreach ($arr as $id => $mo) {
- // isEditor() and $mo = new \sm_item_weapon();
- if ($mo->hero_id == $hero->typeId) {
- $wp = $mo;
- break;
- }
- }
- if (null != $wp) {
- $wuid = StoreProc::PutEquipInStore($wp->typeId);
- req()->userInfo->game->store->equipment->$wuid->herouid = $uid;
- $hero->equip->weapon = array("itemuid" => $wuid);
- }
- return $hero;
- }
- /**
- * 查找下一个玩家获得英雄的UID
- * @param type $req
- * @return int
- */
- static function CreateNewGameHeroUID($collectHeros, $oldMaxUID) {
- $maxID = 10000;
- my_default_Obj($collectHeros);
- foreach ($collectHeros as $itemId => $hero) {
- if ($itemId > $maxID) {
- $maxID = $itemId;
- }
- }
- $max = max($maxID, $oldMaxUID);
- return $max + 1;
- }
- /**
- * 英雄卡牌增加经验值
- * @param string $heroUID
- * @param int $totalEXP
- */
- static function HeroAddEXP($heroUID, $totalEXP) {
- $req = req();
- $collectHeros = $req->userInfo->game->heros->collectHeros;
- my_default_Obj($collectHeros);
- my_Assert(CommUtil::isPropertyExists($collectHeros, $heroUID), ErrCode::hero_no); # 要升级的英雄不存在
- $targetHero = new Ins_UserHero($collectHeros->$heroUID); # 英雄对象
- // $playerLimit = GameConfig::playerlevel_getItem(ctx()->base()->level)->hero_max_level;
- // $maxLevel = min(glc()->Hero_Upgrade_BasicMaxLevel, $playerLimit); # 最大等级= max(英雄最高等级上限,玩家等级限制的上限)
- // if ($targetHero->level >= $maxLevel) {
- // return; # 已达顶级
- // }
- //$lvs = GameConfig::hero_levelexp_getItem($targetHero->level + 1);
- $targetHero->xp += $totalEXP;
- my_Assert($targetHero->xp >= 0, "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
- $initLevel = $targetHero->level;
- $curLv = 0;
- $heroLvDic = GameConfig::hero_levelexp();
- $f = (array) $heroLvDic;
- ksort($f);
- foreach ($f as $lv => $mo) {
- if ($targetHero->xp < $mo->requiredExp) {
- $curLv = $lv - 1;
- break;
- }
- if ($lv >= glc()->Hero_Upgrade_BasicMaxLevel) {
- $curLv = glc()->Hero_Upgrade_BasicMaxLevel;
- break;
- }
- }
- $targetHero->level = $curLv;
- $curStar = $targetHero->curStar; #当前星级
- if ($curStar < 5) {
- $starlimitLv = GameConfig::heroextra_level_tupo_getItem($targetHero->typeId, $curStar + 1)->starlimitLv;
- if ($starlimitLv < $curLv) {
- $targetHero->level = $starlimitLv;
- $targetHero->xp = GameConfig::hero_levelexp_getItem($starlimitLv)->needExp;
- }
- }
- // while ($targetHero->xp >= $lvs->needExp) {
- // if ($targetHero->level < $maxLevel) { # 如果未到达最大等级
- // $targetHero->level += 1;
- // if ($targetHero->level >= $maxLevel) {
- // $targetHero->xp = $lvs->needExp;
- // } else {
- // $targetHero->xp -= $lvs->needExp;
- // }
- // $lvs = GameConfig::hero_levelexp_getItem($targetHero->level + 1);
- // } else { # 如果已到达最大等级则仅补齐缺失的经验即可
- // $targetHero->xp = $targetHero->maxXp; # 经验不能超过最大值
- // break;
- // }
- // } // end while
- my_Assert($targetHero->xp >= 0, "[" . $req->uid . "] : HeroLevelUpgrade Exp is negative!");
- $collectHeros->$heroUID = $targetHero; # 更新英雄的数据
- if ($targetHero->level != $initLevel) {
- NormalEventProc::OnHeroLvlUp($targetHero->uid, $initLevel); # 广播英雄升级事件
- }
- TaskProc::OnHeroLevelUp($targetHero->typeId, $targetHero->level);
- return $targetHero; # 将英雄对象返回
- }
- // </editor-fold>
- /**
- * [6306] 英雄-更改英雄的锁定状态
- * (测试已经OK)
- */
- static function HeroChangelockstate() {
- $gamedata = req()->userInfo->game;
- $heroUID = req()->paras[0]; # 玩家英雄实例编号
- $lockstate = req()->paras[1]; # 玩家英雄锁定状态
- $collectHeros = $gamedata->heros->collectHeros;
- my_default_Obj($collectHeros); # 默认值
- 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. 保存玩家数据
- return Resp::ok(ObjectInit()); # 4. 设置返回值
- }
- /** 6326
- * 言灵升星--改成突破【2021-6-8】 2021.4(cyzhao)
- * @return resp
- */
- static function StrengthenStar() {
- list($yanlingUid, $uidList) = req()->paras;
- $store = req()->userInfo->game->store;
- my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
- my_Assert(!in_array($yanlingUid, $uidList), ErrCode::hero_yanling_repeat);
- my_Assert($store->yanling->$yanlingUid->starLv < 5, ErrCode::hero_yanling_repeat);
- $tag = true;
- foreach ($uidList as $costUid) {
- if (StlUtil::dictHasProperty($store->yanling, $costUid)) { # 校验是否是同类型
- $confDic = GameConfig::item_yanling_getItem($store->yanling->$costUid->typeId);
- my_Assert(null != $confDic, ErrCode::hero_const_no_err);
- if ($confDic->type != GameConfig::item_yanling_getItem($store->yanling->$yanlingUid->typeId)->type) {
- $tag = false;
- break;
- }
- if ($store->yanling->$costUid->herouid != 0) {
- $tag = false;
- break;
- }
- } else {
- $tag = false;
- break;
- }
- }
- my_Assert($tag, ErrCode::hero_yanling_errorYanling);
- $exp = 0;
- foreach ($uidList as $costuid) {
- $confDic = GameConfig::item_yanling_getItem($store->yanling->$costuid->typeId);
- my_Assert(null != $confDic, ErrCode::hero_const_no_err);
- $exp += $confDic->addStarExp;
- StlUtil::dictRemove($store->yanling, $costuid);
- }
- $store->yanling->$yanlingUid->curStarExp += $exp;
- $dic = GameConfig::item_yanling_getItem($store->yanling->$yanlingUid->typeId);
- if ($store->yanling->$yanlingUid->curStarExp >= $dic->maxStarExp) {
- $store->yanling->$yanlingUid->curStarExp = 0;
- $store->yanling->$yanlingUid->starLv += 1;
- $store->yanling->$yanlingUid->typeId = $dic->nextId;
- }
- req()->userInfo->game->store = $store;
- UserProc::updateUserInfo();
- return Resp::ok(array('store' => req()->userInfo->game->store,));
- }
-
- static function StrengthenStar_new() {
- list($uid) = req()->paras; # 参数 言灵uid(指定进阶的言灵实例id)
- $user = req()->userInfo->game;
- $yanling = $user->store->yanling;
- my_Assert(CommUtil::isPropertyExists($yanling, $uid), ErrCode::store_weapon_err); # 玩家拥有此英雄
-
- $typeId = $yanling->$uid->typeId;
- $curStar = $yanling->$uid->starLv;
- my_Assert($curStar < 5, ErrCode::hero_yanling_canotTupo);
-
- $mo = GameConfig::yanlingextra_level_getItem($typeId, $curStar+1);
- my_Assert($mo != null, ErrCode::err_const_no);
-
- my_Assert($yanling->$uid->level >= $mo->starlimitLv, ErrCode::hero_yanling_canotTupo);
- my_Assert($user->baseInfo->level >= $mo->userlvLimit, ErrCode::hero_yanling_canotTupo);
- my_Assert($user->baseInfo->gold >= $mo->gold , ErrCode::notenough_gold_msg);
-
- $costItemsList = explode(';',$mo->costItems);
- foreach ($costItemsList as $value) {
- $list = explode(',', $value);
- StoreProc::removeItemFromStore($user->store, $list[0], $list[1]);
- }
-
- $user->baseInfo->gold -= $mo->gold;
- $yanling->$uid->starLv += 1;
-
- NormalEventProc::OnYanLingLvTuPo($uid, $yanling->$uid->starLv); # 广播英雄升级事件
-
- $user->store->yanling = $yanling;
- req()->userInfo->game = $user;
-
- UserProc::updateUserInfo(); # 回写玩家数据
- return Resp::ok(array(
- "store" => $user->store, # # 目前来看只涉及到items变化
- 'gold' => $user->baseInfo->gold,
- ));
- }
- /**
- * 言灵升级
- * @return type
- */
- static function YanlinUpLevel_new() {
- list($uid,$yanlingList, $items) = req()->paras; # 参数 言灵uid(指定进阶的言灵实例id)
- $user = req()->userInfo->game;
- $yanling = $user->store->yanling;
-
- my_Assert(CommUtil::isPropertyExists($yanling, $uid), ErrCode::store_weapon_err); # 玩家拥有此英雄
- $myPacketItems = $user->store->items;
- //消耗材料道具
- $total = 0;
- $totalGold = 0;
- foreach ($items as $costItemId => $costNumber) {
- my_Assert(CommUtil::isPropertyExists($myPacketItems,$costItemId), ErrCode::store_itemnotenough); #
- my_Assert($myPacketItems->$costItemId >= $costNumber, ErrCode::store_itemnotenough);# 检查道具的数量,在背包中是否充足
- $mo = GameConfig::item_stones_getItem($costItemId);
- my_Assert($mo != null, ErrCode::err_const_no);
-
- StoreProc::removeItemFromStore($user->store, $costItemId, $costNumber);
- $total += $mo->baseExp*$costNumber;
- $totalGold += $mo->costGold*$costNumber;
- }
-
- $yanlingExp = 0;
- //消耗武器
- foreach ($yanlingList as $yanlingId) {
- my_Assert(CommUtil::isPropertyExists($yanling, $yanlingId), ErrCode::store_weapon_err); # 玩家拥有此英雄
- $mo = GameConfig::item_yanling_getItem($yanling->$yanlingId->typeId);
- $baseExp = $mo->baseExp;
- $yanlingExp += $baseExp + $yanling->$yanlingId->curStarExp *0.75;
- $totalGold += $mo->costGold;
- StlUtil::dictRemove($user->store->yanling, $yanlingId);
- }
- my_Assert($user->baseInfo->gold >= $totalGold, ErrCode::notenough_gold_msg);
-
- $equipVo = new Ins_YanLin($yanling->$uid);
- //$equipVo = new Ins_Weapon($equipment->$uid);
- $initLevel = $equipVo->level;
-
- $equipVo->curStarExp += $total+(int)$wuqiExp;
- $curlevel = StoreProc::Upgrade($equipVo->curStarExp, GameConfig::item_base_getItem($equipVo->typeId)->quality,Enum_UpgradeType::YanLing);
- $curStar = $equipVo->starLv ; #当前星级
- $equipVo->level = $curlevel;
- if ($curStar < 5) {
- $starlimitLv = GameConfig::yanlingextra_level_getItem($equipVo->typeId, $curStar + 1)->starlimitLv;
- if ($starlimitLv < $curlevel) {
- $equipVo->level = $starlimitLv;
- $equipVo->curStarExp = GameConfig::yanlingLevel_type_getItem(GameConfig::item_base_getItem($equipVo->typeId)->quality,$starlimitLv)->requiredExp;
- }
- }
-
- $user->store->yanling->$uid = $equipVo;
- $user->baseInfo->gold -= $totalGold;
- req()->userInfo->game = $user;
- req()->userInfo->game->store->items = $myPacketItems; # 更新背包数据
- if ($equipVo->level != $initLevel) {
- NormalEventProc::OnYanLingLvlUp($uid, $equipVo->level); # 广播英雄升级事件
- }
-
- UserProc::updateUserInfo(); # 回写玩家数据
- return Resp::ok(array(
- "store" => $user->store, # # 目前来看只涉及到items变化
- 'gold' => $user->baseInfo->gold,
- ));
- }
-
- /** 6327
- * 言灵升级 2021.4(cyzhao)
- */
- static function YanlinUpLevel() {
- list($yanlingUid, $type) = req()->paras; # 参数: 言灵uid,升级类型:1/5级.
- $store = ctx()->store();
- my_Assert(StlUtil::dictHasProperty($store->yanling, $yanlingUid), ErrCode::hero_yanling_notfound);
- $allDic = GameConfig::yanlingLeve();
- $maxLevel = count((array) $allDic);
- $curlv = $store->yanling->$yanlingUid->level;
- my_Assert($curlv <= ctx()->base()->level, "请提升指挥官等级."); # 言灵等级不能超过指挥官等级.-gwang 2021.4.20
- my_Assert($curlv < $maxLevel, ErrCode::hero_yanling_levelMax);
- $maxLv = $curlv + $type;
- if ($maxLv > $maxLevel) {
- $maxLv = $maxLevel;
- }
- $goldNum = 0;
- $pointNum = 0;
- for ($index = $curlv; $index < $maxLv; $index++) {
- my_Assert(StlUtil::dictHasProperty($allDic, $index), ErrCode::hero_yanling_levelconst_no);
- $mo = GameConfig::yanlingLeve_getItem($index);
- $goldNum += $mo->goldCost;
- $pointNum += $mo->pointCost;
- }
- my_Assert(req()->userInfo->game->base()->Consume_Gold($goldNum), ErrCode::notenough_gold_msg);
- // my_Assert(Data_UserGame::Consume_ResPoint(req()->userInfo->game->baseInfo, $pointNum), ErrCode::notenough_resPoint);
- my_Assert(req()->userInfo->game->base()->Consume_ResPoint($pointNum), ErrCode::notenough_resPoint);
- $store->yanling->$yanlingUid->level += $type; # 增加等级
- if ($store->yanling->$yanlingUid->level > $maxLevel) {
- $store->yanling->$yanlingUid->level = $maxLevel;
- }
- TaskProc::OnYanlingLevelUp($store->yanling->$yanlingUid->typeId, $store->yanling->$yanlingUid->level); # 言灵升级
- // req()->userInfo->game->store = $store;
- UserProc::updateUserInfo(); # 回写玩家数据
- return Resp::ok(array('store' => req()->userInfo->game->store, #
- 'gold' => ctx()->base()->gold, #
- 'resPoint' => ctx()->base()->resPoint));
- }
- //
- // <editor-fold defaultstate="collapsed" desc="计算战队战斗力, for pvp back matchers, -wg 2017.07.13">
- /**
- * 计算队伍战斗力, 添加到战斗力隐藏榜单中, for pvp back matchers, -wg 2017.07.13
- * @param type $zoneid
- * @param type $uid
- * @param Data_UserGame $user
- * @return type
- */
- static function CalcTeamFightPower($zoneid, $uid, $user) {
- $teamsetting = $user->heroTeamConfig; # 战队配置
- // var_dump($user);
- $heros = $user->heros;
- $teamCfg = JsonUtil::decode($teamsetting);
- $tid = $teamCfg->curUseTeamID;
- $team = $teamCfg->teamDic->$tid;
- $fp = 0; # 返回值
- if ($team) {
- foreach ($team->heros as $hid) {
- if ($hid) {
- $hero = $heros->collectHeros->$hid;
- if ($hero) {
- // $fp += self::calcHeroFightPower($hero);
- $h = new Ins_UserHero($hero);
- $fp += $h->GetPower();
- }
- }
- }
- //todo: 这里的战斗力榜被总战力榜征用了key, 重启PVP机制时再
- }
- return $fp;
- }
- /**
- * 计算玩家总战斗力, 添加到战斗力榜单中
- * @version 1.0.0 改造自原来的队伍战斗力统计方法 --gwang 2020.4.23
- * @param type $zoneid
- * @param type $uid
- * @param Data_UserGame $user
- * @return type
- */
- static function CalcUserFightPower($zoneid, $uid, $user) {
- $fp = 0; # 总战力:返回值
- foreach ($user->heros->collectHeros as $hid => $hero) {
- $h = new Ins_UserHero($hero);
- $fp += $h->GetPower();
- }
- $key_fp = MemKey_GameRun::Game_FightPowerRank_zset($zoneid); # 战力榜
- $key_log = MemKey_GameRun::Game_Rank_FPowerBreakLog_hash($zoneid); # 突破记录
- gMem()->zadd($key_fp, array($uid => $fp)); # 更新战力记录
- foreach (GameConfig::rankreward_fpower() as $condition => $reward) { # 遍历突破奖励数据
- if ($fp >= $condition && !gMem()->hexists($key_log, $condition)) { # 判断是否达成突破奖励标准
- gMem()->hset($key_log, $condition, $uid); # 添加突破记录
- CornerSignEventProc::OnRanking_PowerReward_new();
- }
- }
- TaskProc::OnUserFightPowerN($fp);
- return $fp;
- }
- /**
- * 计算hero战斗力, for pvp back matchers, -wg 2017.07.13
- * @param Ins_UserHero $hero
- * @return int
- */
- static private function calcHeroFightPower($hero) {
- $arr = explode(';', glc()->Battle_PowerFactor);
- $factor = ArrayInit();
- foreach ($arr as $s) {
- $kv = explode(',', $s);
- $k = $kv[0];
- $v = $kv[1];
- $factor[$k] = $v;
- }
- $a = (int) (self::calcHeroProperty($hero, 'hp') * $factor ["hp"] //// todo: 哈哈, 奇葩的命名方案, 多处使用的命名不一致, 坑!
- + $hero->level * 10);
- return $a;
- }
- /**
- * 计算hero的属性,, for pvp back matchers, -wg 2017.07.13
- * @param Ins_UserHero $hero
- * @param type $propertyname
- */
- private static function calcHeroProperty($hero, $propertyname) {
- $val = 0;
- if ($hero) {
- $modle = GameConfig::hero_getItem($hero->typeId);
- if ($modle) {
- $extra = GameConfig::heroextra_level_getItem($hero->typeId, $hero->grade);
- if ($extra) {
- $val = (int) ($modle->$propertyname * (1 + $extra->$propertyname));
- } else {
- $val = $modle->$propertyname;
- }
- }
- }
- return $val;
- }
- // </editor-fold>
- //
- }
|