FightProc.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 战斗模块
  5. * @author c'y'zhao
  6. */
  7. class FightProc {
  8. public const TowerGateId = 940011999;
  9. /**
  10. * 逻辑分发
  11. * 所有的Proc中必须有这样一个方法
  12. * @param Req $req
  13. */
  14. public static function procMain($req) {
  15. switch ($req->cmd) {
  16. case CmdCode::fight_settle: # 6801 主线战斗结算
  17. return FightProc::Settle();
  18. case CmdCode::fight_PassGateTsPrizeReceive: # 6802 章节宝箱的领取
  19. return FightProc::PassGateTsPrizeReceive();
  20. case CmdCode::fight_selectGate: # 6803 主线剧情关卡选择
  21. return FightProc::SelectGate();
  22. case CmdCode::fight_gateChallengeRewards: # 6804 挑战关卡: 领取奖励
  23. return FightProc::GateChallengeRewards();
  24. case CmdCode::fihgt_reliveCost: # 6805 战斗: 复活花费
  25. return FightProc::ReliveCost();
  26. case CmdCode::fight_plotSav: # 6806 主线剧情(已播放)回存
  27. return FightProc::PlotSav();
  28. case CmdCode::fight_sweep: # 6807 主线扫荡
  29. return FightProc::FightSweep();
  30. case CmdCode::fight_startFight: # 6808 主线剧情关卡开始挑战
  31. return self::StartFight();
  32. case CmdCode::fight_tower_RefreshSkills: # 6809 挑战关卡: 刷新初始技能
  33. return self::TowerRefreshSkills();
  34. case CmdCode::fight_tower_updatelocklist: # 6810 挑战关卡: 更新技能锁定列表
  35. return self::TowerUpdateLockskillList();
  36. case CmdCode::fight_rankInfo: # 6811 获取主线关卡排行榜信息
  37. return self::GetRankInfo();
  38. case CmdCode::fight_rank_uidEquipInfo: # 6812 获取主线关卡榜内玩家的装备信息
  39. return self::GetUidEquipInfo_Rank();
  40. case CmdCode::fight_rank_GetMainGateRankRewardInfo: # 6813 获取通关荣誉榜信息
  41. return self::GetmainGate_RankRewardInfo();
  42. case CmdCode::fight_rank_GetFightPowerRankRewardInfo: # 6814 获取战力荣誉榜信息
  43. return self::GetFightPower_RankRewardInfo();
  44. case CmdCode::fight_rank_ReceiveRankReward_MainGate: # 6815 领取通关荣誉榜奖励
  45. return self::ReceiveRankReward_MainGate();
  46. case CmdCode::fight_rank_ReceiveRankReward_FightPower: # 6816 领取战力荣誉榜奖励
  47. return self::ReceiveRankReward_FightPower();
  48. case CmdCode::fight_rank_IsExistRankReward: # 6817 是否存在未领取的荣誉榜奖励
  49. return self::IsExistRankReward();
  50. case CmdCode::fight_evolveUnlock: # 6818 启灵解锁
  51. return self::EvolveUnlock();
  52. case CmdCode::fight_MainTZPass: # 6819 主线挑战--通关
  53. return self::MainTZPass();
  54. case CmdCode::fight_MainTZGetReward: # 6820 主线挑战--领取奖励
  55. return self::MainTZGetReward();
  56. case CmdCode::fight_ResetChallange_RedMask: # 6821 每天重置挑战红点
  57. return self::ResetChallange_RedMask();
  58. case CmdCode::fight_lockSkill: # 6822 封印/解封技能
  59. return self::LockSkill();
  60. case CmdCode::fight_buyLockSkillCount: # 6823 购买更多封印数量
  61. return self::BuySkillLockCount();
  62. case CmdCode::fight_rank_ReceiveRankReward: # 6824 排行奖励一键领取
  63. return self::ReceiveRankReward();
  64. default:
  65. Err(ErrCode::cmd_err);
  66. }
  67. }
  68. /**
  69. * 6823 购买更多技能封印数量
  70. */
  71. static function BuySkillLockCount() {
  72. list($n) = req()->paras; # 解锁数量
  73. my_Assert($n > ctx()->privateData()->skillLockerNumber, ErrCode::paras_err); # 参数异常
  74. $amt = 0;
  75. foreach (explode(",", glc()->Skill_LockBtn_BuyCount_Cost) as $str) {
  76. list($cnt, $cost) = explode(':', $str);
  77. if ($cnt == $n) {
  78. $amt = $cost;
  79. break;
  80. }
  81. }
  82. my_Assert($amt > 0, "消耗元宝数量配置出错!");
  83. my_Assert(ctx()->base()->Consume_Cash($amt), ErrCode::notenough_cash_msg);
  84. ctx()->privateData()->skillLockerNumber = $cnt;
  85. UserProc::updateUserInfo();
  86. return Resp::ok();
  87. }
  88. /**
  89. * 6822 封印/解封技能
  90. */
  91. static function LockSkill() {
  92. list($skillTypeId) = req()->paras; # 技能类型ID
  93. $pri = ctx()->privateData();
  94. // my_Assert(in_array($skillTypeId, $pri->skillUnlockRecord), "技能尚未解锁!");
  95. if (in_array($skillTypeId, $pri->skillReLocked)) { # 解封
  96. StlUtil::arrayRemove($pri->skillReLocked, $skillTypeId);
  97. } else { # 封印
  98. my_Assert(count($pri->skillReLocked) < $pri->skillLockerNumber, "超出封印上限!");
  99. $pri->skillReLocked[] = $skillTypeId;
  100. TaskProc::OnCloseSkill();
  101. }
  102. return Resp::ok(array("task" => ctx()->task,));
  103. }
  104. /**
  105. * 6821 每天重置挑战红点
  106. */
  107. static function ResetChallange_RedMask() {
  108. ctx()->privateState->challange_RedMask = 1;
  109. UserProc::updateUserInfo();
  110. return Resp::ok();
  111. }
  112. /**
  113. * 6819 主线挑战 -- 通关
  114. */
  115. static function MainTZPass() {
  116. list($gateId, $index, $killMonsterNum, $killBossNum) = req()->paras; # 关卡id, 通关难度索引(1/2/3)
  117. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  118. // isEditor() && $gateInfo = new Ins_GateInfo();
  119. $gateInfo = ctx()->gates->GateList->$gateId;
  120. my_Assert($gateInfo->pass, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
  121. my_Assert($gateInfo->tz_state + 1 >= $index, ErrCode::gate_GateNoUnlock); # 通关上一难度解锁当前难度
  122. FightProc::funUnlock_mainChallengeGate_State(true, $gateId, $index);
  123. $gateInfo->tz_state = $index;
  124. TaskProc::OnPassMainChallengeGate_X_Num($gateId, $index);
  125. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  126. TaskProc::OnKillleaderNumMonster($killBossNum);
  127. UserProc::updateUserInfo();
  128. return Resp::ok(array("task" => ctx()->task,
  129. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  130. 'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
  131. ));
  132. }
  133. /**
  134. * 6820 主线挑战 -- 领取奖励
  135. */
  136. static function MainTZGetReward() {
  137. list($gateId, $index) = req()->paras; # 关卡id, 通关难度索引(1/2/3)
  138. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  139. // isEditor() && $gateInfo = new Ins_GateInfo();
  140. $gateInfo = ctx()->gates->GateList->$gateId;
  141. my_Assert($gateInfo->pass, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
  142. my_Assert($gateInfo->tz_state >= $index, ErrCode::gate_GateNoUnlock); # 已解锁当前难度
  143. my_Assert(Bits::GetBitValue($gateInfo->tz_rewards, $index - 1) == false, ErrCode::gate_GatePriceHasReceive);
  144. $gateInfo->tz_rewards = Bits::SetBitValue($gateInfo->tz_rewards, $index - 1, true); # 更新领取记录
  145. $prize = "tz_reward" . $index;
  146. $mo = GameConfig::gate_getItem($gateId);
  147. StoreProc::AddMultiItemInStore($mo->$prize);
  148. UserProc::updateUserInfo();
  149. return Resp::ok();
  150. }
  151. /**
  152. * 6818 启灵解锁
  153. * @return type
  154. */
  155. public static function EvolveUnlock() {
  156. list($type, $id) = req()->paras; //$id废弃 因为玩家可能不安顺序点
  157. if ($type == 1) {
  158. $nextId = ctx()->gates->evolveMaxId_left + 1;
  159. my_Assert($id == $nextId, ErrCode::err_const_no);
  160. $mo = GameConfig::evolve_getItem($nextId);
  161. my_Assert($mo != null, ErrCode::err_const_no);
  162. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  163. my_Assert(ctx()->baseInfo->gold >= $mo->needGold_unlock, ErrCode::notenough_gold_msg);
  164. ctx()->baseInfo->Consume_Gold($mo->needGold_unlock);
  165. ctx()->gates->evolveMaxId_left = $nextId;
  166. TaskProc::OnCompleteNumQiLing();
  167. } else {
  168. $nextId = ctx()->gates->evolveMaxId_right + 1;
  169. my_Assert($id == $nextId, ErrCode::err_const_no);
  170. $dic = GameConfig::evolve();
  171. foreach ($dic as $key => $value) {
  172. if ($value->specificEvolveId == $nextId) {
  173. $mo = $value;
  174. }
  175. }
  176. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  177. my_Assert($mo != null, ErrCode::err_const_no);
  178. if ($mo->specificEvolveCost != null) {
  179. $cost = explode(',', $mo->specificEvolveCost);
  180. $costId = $cost[0];
  181. $costNum = $cost[1];
  182. my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $costId) && ctx()->store->items->$costId >= $costNum, ErrCode::notenough_item);
  183. ctx()->store->removeItem($costId, $costNum);
  184. }
  185. ctx()->gates->evolveMaxId_right = $id;
  186. TaskProc::OnCompleteNumSpecialQiLing();
  187. }
  188. UserProc::updateUserInfo();
  189. $ret = array(
  190. 'task' => ctx()->task,
  191. 'gold' => ctx()->baseInfo->gold,
  192. 'items' => ctx()->store->items,
  193. 'evolveMaxId_right' => ctx()->gates->evolveMaxId_right,
  194. 'evolveMaxId_left' => ctx()->gates->evolveMaxId_left,
  195. );
  196. return Resp::ok($ret);
  197. }
  198. /**
  199. * 6807 扫荡
  200. * @return type
  201. */
  202. public static function FightSweep() {
  203. //list($gateId) = req()->paras;
  204. $passGateId = ctx()->gates->maxPassGateId();
  205. my_Assert($passGateId != 0, ErrCode::gate_NoSweep);
  206. $mo = GameConfig::gate_getItem($passGateId);
  207. $gateName = $mo->gateName;
  208. $costTili = glc()->sweep_cost_tili;
  209. $curTili = ctx()->baseInfo->CurTili();
  210. my_Assert($curTili >= $costTili, ErrCode::notenough_tili);
  211. if (ctx()->privateState->honourCardShop_ts == 0) {
  212. $max = glc()->sweepMaxNum;
  213. my_Assert(ctx()->gates->fightSweepNum < $max, ErrCode::gate_SweepMaxNum_limit);
  214. }
  215. ctx()->gates->fightSweepNum += 1;
  216. ctx()->baseInfo->Consume_tili($costTili);
  217. $wavesArr = GameConfig::waves_getItemArray($passGateId);
  218. $count = count($wavesArr);
  219. $wavesMo = $wavesArr[$count - 1];
  220. $gold = $wavesMo->rewardGold;
  221. StoreProc::AddMultiItemInStore("1," . $gold);
  222. $oldLevel = ctx()->baseInfo->level;
  223. $exp = $wavesMo->rewardExp;
  224. StoreProc::AddMultiItemInStore("4," . $exp);
  225. $newLevel = ctx()->baseInfo->level;
  226. if ($wavesMo->rewardTuZhi != null) {
  227. $tuzhi = explode('-', $wavesMo->rewardTuZhi);
  228. $n = rand($tuzhi[0], $tuzhi[1]);
  229. $tuzhiArr = array();
  230. $item = GameConfig::item();
  231. foreach ($item as $id => $mo) {
  232. if ($mo->itemType == 100) {
  233. $tuzhiArr[] = $id;
  234. }
  235. }
  236. for ($i = 0; $i < $n; $i++) {
  237. $index = rand(0, count($tuzhiArr) - 1);
  238. $goodsStr = $tuzhiArr[$index] . ',' . 1;
  239. $prizeArr[] = $goodsStr;
  240. StoreProc::AddMultiItemInStore($goodsStr);
  241. }
  242. }
  243. if ($wavesMo->rewardGem != null) {
  244. $goodsStr = self::sweepRandReward($wavesMo->rewardGem);
  245. $str = explode(';', $goodsStr);
  246. $dic = GameConfig::gem();
  247. foreach ($str as $value) {
  248. $list = explode(',', $value);
  249. $posId = rand(1, 6);
  250. $qual = $list[0];
  251. foreach ($dic as $key => $gemMo) {
  252. if ($gemMo->qual == $qual && $gemMo->position == $posId && $gemMo->isfixed_predicateId == 0) {
  253. $gemStr = $gemMo->typeId . ',' . $list[1];
  254. SystemProc::GetGem_GreaterOrangeQual_SweepMainGateIndex(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($passGateId), $gateName, $gemMo->typeId);
  255. //StoreProc::PutGemInStore($gemMo->typeId, $list[1]);
  256. StoreProc::AddMultiItemInStore($gemStr);
  257. break;
  258. }
  259. }
  260. }
  261. }
  262. TaskProc::OnFightSweepGate();
  263. UserProc::updateUserInfo();
  264. $ret = array(
  265. 'gold' => ctx()->baseInfo->gold,
  266. 'cash' => ctx()->baseInfo->cash,
  267. 'tili' => ctx()->baseInfo->tili,
  268. 'tili_ts' => ctx()->baseInfo->tili_ts,
  269. 'xp' => ctx()->baseInfo->xp,
  270. 'maxXp' => ctx()->baseInfo->maxXp,
  271. 'level' => ctx()->baseInfo->level,
  272. 'fightSweepNum' => ctx()->gates->fightSweepNum,
  273. //'prizeArr' => $prizeArr,
  274. 'store' => ctx()->store,
  275. 'task' => ctx()->task,
  276. 'reward' => StoreProc::$reward,
  277. 'reward_Gem' => StoreProc::$reward_Gem,
  278. 'oldLevel' => $oldLevel,
  279. 'newLevel' => $newLevel,
  280. );
  281. return Resp::ok($ret);
  282. }
  283. static function sweepRandReward($rewardStr) {
  284. $ctxArr = explode(';', $rewardStr);
  285. $numArr = explode('-', $ctxArr[0]);
  286. $num = rand($numArr[0], $numArr[1]);
  287. $rand = 0;
  288. $itemArr = explode(',', $ctxArr[1]);
  289. foreach ($itemArr as $value) {
  290. $arr = explode(':', $value);
  291. $itemId = $arr[0];
  292. $per = $arr[1];
  293. $rand += $per;
  294. }
  295. $res = "";
  296. for ($i = 0; $i < $num; $i++) {
  297. $start = 0;
  298. $end = 0;
  299. $randNum = rand(1, $rand);
  300. $id = 0;
  301. foreach ($itemArr as $str) {
  302. $arr = explode(':', $str);
  303. $itemId = $arr[0];
  304. $per = $arr[1];
  305. $end += $per;
  306. if ($randNum > $start && $randNum <= $end) {
  307. $id = $itemId;
  308. break;
  309. }
  310. $start = $end;
  311. }
  312. if ($id != 0) {
  313. $str = $id . ',1';
  314. if ($res == "") {
  315. $res = $str;
  316. } else {
  317. $res = $res . ';' . $str;
  318. }
  319. }
  320. }
  321. return $res;
  322. }
  323. /**
  324. * 6808 开始挑战 (主线关卡:扣除体力, 挑战关卡: 增加次数)
  325. */
  326. private static function StartFight() {
  327. list($gateId, $layerNum) = req()->paras;
  328. my_Assert($gateId > 0, ErrCode::paras_err);
  329. $mo = GameConfig::gate_getItem($gateId);
  330. my_Assert(null != $mo, ErrCode::err_const_no);
  331. if (Ints::Slice($gateId, 0, 1) == 9) { # 爬塔模式
  332. // list($layerNum) = req()->paras;
  333. if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) { # 起始层数校验
  334. Err(ErrCode::tower_layerNum);
  335. }
  336. if (ctx()->gates()->TowerGateInfo()->TodayChanNum < 1) { # 剩余次数校验
  337. Err(ErrCode::tower_timeNo);
  338. }
  339. ctx()->gates()->TowerGateInfo()->TodayChanNum--; # 增加次数
  340. } else { # 主线剧情
  341. my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
  342. }
  343. UserProc::updateUserInfo();
  344. return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
  345. }
  346. public static function FightDailyClear() {
  347. //ctx()->gates->xunluo_quick_buyRecord = 0;
  348. ctx()->gates->fightSweepNum = 0;
  349. ctx()->gates()->TowerGateInfo()->RefreshSkillTimes = 0;
  350. ctx()->gates()->TowerGateInfo()->TodayChanNum = glc()->tower_daily_chanceNum;
  351. ctx()->privateState->challange_RedMask = 0;
  352. }
  353. /**
  354. * 6806 剧情回存
  355. * @return type
  356. */
  357. public static function PlotSav() {
  358. list($gateId) = req()->paras;
  359. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no);
  360. ctx()->gates->GateList->$gateId->plotStart = 1;
  361. UserProc::updateUserInfo();
  362. $ret = array(
  363. 'ok' => 1,
  364. );
  365. return Resp::ok($ret);
  366. }
  367. // <editor-fold defaultstate="collapsed" desc="挑战模块">
  368. /**
  369. * 6810 挑战关卡: 更新锁定技能列表
  370. */
  371. public static function TowerUpdateLockskillList() {
  372. list($li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  373. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  374. $t->skill_zhudong = $li_zd;
  375. $t->skill_beidong = $li_bd;
  376. $t->skill_zhudong_lockState = $li_zds;
  377. $t->skill_beidong_lockState = $li_bds;
  378. UserProc::updateUserInfo();
  379. return Resp::ok();
  380. }
  381. /**
  382. * 6809 挑战关卡: 刷新初始技能(扣除免费次数/cost)
  383. */
  384. public static function TowerRefreshSkills() {
  385. list($isFree, $li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  386. if ($isFree) {
  387. if (ctx()->gates()->TowerGateInfo()->RefreshSkillTimes > glc()->tower_daily_refreshChanceNum) {
  388. Err(ErrCode::tower_refreshNo); # 免费次数不足
  389. }
  390. } else {
  391. list($type, $num) = explode(':', glc()->tower_refreshCost); # 二级货币类型(1:金币,2:元宝):数量
  392. if ($type == 1) { # 金币
  393. my_Assert(ctx()->base()->Consume_Gold($num), ErrCode::notenough_gold_msg);
  394. } else if ($type == 2) { # 元宝
  395. my_Assert(ctx()->base()->Consume_Cash($num), ErrCode::notenough_cash_msg);
  396. } else {
  397. Err(ErrCode::err_const_no, "检查刷新扣费配置信息!");
  398. }
  399. }
  400. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  401. $t->RefreshSkillTimes++;
  402. $t->skill_zhudong = $li_zd;
  403. $t->skill_beidong = $li_bd;
  404. $t->skill_zhudong_lockState = $li_zds;
  405. $t->skill_beidong_lockState = $li_bds;
  406. UserProc::updateUserInfo();
  407. $ret = array(
  408. 'task' => ctx()->task,
  409. );
  410. return Resp::ok($ret);
  411. }
  412. /**
  413. * 6805 战斗: 复活花费
  414. * @return type
  415. * @version 2024年5月17日 重整利用为复活扣除消耗功能
  416. */
  417. public static function ReliveCost() {
  418. // 复活可以扣除复活币(暂无)或者元宝,(客户端看广告复活不需要跟服务器通讯)
  419. list($reliveNum) = req()->paras;
  420. $arr = explode(',', glc()->Relive_cost);
  421. my_Assert($reliveNum >= 0 && $reliveNum <= Count($arr), ErrCode::paras_err); # 参数范围>0
  422. $amt = $arr[$reliveNum];
  423. my_Assert(ctx()->base()->Consume_Cash($amt), ErrCode::notenought_yuanbao);
  424. UserProc::updateUserInfo();
  425. return Resp::ok();
  426. }
  427. /**
  428. * 6804 挑战关卡: 奖励领取
  429. * @return type
  430. */
  431. public static function GateChallengeRewards() {
  432. list($finalLayer, $killedMonster, $killedBoss) = req()->paras; # 战斗结束时的层数
  433. $lastLayer = ctx()->gates()->TowerGateInfo()->CurLayer;
  434. $arr = GameConfig::waves_getItemArray(self::TowerGateId);
  435. TaskProc::OnFightNumChallengeGate();
  436. TaskProc::OnKillCommonNumMonster($killedMonster);
  437. TaskProc::OnKillleaderNumMonster($killedBoss);
  438. if ($finalLayer > $lastLayer) {
  439. foreach ($arr as $layerId => $layerMo) {
  440. if ($layerMo->waveId >= $lastLayer && $layerMo->waveId < $finalLayer) {
  441. my_Assert($layerMo != null, ErrCode::err_const_no);
  442. StoreProc::AddMultiItemInStore($layerMo->rewards); # 发放奖励
  443. }
  444. }
  445. ctx()->gates()->TowerGateInfo()->CurLayer = $finalLayer;
  446. TaskProc::OnPassLayer_ChallengeGate($finalLayer - 1);
  447. UserProc::updateUserInfo();
  448. $ret = array(
  449. 'store' => ctx()->store,
  450. 'gold' => ctx()->base()->gold,
  451. 'cash' => ctx()->base()->cash,
  452. 'task' => ctx()->task,
  453. );
  454. return Resp::ok($ret);
  455. } else if ($finalLayer == $lastLayer) {
  456. $ret = array(
  457. 'store' => ctx()->store,
  458. 'gold' => ctx()->base()->gold,
  459. 'cash' => ctx()->base()->cash,
  460. 'task' => ctx()->task,
  461. );
  462. return Resp::ok($ret);
  463. }
  464. return Resp::err(ErrCode::tower_rewardNo); # 没有奖励
  465. }
  466. // </editor-fold>
  467. /**
  468. * 6803 关卡选择
  469. * @return type
  470. */
  471. public static function SelectGate() {
  472. list($gateId) = req()->paras;
  473. ctx()->gates->CurrentGateId = $gateId;
  474. UserProc::updateUserInfo();
  475. $ret = array(
  476. 'gates' => ctx()->gates,
  477. );
  478. return Resp::ok($ret);
  479. }
  480. /**
  481. * 6802 章节宝箱的领取
  482. * @return type
  483. */
  484. public static function PassGateTsPrizeReceive() {
  485. list($gateId, $index) = req()->paras;
  486. $gateMo = GameConfig::gate_getItem($gateId);
  487. my_Assert($gateMo != null, ErrCode::err_const_no);
  488. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  489. $gateInfo = ctx()->gates->GateList->$gateId;
  490. $tag = false;
  491. $prize = "";
  492. $mask = 0;
  493. switch ($index) {
  494. case 1:
  495. $ts = $gateMo->first_ts1 * 60;
  496. if ($gateInfo->MaxSeconds >= $ts) {
  497. $tag = true;
  498. }
  499. $mask = 1;
  500. $prize = $gateMo->first_reward1;
  501. break;
  502. case 2:
  503. $ts = $gateMo->first_ts2 * 60;
  504. if ($gateInfo->MaxSeconds >= $ts) {
  505. $tag = true;
  506. }
  507. $mask = 2;
  508. $prize = $gateMo->first_reward2;
  509. break;
  510. case 3:
  511. if ($gateInfo->pass > 0) {
  512. $tag = true;
  513. }
  514. $mask = 3;
  515. $prize = $gateMo->first_reward3;
  516. break;
  517. default:
  518. break;
  519. }
  520. if ($tag) {
  521. my_Assert(!in_array($mask, $gateInfo->FirstReward), ErrCode::gate_GatePriceHasReceive);
  522. $gateInfo->FirstReward[] = $mask;
  523. $pStr = explode(';', $prize);
  524. foreach ($pStr as $val) {
  525. $arr = explode(',', $val);
  526. if(GameConfig::item_getItem($arr[0]) == 201 || GameConfig::item_getItem($arr[0]) == 701){
  527. FightProc::funUnlock_Gem();
  528. break;
  529. }
  530. }
  531. StoreProc::AddMultiItemInStore($prize);
  532. }
  533. ctx()->gates->GateList->$gateId = $gateInfo;
  534. UserProc::updateUserInfo();
  535. $ret = array(
  536. 'gates' => ctx()->gates,
  537. 'store' => ctx()->store,
  538. 'task' => ctx()->task,
  539. 'gold' => ctx()->baseInfo->gold,
  540. 'cash' => ctx()->baseInfo->cash,
  541. 'reward' => StoreProc::$reward,
  542. 'reward_Gem' => StoreProc::$reward_Gem,
  543. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  544. 'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
  545. );
  546. return Resp::ok($ret);
  547. }
  548. /**
  549. * [6801]关卡战斗结算
  550. * @return type
  551. */
  552. public static function Settle() {
  553. list($resultType, $gateId, $gold, $curTs, $pickups,
  554. $finalLayer, $finalHpPercent, $killMonsterNum, $killBossNum,
  555. $finalLevel, $reliveNum) = req()->paras;
  556. # 客户端需要增加参数: killmonserNum,killBosssNum, finalHpPercent(最终血量百分比)
  557. $gateMo = GameConfig::gate_getItem($gateId);
  558. my_Assert($gateMo != null, ErrCode::err_const_no);
  559. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  560. $gateInfo = ctx()->gates->GateList->$gateId;
  561. $ts = $gateInfo->MaxSeconds;
  562. if ($curTs >= $ts) {
  563. $gateInfo->MaxSeconds = $curTs;
  564. }
  565. self::funUnlock_Gate($resultType, $gateId); //备注:这个接口的位置不能动 里面有关卡第一次胜利解锁的功能提示校验
  566. self::subFunUnlock($resultType, $gateId);
  567. if ($resultType) { # 胜利
  568. self::skillUnlock_gate($resultType, $gateId); //备注 这个接口位置不能动
  569. if (ctx()->gates->GateList->$gateId->pass == 0) {
  570. ctx()->gates->GateList->$gateId->pass = 1;
  571. TaskProc::Day7TaskReset($gateId); # 刷新七日任务
  572. $maxGateId = ctx()->gates->maxPassGateNumId();
  573. if ($maxGateId > 0) {
  574. self::Ranking_MainGateIndex($maxGateId);
  575. self::IsAchievedMainGate_PassReward($maxGateId);
  576. }
  577. }
  578. TaskProc::OnPassGate_X($gateId); # 刷新任务进度: 通关第X关
  579. TaskProc::OnPassGate_X_state($gateId);
  580. if (Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate) {
  581. ctx()->gates()->UnlockNextPlotGate($gateId); # 解锁下一主线关卡
  582. // ctx()->gates()->UnlockMainChallengeGate($gateId); # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  583. } else { # 不是主线关卡, 暂时没有其他逻辑
  584. }
  585. // StoreProc::AddMultiItemInStore($gateMo->reward_win); # 发放胜利奖励(2024.5.30 过期)
  586. } else {
  587. ctx()->gates->GateList->$gateId->fightNum_fail += 1;
  588. self::skillUnlock_fightNum($resultType); //这个接口位置不能动
  589. }
  590. // else { # 失败
  591. //// StoreProc::AddMultiItemInStore($gateMo->reward_fail); # 发放失败奖励(2024.5.30 过期)
  592. // }
  593. StoreProc::AddMultiItemInStore($pickups); # 战场拾取道具直接入背包
  594. //ctx()->base()->Add_Gold($gold); # 战场拾取的金币直接入背包
  595. //ctx()->base()->Add_Exp($exp);
  596. $waveMo = GameConfig::waveItem_getItem($gateId, $finalLayer);
  597. my_Assert(null != $waveMo, ErrCode::err_const_no);
  598. $oldLevel = ctx()->baseInfo->level;
  599. StoreProc::AddMultiItemInStore('4,' . $waveMo->rewardExp);
  600. //ctx()->base()->Add_Exp($waveMo->rewardExp); # 指挥官经验
  601. $newLevel = ctx()->baseInfo->level;
  602. if ($oldLevel != $newLevel) {
  603. ctx()->privateState->oldLevel = $oldLevel;
  604. ctx()->privateState->upLevel = $newLevel;
  605. }
  606. //ctx()->base()->Add_Gold($waveMo->rewardGold); # 金币奖励
  607. //$pickups .= ";1," . $gold + $waveMo->rewardGold;
  608. $str = "1," . $gold + $waveMo->rewardGold;
  609. StoreProc::AddMultiItemInStore($str);
  610. # 图纸奖励: 数量min-max, 部位随机
  611. if (strlen($waveMo->rewardTuZhi) > 0 && str_contains($waveMo->rewardTuZhi, '-')) {
  612. list($tz_min, $tz_max) = explode('-', $waveMo->rewardTuZhi); # 图纸数量
  613. $tz_n = rand($tz_min, $tz_max);
  614. # 图纸部位数据源 1001, 1002, 1003, 1004, 1005, 1006
  615. for ($i = 0; $i < $tz_n; $i++) {
  616. $id = 1000 + rand(1, 6);
  617. StoreProc::AddMultiItemInStore("$id,1"); # 获得图纸
  618. //$pickups .= ";$id,1";
  619. }
  620. }
  621. # 宝石奖励: 数量min-max;品质:权重,品质:权重...
  622. if (strlen($waveMo->rewardGem) > 0) {
  623. self::funUnlock_Gem();
  624. list($gs_num, $gs_props) = explode(';', $waveMo->rewardGem);
  625. list($gem_min, $gem_max) = explode('-', $gs_num); # 宝石数量
  626. $gem_n = rand($gem_min, $gem_max);
  627. $arr = explode(",", $gs_props);
  628. $pool = array();
  629. $n = 0;
  630. foreach ($arr as $str) {
  631. list($qual, $props) = explode(':', $str);
  632. $pool[] = array('q' => $qual, 'p' => $props);
  633. $n += $props;
  634. }
  635. for ($i = 0; $i < $gem_n; $i++) { # 随机n块宝石
  636. $r = rand(1, $n); # 投色子
  637. $l = 0;
  638. foreach ($pool as $item) {
  639. if ($r <= ($l + $item['p'])) {
  640. $gemId = $item['q'] * 100000 + rand(1, 6) * 1000;
  641. SystemProc::GetGem_GreaterOrangeQual_MainGate(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($gateId), $gateMo->gateName, $gemId); //广播
  642. //StoreProc::PutGemInStore($gemId); # 发放宝石并退出本次投色子
  643. //$pickups .= ";$gemId,1";
  644. StoreProc::AddMultiItemInStore("$gemId,1");
  645. break;
  646. }
  647. $l += $item['p']; # 累计到下一段
  648. }
  649. }
  650. }
  651. ctx()->gates->GateList->$gateId->fightNum += 1;
  652. TaskProc::OnFightNumMainGate();
  653. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  654. TaskProc::OnKillleaderNumMonster($killBossNum);
  655. TaskProc::OnFightGate_X($gateId);
  656. UserProc::updateUserInfo();
  657. $ret = array(
  658. 'gates' => ctx()->gates,
  659. 'store' => ctx()->store,
  660. 'task' => ctx()->task,
  661. 'baseInfo' => ctx()->base(),
  662. 'gold' => $gold + $waveMo->rewardGold,
  663. 'exp' => $waveMo->rewardExp,
  664. //'rewardStr' => $pickups
  665. 'reward' => StoreProc::$reward,
  666. 'reward_Gem' => StoreProc::$reward_Gem,
  667. 'oldLevel' => $oldLevel,
  668. 'newLevel' => $newLevel,
  669. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  670. 'funUnlockRecord_2'=> ctx()->privateState->funUnlockRecord_2,
  671. 'skillUnlockRecord' => ctx()->privateState->skillUnlockRecord,
  672. 'heros' => ctx()->heros,
  673. 'subFunStartTs' => ctx()->privateState->subFunStartTs,
  674. );
  675. return Resp::ok($ret);
  676. }
  677. // <editor-fold defaultstate="collapsed" desc="功能解锁">
  678. /**
  679. * 检测功能解锁的
  680. * @param type $resultType
  681. * @param type $gateId
  682. * @return type
  683. */
  684. static function funUnlock($resultType, $gateId) {
  685. $dic = GameConfig::fun_unlock();
  686. foreach ($dic as $id => $mo) {
  687. if ($mo->unlockTip == 1 && $mo->unlockParas1 == $gateId) {
  688. $tag = false;
  689. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  690. switch ($mo->unlockType1) {
  691. case 1:
  692. if (ctx()->gates->GateList->$gateId->fightNum == 0) {
  693. $tag = true;
  694. }
  695. break;
  696. case 2:
  697. if ($resultType == true && ctx()->gates->GateList->$gateId->pass == 0) {
  698. $tag = true;
  699. }
  700. break;
  701. default:
  702. break;
  703. }
  704. if ($tag) {
  705. ctx()->privateState->funUnlockRecord[] = $id;
  706. }
  707. }
  708. }
  709. }
  710. /**
  711. * 检测功能解锁的 关卡
  712. * @param type $resultType
  713. * @param type $gateId
  714. * @return type
  715. */
  716. static function funUnlock_Gate($resultType, $gateId) {
  717. $dic = GameConfig::fun_unlock();
  718. foreach ($dic as $id => $mo) {
  719. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  720. $tag = false;
  721. if ($mo->unlockType1 != null) {
  722. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  723. switch ($mo->unlockType1) {
  724. case Enum_FunUnlockType::battle_Gate:
  725. if ($mo->unlockParas1 == $gateId && ctx()->gates->GateList->$gateId->fightNum == 0) {
  726. $tag = true;
  727. }
  728. break;
  729. case Enum_FunUnlockType::passBattle_Gate:
  730. if ($resultType == true && $mo->unlockParas1 == $gateId && ctx()->gates->GateList->$gateId->pass == 0) {
  731. $tag = true;
  732. }
  733. break;
  734. default:
  735. break;
  736. }
  737. }
  738. if ($mo->unlockType2 != null) {
  739. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  740. switch ($mo->unlockType2) {
  741. case Enum_FunUnlockType::battle_Gate:
  742. if ($mo->unlockParas2 == $gateId && ctx()->gates->GateList->$gateId->fightNum == 0) {
  743. $tag = true;
  744. }
  745. break;
  746. case Enum_FunUnlockType::passBattle_Gate:
  747. if ($resultType == true && $mo->unlockParas2 == $gateId && ctx()->gates->GateList->$gateId->pass == 0) {
  748. $tag = true;
  749. }
  750. break;
  751. default:
  752. break;
  753. }
  754. }
  755. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  756. ctx()->privateState->funUnlockRecord[] = $id;
  757. ctx()->privateState->funUnlockRecord_2[] = $id;
  758. }
  759. }
  760. }
  761. }
  762. /**
  763. * 初次得到宝石 功能解锁
  764. */
  765. static function funUnlock_Gem() {
  766. $dic = GameConfig::fun_unlock();
  767. foreach ($dic as $id => $mo) {
  768. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  769. $tag = false;
  770. if($mo->unlockType1 != null && $mo->unlockType1 == Enum_FunUnlockType::getGem && ctx()->store->gemStore == null){
  771. $tag = true;
  772. }
  773. if($mo->unlockType2 != null && $mo->unlockType2 == Enum_FunUnlockType::getGem && ctx()->store->gemStore == null){
  774. $tag = true;
  775. }
  776. }
  777. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  778. ctx()->privateState->funUnlockRecord[] = $id;
  779. ctx()->privateState->funUnlockRecord_2[] = $id;
  780. }
  781. }
  782. }
  783. /**
  784. * 玩家等级要求 功能解锁
  785. */
  786. static function funUnlock_userLv($level) {
  787. $dic = GameConfig::fun_unlock();
  788. foreach ($dic as $id => $mo) {
  789. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  790. $tag = false;
  791. if($mo->unlockType1 != null && $mo->unlockType1 == Enum_FunUnlockType::userLv && $mo->unlockParas1 == $level){
  792. $tag = true;
  793. }
  794. if($mo->unlockType2 != null && $mo->unlockType2 == Enum_FunUnlockType::userLv && $mo->unlockParas2 == $level){
  795. $tag = true;
  796. }
  797. }
  798. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  799. ctx()->privateState->funUnlockRecord[] = $id;
  800. ctx()->privateState->funUnlockRecord_2[] = $id;
  801. }
  802. }
  803. }
  804. /**
  805. * 主线挑战 功能解锁
  806. */
  807. static function funUnlock_mainChallengeGate_State($result,$gateId,$state) {
  808. $dic = GameConfig::fun_unlock();
  809. foreach ($dic as $id => $mo) {
  810. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  811. $tag = false;
  812. if($mo->unlockType1 != null && $result = true && $mo->unlockType1 == Enum_FunUnlockType::mainChallengeGate_State){
  813. $str = explode(',', $mo->unlockParas1);
  814. $uGateId = $str[0];
  815. $gateState = $str[1];
  816. if($uGateId == $gateId && StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId) && ctx()->gates->GateList->$gateId->tz_state == $gateState-1){
  817. $tag = true;
  818. }
  819. }
  820. if($mo->unlockType2 != null &&$result = true && $mo->unlockType2 == Enum_FunUnlockType::mainChallengeGate_State){
  821. $str = explode(',', $mo->unlockParas2);
  822. $uGateId = $str[0];
  823. $gateState = $str[1];
  824. if($uGateId == $gateId && StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId) && ctx()->gates->GateList->$gateId->tz_state == $gateState-1){
  825. $tag = true;
  826. }
  827. }
  828. }
  829. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  830. ctx()->privateState->funUnlockRecord[] = $id;
  831. ctx()->privateState->funUnlockRecord_2[] = $id;
  832. }
  833. }
  834. }
  835. /**
  836. * 检测次级功能解锁的
  837. * @param type $resultType
  838. * @param type $gateId
  839. * @return type
  840. */
  841. static function subFunUnlock($resultType, $gateId) {
  842. $dic = GameConfig::subfun_unlock();
  843. foreach ($dic as $id => $mo) {
  844. if ($mo->type != 1) {
  845. continue;
  846. }
  847. if ($mo->unlockGateId == $gateId) {
  848. $tag = false;
  849. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  850. switch ($mo->unlockType) {
  851. case 1:
  852. if (ctx()->gates->GateList->$gateId->fightNum == 0) {
  853. $tag = true;
  854. }
  855. break;
  856. case 2:
  857. if ($resultType == true && ctx()->gates->GateList->$gateId->pass == 0) {
  858. $tag = true;
  859. }
  860. break;
  861. default:
  862. break;
  863. }
  864. if ($tag) {
  865. if (!StlUtil::dictHasProperty(ctx()->privateState->subFunStartTs, $id)) {
  866. ctx()->privateState->subFunStartTs->$id = now();
  867. }
  868. }
  869. }
  870. }
  871. }
  872. // </editor-fold>
  873. // <editor-fold defaultstate="collapsed" desc="技能解锁">
  874. /**
  875. * 检测技能解锁的 1 关卡解锁,游玩到一定关卡解锁技能
  876. * @param type $resultType
  877. * @param type $gateId
  878. * @return type
  879. */
  880. static function skillUnlock_gate($resultType, $gateId) {
  881. $dic = GameConfig::skills();
  882. $gateIndex = Ins_GateInfo::gateNum($gateId);
  883. foreach ($dic as $id => $mo) {
  884. if ($mo->unlock_acc_id_new == null) {
  885. continue;
  886. }
  887. $strList = explode(':', $mo->unlock_acc_id_new);
  888. $unlockType = $strList[0];
  889. $unlockId = $strList[1];
  890. if ($unlockType == 1 && $unlockId == $gateIndex && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  891. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  892. }
  893. }
  894. }
  895. /**
  896. * 检测技能解锁的 2://皮肤解锁,获取到人物解锁后对应皮肤技能
  897. * @param type $resultType
  898. * @param type $gateId
  899. * @return type
  900. */
  901. static function skillUnlock_heroUnlock($heroId) {
  902. $dic = GameConfig::skills();
  903. foreach ($dic as $id => $mo) {
  904. if ($mo->unlock_acc_id_new == null) {
  905. continue;
  906. }
  907. $strList = explode(':', $mo->unlock_acc_id_new);
  908. $unlockType = $strList[0];
  909. $unlockId = $strList[1];
  910. if ($unlockType != 2) {
  911. continue;
  912. }
  913. $heroMo = GameConfig::hero_getItem($heroId);
  914. $heroTypeId = $heroMo->typeID;
  915. $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
  916. if ($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  917. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  918. }
  919. }
  920. }
  921. /**
  922. * 检测技能解锁的 3://玩家失败X次后解锁
  923. * @param type $resultType
  924. * @param type $gateId
  925. * @return type
  926. */
  927. static function skillUnlock_fightNum($resultType) {
  928. if ($resultType) {
  929. return;
  930. }
  931. $GateList = ctx()->gates->GateList;
  932. $num = 0;
  933. foreach ($GateList as $gateId => $Ins_GateInfo) {
  934. $num += $Ins_GateInfo->fightNum_fail;
  935. }
  936. $dic = GameConfig::skills();
  937. foreach ($dic as $id => $mo) {
  938. if ($mo->unlock_acc_id_new == null) {
  939. continue;
  940. }
  941. $strList = explode(':', $mo->unlock_acc_id_new);
  942. $unlockType = $strList[0];
  943. $unlockId = $strList[1];
  944. if ($unlockType != 3) {
  945. continue;
  946. }
  947. if ($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  948. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  949. }
  950. }
  951. }
  952. /**
  953. * 玩家等级解锁技能
  954. * @param type $curLevel
  955. */
  956. static function skillUnlock_userLevel($curLevel) {
  957. $dic = GameConfig::skills();
  958. foreach ($dic as $id => $mo) {
  959. if ($mo->unlock_acc_id_new == null) {
  960. continue;
  961. }
  962. $strList = explode(':', $mo->unlock_acc_id_new);
  963. $unlockType = $strList[0];
  964. $unlockId = $strList[1];
  965. if ($unlockType != 5) { // 玩家等级
  966. continue;
  967. }
  968. if ($unlockId == $curLevel && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  969. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  970. }
  971. }
  972. }
  973. // </editor-fold>
  974. // <editor-fold defaultstate="collapsed" desc="排行榜">
  975. /**
  976. * 参与主线关卡排行榜
  977. * @param type $gateIndex
  978. */
  979. public static function Ranking_MainGateIndex($maxGateIndex) {
  980. $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
  981. $mem = gMem();
  982. $uid = req()->uid;
  983. $score = self::GetRankScoreUid($uid, 1);
  984. if ($maxGateIndex > $score) {
  985. $arr = array();
  986. $arr["$uid"] = self::createScore($maxGateIndex);
  987. $mem->zadd($memKey, $arr);
  988. }
  989. $length = $mem->zlen($memKey);
  990. if ($length > glc()->Rank_MainGateIndex_OnListRank) {
  991. $num = $length - glc()->Rank_MainGateIndex_OnListRank;
  992. $mem->zremrangebyrank($memKey, 0, $num - 1);
  993. }
  994. }
  995. public static function createScore($score) {
  996. if ($score > 0) {
  997. $newScore = $score . '.' . (9999999999 - now());
  998. return $newScore;
  999. }
  1000. return 0;
  1001. }
  1002. /**
  1003. * 战力榜
  1004. * @param type $gateIndex
  1005. */
  1006. public static function Ranking_FightPower() {
  1007. $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
  1008. $mem = gMem();
  1009. $uid = req()->uid;
  1010. $score = self::GetRankScoreUid($uid, 2);
  1011. $power = self::countUserFightPower();
  1012. if ($power > $score) {
  1013. $arr = array();
  1014. $arr["$uid"] = self::createScore($power);
  1015. $mem->zadd($memKey, $arr);
  1016. self::IsAchievedFightPower_PassReward($power);
  1017. }
  1018. $length = $mem->zlen($memKey);
  1019. if ($length > glc()->Rank_FightPower_OnListRank) {
  1020. $num = $length - glc()->Rank_FightPower_OnListRank;
  1021. $mem->zremrangebyrank($memKey, 0, $num - 1);
  1022. }
  1023. }
  1024. public static function GetRankScoreUid($uid_rank, $type) {
  1025. if ($type == 1) {
  1026. $score = gMem()->zscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid_rank);
  1027. } else {
  1028. $score = gMem()->zscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid_rank);
  1029. }
  1030. if ($score == null) {
  1031. $score = 0;
  1032. }
  1033. return intval($score);
  1034. }
  1035. /**
  1036. * 6811 获取主线关卡排行榜信息
  1037. * @return type
  1038. */
  1039. public static function GetRankInfo() {
  1040. list($type) = req()->paras;
  1041. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  1042. $selfExtraInfo = 0;
  1043. $isExistFinishReward = 0;
  1044. $isExistFinishReward_other = 0;
  1045. if ($type == 1) {
  1046. $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  1047. $selfExtraInfo = ctx()->gates->maxPassGateNumId();
  1048. $isExistFinishReward = self::isExistNoDrawed_MainGate();
  1049. $isExistFinishReward_other = self::isExistNoDrawed_FightPower();
  1050. } else {
  1051. $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1052. $selfExtraInfo = self::countUserFightPower();
  1053. $isExistFinishReward = self::isExistNoDrawed_FightPower();
  1054. $isExistFinishReward_other = self::isExistNoDrawed_MainGate();
  1055. }
  1056. if ($isExistFinishReward == 1) {
  1057. $isExistFinishReward = true;
  1058. } else {
  1059. $isExistFinishReward = false;
  1060. }
  1061. if ($isExistFinishReward_other == 1) {
  1062. $isExistFinishReward_other = true;
  1063. } else {
  1064. $isExistFinishReward_other = false;
  1065. }
  1066. $selfRank = null;
  1067. $retArr = array();
  1068. if (count($list) > 0) {
  1069. foreach ($list as $uid => $score) {
  1070. $rankInfo = self::initOtherUidRankInfo($uid, $score, $type);
  1071. if ($rankInfo->uid == req()->uid) {
  1072. $selfIsHasRank = 1;
  1073. $selfRank = $rankInfo;
  1074. }
  1075. $retArr[] = $rankInfo;
  1076. }
  1077. }
  1078. if ($selfRank == null) {
  1079. $selfRank = self::initOtherUidRankInfo(req()->uid, $selfExtraInfo, $type);
  1080. }
  1081. UserProc::updateUserInfo();
  1082. $ret = array(
  1083. 'rankInfo' => $retArr,
  1084. 'selfRank' => $selfRank,
  1085. 'selfIsHasRank' => $selfIsHasRank,
  1086. 'isExistFinishReward' => $isExistFinishReward,
  1087. 'isExistFinishReward_other' => $isExistFinishReward_other,
  1088. );
  1089. return Resp::ok($ret);
  1090. }
  1091. /**
  1092. * 初始化玩家rank
  1093. * @param type $uid
  1094. * @param type $score
  1095. * @return \loyalsoft\Ins_rank
  1096. */
  1097. static function initOtherUidRankInfo($uid, $score, $type = null) {
  1098. $ins_rank = new Ins_rank();
  1099. if ($type == 1) {
  1100. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  1101. } else {
  1102. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1103. }
  1104. if ($lv == null) {
  1105. $lv = 0;
  1106. }
  1107. $ins_rank->rank = $lv + 1;
  1108. $ins_rank->uid = $uid;
  1109. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  1110. $ins_rank->name = $userInfo->baseInfo->name;
  1111. $ins_rank->headImg = $userInfo->baseInfo->headImg;
  1112. //$ret = intval($score);
  1113. // if(!$isToRank){
  1114. // $ret = $score;
  1115. // }
  1116. $ins_rank->score = intval($score);
  1117. return $ins_rank;
  1118. }
  1119. /**
  1120. * 6812 获取排行榜内玩家的装备信息
  1121. * @return type
  1122. */
  1123. public static function GetUidEquipInfo_Rank() {
  1124. list($uid) = req()->paras;
  1125. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  1126. $store = $userInfo->store;
  1127. $heros = $userInfo->heros;
  1128. $gates = $userInfo->gates;
  1129. UserProc::updateUserInfo();
  1130. $ret = array(
  1131. 'store' => $store,
  1132. 'heros' => $heros,
  1133. 'gates' => $gates,
  1134. );
  1135. return Resp::ok($ret);
  1136. }
  1137. /**
  1138. * 通关奖励是否达成
  1139. * @param type $maxGateIndex
  1140. */
  1141. public static function IsAchievedMainGate_PassReward($maxGateIndex) {
  1142. $rewards = GameConfig::rank_passgatereward();
  1143. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1144. foreach ($rewards as $passGateId => $mo) {
  1145. if ($passGateId == $maxGateIndex && !gMem()->hexists($memKey, $maxGateIndex)) {
  1146. $ins_rank = new Ins_rank();
  1147. $ins_rank->uid = req()->uid;
  1148. $ins_rank->name = ctx()->baseInfo->name;
  1149. $ins_rank->headImg = ctx()->baseInfo->headImg;
  1150. $ins_rank->score = $passGateId;
  1151. gMem()->hset($memKey, $maxGateIndex, $ins_rank);
  1152. break;
  1153. }
  1154. }
  1155. }
  1156. /*
  1157. * 战力奖励是否达成
  1158. */
  1159. public static function IsAchievedFightPower_PassReward($power) {
  1160. $rewards = GameConfig::rank_fightpowerreward();
  1161. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1162. foreach ($rewards as $fightPower => $mo) {
  1163. if ($power >= $fightPower && !gMem()->hexists($memKey, $fightPower)) {
  1164. $ins_rank = new Ins_rank();
  1165. $ins_rank->uid = req()->uid;
  1166. $ins_rank->name = ctx()->baseInfo->name;
  1167. $ins_rank->headImg = ctx()->baseInfo->headImg;
  1168. $ins_rank->score = $fightPower;
  1169. gMem()->hset($memKey, $fightPower, $ins_rank);
  1170. }
  1171. }
  1172. }
  1173. public static function isExistNoDrawed_MainGate() {
  1174. $isExistFinishReward = 0;
  1175. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1176. $dic = gMem()->hgetall($memKey);
  1177. foreach ($dic as $gateId => $ins_rank) {
  1178. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1179. $isExistFinishReward = 1;
  1180. break;
  1181. }
  1182. }
  1183. ctx()->privateState->redTip_RewardMainGateRank = $isExistFinishReward;
  1184. return $isExistFinishReward;
  1185. }
  1186. public static function isExistNoDrawed_FightPower() {
  1187. $isExistFinishReward = 0;
  1188. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1189. $dic = gMem()->hgetall($memKey);
  1190. foreach ($dic as $fightPower => $ins_rank) {
  1191. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1192. $isExistFinishReward = 1;
  1193. break;
  1194. }
  1195. }
  1196. ctx()->privateState->redTip_RewardFightPowerRank = $isExistFinishReward;
  1197. return $isExistFinishReward;
  1198. }
  1199. /**
  1200. * 6813
  1201. * @return type
  1202. */
  1203. public static function GetmainGate_RankRewardInfo() {
  1204. //list($type) = req()->paras;
  1205. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1206. $dic = gMem()->hgetall($memKey);
  1207. if ($dic == null) {
  1208. $dic = new \stdClass();
  1209. }
  1210. UserProc::updateUserInfo();
  1211. $ret = array(
  1212. 'rankReward' => $dic,
  1213. );
  1214. return Resp::ok($ret);
  1215. }
  1216. /**
  1217. * 6814
  1218. * @return type
  1219. */
  1220. public static function GetFightPower_RankRewardInfo() {
  1221. //list($type) = req()->paras;
  1222. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1223. $dic = gMem()->hgetall($memKey);
  1224. if ($dic == null) {
  1225. $dic = new \stdClass();
  1226. }
  1227. UserProc::updateUserInfo();
  1228. $ret = array(
  1229. 'rankReward' => $dic,
  1230. );
  1231. return Resp::ok($ret);
  1232. }
  1233. /**
  1234. * 6815 领取通关荣誉榜奖励
  1235. * @return type
  1236. */
  1237. public static function ReceiveRankReward_MainGate() {
  1238. list($gateId) = req()->paras;
  1239. my_Assert(!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate), ErrCode::rankReward_HasReceive);
  1240. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  1241. my_Assert($mo != null, ErrCode::err_const_no);
  1242. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1243. if (gMem()->hexists($memKey, $gateId)) {
  1244. StoreProc::AddMultiItemInStore($mo->reward);
  1245. ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
  1246. TaskProc::OnRankPrize_Num();
  1247. }
  1248. $tag = self::isExistNoDrawed_MainGate();
  1249. UserProc::updateUserInfo();
  1250. $ret = array('redTip' => $tag, 'task' => ctx()->task, 'store' => ctx()->store, 'cash' => ctx()->baseInfo->cash, 'reward' => StoreProc::$reward);
  1251. return Resp::ok($ret);
  1252. }
  1253. /**
  1254. * 6816 领取战力荣誉榜奖励
  1255. * @return type
  1256. */
  1257. public static function ReceiveRankReward_FightPower() {
  1258. list($fightPower) = req()->paras;
  1259. my_Assert(!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower), ErrCode::rankReward_HasReceive);
  1260. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  1261. my_Assert($mo != null, ErrCode::err_const_no);
  1262. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1263. if (gMem()->hexists($memKey, $fightPower)) {
  1264. StoreProc::AddMultiItemInStore($mo->reward);
  1265. ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
  1266. TaskProc::OnFightRankPrize_Num();
  1267. }
  1268. $tag = self::isExistNoDrawed_FightPower();
  1269. UserProc::updateUserInfo();
  1270. $ret = array('redTip' => $tag, 'task' => ctx()->task, 'store' => ctx()->store, 'cash' => ctx()->baseInfo->cash, 'reward' => StoreProc::$reward);
  1271. return Resp::ok($ret);
  1272. }
  1273. /**
  1274. * 6824 排行奖励一键领取
  1275. */
  1276. static function ReceiveRankReward() {
  1277. list($type) = req()->paras; # 解锁数量
  1278. if ($type == 1) {
  1279. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1280. $dic = gMem()->hgetall($memKey);
  1281. foreach ($dic as $gateId => $ins_rank) {
  1282. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1283. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  1284. StoreProc::AddMultiItemInStore($mo->reward);
  1285. ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
  1286. TaskProc::OnRankPrize_Num();
  1287. }
  1288. }
  1289. } else {
  1290. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1291. $dic2 = gMem()->hgetall($memKey2);
  1292. foreach ($dic2 as $fightPower => $ins_rank) {
  1293. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1294. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  1295. StoreProc::AddMultiItemInStore($mo->reward);
  1296. ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
  1297. TaskProc::OnFightRankPrize_Num();
  1298. }
  1299. }
  1300. }
  1301. UserProc::updateUserInfo();
  1302. $ret = array('redTip' => 0,
  1303. 'task' => ctx()->task,
  1304. 'store' => ctx()->store,
  1305. 'cash' => ctx()->baseInfo->cash,
  1306. 'reward' => StoreProc::$reward,
  1307. 'rankReward_drawed_fightPower' => ctx()->privateState->rankReward_drawed_fightPower,
  1308. 'rankReward_drawed_MainGate' => ctx()->privateState->rankReward_drawed_MainGate,
  1309. );
  1310. return Resp::ok($ret);
  1311. }
  1312. /**
  1313. * 6817
  1314. */
  1315. public static function IsExistRankReward() {
  1316. //list($type) = req()->paras;
  1317. $type = 0;
  1318. $isExistFinishReward = false;
  1319. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1320. $dic = gMem()->hgetall($memKey);
  1321. foreach ($dic as $gateId => $ins_rank) {
  1322. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1323. $isExistFinishReward = true;
  1324. $type = 1;
  1325. break;
  1326. }
  1327. }
  1328. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1329. $dic2 = gMem()->hgetall($memKey2);
  1330. foreach ($dic2 as $fightPower => $ins_rank) {
  1331. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1332. $isExistFinishReward = true;
  1333. $type = 2;
  1334. break;
  1335. }
  1336. }
  1337. UserProc::updateUserInfo();
  1338. $ret = array(
  1339. 'isExistFinishReward' => $isExistFinishReward,
  1340. 'type' => $type,
  1341. );
  1342. return Resp::ok($ret);
  1343. }
  1344. /*
  1345. * 删除排行榜内注销账号的玩家
  1346. */
  1347. public static function DeleteRankInvalidUser($uid2) {
  1348. $dic1 = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  1349. foreach ($dic1 as $uid => $score) {
  1350. if ($uid == $uid2) {
  1351. gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  1352. break;
  1353. }
  1354. }
  1355. $dic2 = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1356. foreach ($dic2 as $uid => $score) {
  1357. if ($uid == $uid2) {
  1358. gMem()->zrem(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1359. break;
  1360. }
  1361. }
  1362. }
  1363. /*
  1364. * 排行玩家修改昵称
  1365. */
  1366. public static function UpdateRankUserName($uid, $newName) {
  1367. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1368. $dic = gMem()->hgetall($memKey1);
  1369. foreach ($dic as $gateId => $ins_rank) {
  1370. if ($ins_rank->uid == $uid) {
  1371. $ins_rank->name = $newName;
  1372. gMem()->hset($memKey1, $gateId, $ins_rank);
  1373. }
  1374. }
  1375. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1376. $dic2 = gMem()->hgetall($memKey2);
  1377. foreach ($dic2 as $fightPower => $ins_rank) {
  1378. if ($ins_rank->uid == $uid) {
  1379. $ins_rank->name = $newName;
  1380. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1381. }
  1382. }
  1383. }
  1384. /*
  1385. * 排行玩家头像变动
  1386. */
  1387. public static function UpdateRankUserHeadImg($uid, $headImg) {
  1388. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1389. $dic = gMem()->hgetall($memKey1);
  1390. foreach ($dic as $gateId => $ins_rank) {
  1391. if ($ins_rank->uid == $uid) {
  1392. $ins_rank->headImg = $headImg;
  1393. gMem()->hset($memKey1, $gateId, $ins_rank);
  1394. }
  1395. }
  1396. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1397. $dic2 = gMem()->hgetall($memKey2);
  1398. foreach ($dic2 as $fightPower => $ins_rank) {
  1399. if ($ins_rank->uid == $uid) {
  1400. $ins_rank->headImg = $headImg;
  1401. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1402. }
  1403. }
  1404. }
  1405. /*
  1406. * 统计战力 战斗力=攻击x(生命-伤害减免值)x(1+暴击率/100x(暴击伤害倍率-1))改为 //战斗力=攻击x(生命-伤害减免值)x(1+暴击率 x(暴击伤害倍率-1))2024-8-30
  1407. */
  1408. public static function countUserFightPower() {
  1409. $CurrentHeroId = ctx()->heros->CurrentHeroId;
  1410. //$hero = ctx()->heros->Dic->$CurrentHeroId;
  1411. list($addHp, $addAtk, $addDecDamage, $addEatFood) = ctx()->gates()->GetEnvovleBuffs(); // 启灵加成
  1412. $mo = GameConfig::hero_getItem($CurrentHeroId);
  1413. my_Assert($mo != null, ErrCode::err_const_no);
  1414. $heroBashAttack = $mo->attack;
  1415. $heroBashHp = $mo->hp;
  1416. $equipDic = ctx()->store->equip;
  1417. $attck = 0;
  1418. $hp = 0;
  1419. foreach ($equipDic as $index => $ins_equip) {
  1420. $Ins_Equip = new Ins_Equip($ins_equip);
  1421. if ($Ins_Equip->mo()->upgradeType == 1) {//攻击力
  1422. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1423. } elseif ($Ins_Equip->mo()->upgradeType == 2) {
  1424. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1425. } else {
  1426. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1427. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1428. }
  1429. }
  1430. $heroAttck = $heroBashAttack + $attck + $addAtk; # 英雄基础攻击力+装备宝石词条攻击力+启灵攻击力
  1431. $heroHp = $heroBashHp + $hp + $addHp; # 英雄基础hp + 装备宝石词条hp + 启灵hp
  1432. $pag = ctx()->store->equipPag;
  1433. $gemDic = ctx()->store->gemEquip->$pag; //Dictionary<E_EquipPosition, Dictionary<int, Ins_Gem>>
  1434. $per = 0;
  1435. $parasVal = 0;
  1436. $per_hp = 0;
  1437. $parasVal_hp = 0;
  1438. foreach ($equipDic as $index => $ins_equip) {
  1439. if (StlUtil::dictHasProperty($gemDic, $index)) {
  1440. $dic = $gemDic->$index;
  1441. foreach ($dic as $k => $gem) {
  1442. $ins_Gem = new Ins_Gem($gem);
  1443. if ($ins_Gem->predicateMo()->actionType == "mulDamage") {
  1444. $per += $ins_Gem->predicateMo()->actionParam1;
  1445. } elseif ($ins_Gem->predicateMo()->actionType == "addDamage") {
  1446. $parasVal += $ins_Gem->predicateMo()->actionParam1;
  1447. } elseif ($ins_Gem->predicateMo()->actionType == "mulHp") {
  1448. $per_hp += $ins_Gem->predicateMo()->actionParam1;
  1449. } elseif ($ins_Gem->predicateMo()->actionType == "addHp") {
  1450. $parasVal_hp += $ins_Gem->predicateMo()->actionParam1;
  1451. }
  1452. }
  1453. }
  1454. }
  1455. if ($per != 0) {
  1456. $heroAttck = round($heroAttck + $heroAttck * $per);
  1457. }
  1458. if ($parasVal != 0) {
  1459. $heroAttck += $parasVal;
  1460. }
  1461. if ($per_hp != 0) {
  1462. $heroHp = round($heroHp + $heroHp * $per_hp);
  1463. }
  1464. if ($parasVal_hp != 0) {
  1465. $heroHp += $parasVal_hp;
  1466. }
  1467. $dec_demage = $mo->dec_demage + $addDecDamage; # 英雄基础减伤 + 启灵减伤
  1468. $bigHit_Val = $mo->bigHit_Val;
  1469. $bigHit_rate = $mo->bigHit_rate;
  1470. $val = $heroAttck * ($heroHp - $dec_demage) * (1 + $bigHit_rate * ($bigHit_Val - 1));
  1471. return intval($val);
  1472. }
  1473. // </editor-fold>
  1474. }