FightProc.php 66 KB

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