FightProc.php 68 KB

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