FightProc.php 69 KB

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