FightProc.php 71 KB

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