FightProc.php 66 KB

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