FightProc.php 66 KB

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