FightProc.php 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272
  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. case CmdCode::fight_WorldBoss_rankInfo: # 6826 世界boss的排名信息
  66. return self::GetWorldBoss_RankInfo();
  67. case CmdCode::fight_WorldBoss_getRankDamageVal: # 6827 当前轮次下 自己的最高伤害值
  68. return self::GetWorldBoss_RankDamageVal();
  69. case CmdCode::fight_WorldBoss_getSelfRank: # 6828 获取自己的排名信息
  70. return self::GetWorldBoss_GetSelfRank();
  71. case CmdCode::fight_WorldBoss_claimRewards: # 6829 领取奖励
  72. return self::GetWorldBoss_ClaimRewards();
  73. case CmdCode::fight_WorldBoss_settle: # 6830 世界boss结算
  74. return self::WorldBoss_settle();
  75. default:
  76. Err(ErrCode::cmd_err);
  77. }
  78. }
  79. /**
  80. * 6825 pvp 匹配一个对手
  81. * @return Resp
  82. */
  83. static function PvpMatchPlayer() {
  84. // 先从排行榜上随机取一个玩家的数据返回 -gwang 2024.10.30
  85. // $uid = req()->uid;
  86. $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
  87. $mem = gMem();
  88. $length = $mem->zlen($memKey);
  89. if ($length > glc()->Rank_FightPower_OnListRank) {
  90. $length = glc()->Rank_FightPower_OnListRank;
  91. }
  92. $arr = $mem->zrange($memKey, 0, $length - 1);
  93. $uid = $arr[array_rand($arr)]; # 这里是否应该去掉自己呢? 算了不用,自己打自己也是一种挑战
  94. $pvpPlayer = UserProc::getUserGame(req()->zoneid, $uid);
  95. return Resp::ok($pvpPlayer);
  96. }
  97. /**
  98. * 6823 购买更多技能封印数量
  99. */
  100. static function BuySkillLockCount() {
  101. list($n) = req()->paras; # 解锁数量
  102. my_Assert($n > ctx()->privateData()->skillLockerNumber, ErrCode::paras_err); # 参数异常
  103. $amt = 0;
  104. foreach (explode(",", glc()->Skill_LockBtn_BuyCount_Cost) as $str) {
  105. list($cnt, $cost) = explode(':', $str);
  106. if ($cnt == $n) {
  107. $amt = $cost;
  108. break;
  109. }
  110. }
  111. my_Assert($amt > 0, "消耗元宝数量配置出错!");
  112. my_Assert(ctx()->base(true)->Consume_Cash($amt), ErrCode::notenough_cash_msg);
  113. ctx()->privateData(true)->skillLockerNumber = $cnt;
  114. UserProc::updateUserInfo();
  115. return Resp::ok();
  116. }
  117. /**
  118. * 6822 封印/解封技能
  119. */
  120. static function LockSkill() {
  121. list($skillTypeId) = req()->paras; # 技能类型ID
  122. $pri = ctx()->privateData(true);
  123. // my_Assert(in_array($skillTypeId, $pri->skillUnlockRecord), "技能尚未解锁!");
  124. if (in_array($skillTypeId, $pri->skillReLocked)) { # 解封
  125. StlUtil::arrayRemove($pri->skillReLocked, $skillTypeId);
  126. } else { # 封印
  127. my_Assert(count($pri->skillReLocked) < $pri->skillLockerNumber, "超出封印上限!");
  128. $pri->skillReLocked[] = $skillTypeId;
  129. TaskProc::OnCloseSkill();
  130. }
  131. return Resp::ok(array("task" => ctx()->task,));
  132. }
  133. /**
  134. * 6821 每天重置挑战红点
  135. */
  136. static function ResetChallange_RedMask() {
  137. ctx()->privateData(true)->challange_RedMask = 1;
  138. UserProc::updateUserInfo();
  139. return Resp::ok();
  140. }
  141. /**
  142. * 6819 主线挑战 -- 通关
  143. */
  144. static function MainTZPass() {
  145. list($gateId, $index, $killMonsterNum, $killBossNum) = req()->paras; # 关卡id, 通关难度索引(1/2/3)
  146. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  147. // isEditor() && $gateInfo = new Ins_GateInfo();
  148. $gateInfo = ctx()->gates->GateList->$gateId;
  149. my_Assert($gateInfo->pass, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
  150. // my_Assert($gateInfo->tz_state + 1 >= $index, ErrCode::gate_GateNoUnlock); # 通关上一难度解锁当前难度
  151. FightProc::funUnlock_mainChallengeGate_State(true, $gateId, $index);
  152. $gateInfo->tz_state = $index;
  153. TaskProc::OnPassMainChallengeGate_X_Num($gateId, $index);
  154. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  155. TaskProc::OnKillleaderNumMonster($killBossNum);
  156. //TaskProc::Day7TaskReset();
  157. UserProc::updateUserInfo();
  158. return Resp::ok(array("task" => ctx()->task,
  159. 'privateState' => ctx()->privateState,
  160. // 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  161. // 'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
  162. ));
  163. }
  164. /**
  165. * 6820 主线挑战 -- 领取奖励
  166. */
  167. static function MainTZGetReward() {
  168. list($gateId, $index) = req()->paras; # 关卡id, 通关难度索引(1/2/3)
  169. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  170. // isEditor() && $gateInfo = new Ins_GateInfo();
  171. $gateInfo = ctx()->gates->GateList->$gateId;
  172. my_Assert($gateInfo->pass, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
  173. my_Assert($gateInfo->tz_state >= $index, ErrCode::gate_GateNoUnlock); # 已解锁当前难度
  174. my_Assert(Bits::GetBitValue($gateInfo->tz_rewards, $index - 1) == false, ErrCode::gate_GatePriceHasReceive);
  175. $gateInfo->tz_rewards = Bits::SetBitValue($gateInfo->tz_rewards, $index - 1, true); # 更新领取记录
  176. $prize = "tz_reward" . $index;
  177. $mo = GameConfig::gate_getItem($gateId);
  178. StoreProc::AddMultiItemInStore($mo->$prize);
  179. UserProc::updateUserInfo();
  180. return Resp::ok(array(
  181. 'gold' => ctx()->baseInfo->gold,
  182. 'cash' => ctx()->baseInfo->cash,
  183. 'store' => ctx()->store,
  184. 'reward' => StoreProc::$reward,
  185. 'reward_Gem' => StoreProc::$reward_Gem,
  186. 'reward_equip' => StoreProc::$reward_equip,
  187. ));
  188. }
  189. /**
  190. * 6818 启灵解锁
  191. * @return type
  192. */
  193. public static function EvolveUnlock() {
  194. list($type, $id) = req()->paras; //$id废弃 因为玩家可能不安顺序点
  195. if ($type == 1) {
  196. $nextId = ctx()->gates->evolveMaxId_left + 1;
  197. my_Assert($id == $nextId, ErrCode::err_const_no);
  198. $mo = GameConfig::evolve_getItem($nextId);
  199. my_Assert($mo != null, ErrCode::err_const_no);
  200. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  201. my_Assert(ctx()->baseInfo->gold >= $mo->needGold_unlock, ErrCode::notenough_gold_msg);
  202. ctx()->baseInfo->Consume_Gold($mo->needGold_unlock);
  203. ctx()->gates->evolveMaxId_left = $nextId;
  204. GuideProc::Shop_Guide_Trigger(ctx()->gates->evolveMaxId_left);
  205. TaskProc::OnCompleteNumQiLing();
  206. } else {
  207. $nextId = ctx()->gates->evolveMaxId_right + 1;
  208. my_Assert($id == $nextId, ErrCode::err_const_no);
  209. $dic = GameConfig::evolve();
  210. foreach ($dic as $key => $value) {
  211. if ($value->specificEvolveId == $nextId) {
  212. $mo = $value;
  213. }
  214. }
  215. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  216. my_Assert($mo != null, ErrCode::err_const_no);
  217. if ($mo->specificEvolveCost != null) {
  218. $cost = explode(',', $mo->specificEvolveCost);
  219. $costId = $cost[0];
  220. $costNum = $cost[1];
  221. my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $costId) && ctx()->store->items->$costId >= $costNum, ErrCode::notenough_item);
  222. ctx()->store->removeItem($costId, $costNum);
  223. }
  224. ctx()->gates->evolveMaxId_right = $id;
  225. TaskProc::OnCompleteNumSpecialQiLing();
  226. }
  227. FightProc::Ranking_FightPower();
  228. UserProc::updateUserInfo();
  229. $ret = array(
  230. 'task' => ctx()->task,
  231. 'gold' => ctx()->baseInfo->gold,
  232. 'items' => ctx()->store->items,
  233. 'evolveMaxId_right' => ctx()->gates->evolveMaxId_right,
  234. 'evolveMaxId_left' => ctx()->gates->evolveMaxId_left,
  235. );
  236. return Resp::ok($ret);
  237. }
  238. /**
  239. * 6807 扫荡
  240. * @return type
  241. */
  242. public static function FightSweep() {
  243. //list($gateId) = req()->paras;
  244. // 2024.12.17 扫荡修改: 前3次免费, 后面可以一直看广告免费.(特权月卡可以免广告, 结合到一起, 特权月卡就可以一直刷了.)
  245. $passGateId = ctx()->gates->maxPassGateId(); # 最高通关关卡id
  246. my_Assert($passGateId != 0, ErrCode::gate_NoSweep); # 还没有通关关卡
  247. $mo = GameConfig::gate_getItem($passGateId); # 关卡配置数据
  248. my_Assert(null != $mo, ErrCode::err_const_no); # 防御: 关卡配置找不到
  249. $gateName = $mo->gateName;
  250. $costTili = glc()->sweep_cost_tili;
  251. $curTili = ctx()->baseInfo->CurTili();
  252. my_Assert($curTili >= $costTili, ErrCode::notenough_tili); # 检查: 体力不足
  253. # 2024.12.17 去掉了次数限制, 故这段废弃
  254. // if (ctx()->privateState->honourCardShop_ts == 0) {
  255. // $max = glc()->sweepMaxNum;
  256. // my_Assert(ctx()->gates->fightSweepNum < $max, ErrCode::gate_SweepMaxNum_limit);
  257. // }
  258. if (ctx()->gates->fightSweepNum < glc()->sweepMaxNum) {
  259. ctx()->gates->fightSweepTs = now(); # 前三次无冷却
  260. } else {
  261. ctx()->gates->fightSweepTs = now(60); # 下次扫荡时间戳(广告时需要间隔)
  262. }
  263. ctx()->gates->fightSweepNum += 1; # 增加扫荡次数记录
  264. ctx()->baseInfo->Consume_tili($costTili); # 扣除体力
  265. ctx()->privateData(true)->battlePass_tili += $costTili; # 增加体力消耗记录
  266. # 发放扫荡奖励↓
  267. $wavesArr = GameConfig::waves_getItemArray($passGateId);
  268. $count = count($wavesArr);
  269. $wavesMo = $wavesArr[$count - 1];
  270. $gold = $wavesMo->rewardGold;
  271. StoreProc::AddMultiItemInStore("1," . $gold);
  272. $oldLevel = ctx()->baseInfo->level;
  273. $exp = $wavesMo->rewardExp;
  274. StoreProc::AddMultiItemInStore("4," . $exp);
  275. $newLevel = ctx()->baseInfo->level;
  276. if ($wavesMo->rewardTuZhi != null) {
  277. $tuzhi = explode('-', $wavesMo->rewardTuZhi);
  278. $n = rand($tuzhi[0], $tuzhi[1]);
  279. $tuzhiArr = array();
  280. $item = GameConfig::item();
  281. foreach ($item as $id => $mo) {
  282. if ($mo->itemType == 100) {
  283. $tuzhiArr[] = $id;
  284. }
  285. }
  286. for ($i = 0; $i < $n; $i++) {
  287. $index = rand(0, count($tuzhiArr) - 1);
  288. $goodsStr = $tuzhiArr[$index] . ',' . 1;
  289. $prizeArr[] = $goodsStr;
  290. StoreProc::AddMultiItemInStore($goodsStr);
  291. }
  292. }
  293. if ($wavesMo->rewardItem != null) {
  294. $reward = StoreProc::Distribute_Rewards($wavesMo->rewardItem);
  295. StoreProc::AddMultiItemInStore($reward);
  296. }
  297. if ($wavesMo->rewardGem != null) {
  298. $goodsStr = self::sweepRandReward($wavesMo->rewardGem);
  299. $str = explode(';', $goodsStr);
  300. $dic = GameConfig::gem();
  301. foreach ($str as $value) {
  302. $list = explode(',', $value);
  303. $posId = rand(1, 6);
  304. $qual = $list[0];
  305. foreach ($dic as $key => $gemMo) {
  306. if ($gemMo->qual == $qual && $gemMo->position == $posId && $gemMo->isfixed_predicateId == 0) {
  307. $gemStr = $gemMo->typeId . ',' . $list[1];
  308. SystemProc::GetGem_GreaterOrangeQual_SweepMainGateIndex(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($passGateId), $gateName, $gemMo->typeId);
  309. //StoreProc::PutGemInStore($gemMo->typeId, $list[1]);
  310. StoreProc::AddMultiItemInStore($gemStr);
  311. break;
  312. }
  313. }
  314. }
  315. }
  316. # 奖励逻辑结束.
  317. TaskProc::OnFightSweepGate();
  318. UserProc::updateUserInfo();
  319. $ret = array(
  320. 'gold' => ctx()->baseInfo->gold,
  321. 'cash' => ctx()->baseInfo->cash,
  322. 'tili' => ctx()->baseInfo->tili,
  323. 'tili_ts' => ctx()->baseInfo->tili_ts,
  324. 'xp' => ctx()->baseInfo->xp,
  325. 'maxXp' => ctx()->baseInfo->maxXp,
  326. 'level' => ctx()->baseInfo->level,
  327. 'fightSweepNum' => ctx()->gates->fightSweepNum,
  328. 'fightSweepTs' => ctx()->gates->fightSweepTs,
  329. //'prizeArr' => $prizeArr,
  330. 'store' => ctx()->store,
  331. 'task' => ctx()->task,
  332. 'reward' => StoreProc::$reward,
  333. 'reward_Gem' => StoreProc::$reward_Gem,
  334. 'reward_equip' => StoreProc::$reward_equip,
  335. 'oldLevel' => $oldLevel,
  336. 'newLevel' => $newLevel,
  337. );
  338. return Resp::ok($ret);
  339. }
  340. static function sweepRandReward($rewardStr) {
  341. $ctxArr = explode(';', $rewardStr);
  342. $numArr = explode('-', $ctxArr[0]);
  343. $num = rand($numArr[0], $numArr[1]);
  344. $rand = 0;
  345. $itemArr = explode(',', $ctxArr[1]);
  346. foreach ($itemArr as $value) {
  347. $arr = explode(':', $value);
  348. $itemId = $arr[0];
  349. $per = $arr[1];
  350. $rand += $per;
  351. }
  352. $res = "";
  353. for ($i = 0; $i < $num; $i++) {
  354. $start = 0;
  355. $end = 0;
  356. $randNum = rand(1, $rand);
  357. $id = 0;
  358. foreach ($itemArr as $str) {
  359. $arr = explode(':', $str);
  360. $itemId = $arr[0];
  361. $per = $arr[1];
  362. $end += $per;
  363. if ($randNum > $start && $randNum <= $end) {
  364. $id = $itemId;
  365. break;
  366. }
  367. $start = $end;
  368. }
  369. if ($id != 0) {
  370. $str = $id . ',1';
  371. if ($res == "") {
  372. $res = $str;
  373. } else {
  374. $res = $res . ';' . $str;
  375. }
  376. }
  377. }
  378. return $res;
  379. }
  380. /**
  381. * 6808 开始挑战 (主线关卡:扣除体力, 挑战关卡: 增加次数)
  382. */
  383. private static function StartFight() {
  384. list($gateId, $layerNum) = req()->paras;
  385. my_Assert($gateId > 0, ErrCode::paras_err);
  386. $mo = GameConfig::gate_getItem($gateId);
  387. my_Assert(null != $mo, ErrCode::err_const_no);
  388. if (Ints::Slice($gateId, 0, 1) == 9) { # 爬塔模式
  389. // list($layerNum) = req()->paras;
  390. if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) { # --起始层数校验
  391. Err(ErrCode::tower_layerNum);
  392. }
  393. if (ctx()->gates()->TowerGateInfo()->TodayChanNum < 1) { # --剩余次数校验
  394. Err(ErrCode::tower_timeNo);
  395. }
  396. ctx()->gates()->TowerGateInfo()->TodayChanNum--; # --增加次数
  397. } else if (Ints::Slice($gateId, 0, 1) == 8) { # 兔羊模式
  398. // nothing todo 临时
  399. } else { # 主线剧情
  400. my_Assert(ctx()->base(true)->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
  401. ctx()->privateData(true)->battlePass_tili += $mo->cost_tili;
  402. }
  403. UserProc::updateUserInfo();
  404. return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
  405. }
  406. /**
  407. * 战斗模块 - 每日清理变量
  408. */
  409. public static function FightDailyClear() {
  410. //ctx()->gates->xunluo_quick_buyRecord = 0;
  411. ctx()->gates->fightSweepNum = 0;
  412. ctx()->gates->fightSweepTs = now();
  413. ctx()->gates()->TowerGateInfo()->RefreshSkillTimes = 0;
  414. ctx()->gates()->TowerGateInfo()->TodayChanNum = glc()->tower_daily_chanceNum;
  415. ctx()->privateState->challange_RedMask = 0;
  416. }
  417. /**
  418. * 6806 剧情回存
  419. * @return type
  420. */
  421. public static function PlotSav() {
  422. list($gateId) = req()->paras;
  423. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no);
  424. ctx()->gates->GateList->$gateId->plotStart = 1;
  425. UserProc::updateUserInfo();
  426. $ret = array(
  427. 'ok' => 1,
  428. );
  429. return Resp::ok($ret);
  430. }
  431. // <editor-fold defaultstate="collapsed" desc="挑战模块">
  432. /**
  433. * 6810 挑战关卡: 更新锁定技能列表
  434. */
  435. public static function TowerUpdateLockskillList() {
  436. list($li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  437. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  438. $t->skill_zhudong = $li_zd;
  439. $t->skill_beidong = $li_bd;
  440. $t->skill_zhudong_lockState = $li_zds;
  441. $t->skill_beidong_lockState = $li_bds;
  442. UserProc::updateUserInfo();
  443. return Resp::ok();
  444. }
  445. /**
  446. * 6809 挑战关卡: 刷新初始技能(扣除免费次数/cost)
  447. */
  448. public static function TowerRefreshSkills() {
  449. list($isFree, $li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  450. if ($isFree) {
  451. if (ctx()->gates()->TowerGateInfo()->RefreshSkillTimes > glc()->tower_daily_refreshChanceNum) {
  452. Err(ErrCode::tower_refreshNo); # 免费次数不足
  453. }
  454. } else {
  455. list($type, $num) = explode(':', glc()->tower_refreshCost); # 二级货币类型(1:金币,2:元宝):数量
  456. if ($type == 1) { # 金币
  457. my_Assert(ctx()->base(true)->Consume_Gold($num), ErrCode::notenough_gold_msg);
  458. } else if ($type == 2) { # 元宝
  459. my_Assert(ctx()->base(true)->Consume_Cash($num), ErrCode::notenough_cash_msg);
  460. } else {
  461. Err(ErrCode::err_const_no, "检查刷新扣费配置信息!");
  462. }
  463. }
  464. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  465. $t->RefreshSkillTimes++;
  466. $t->skill_zhudong = $li_zd;
  467. $t->skill_beidong = $li_bd;
  468. $t->skill_zhudong_lockState = $li_zds;
  469. $t->skill_beidong_lockState = $li_bds;
  470. UserProc::updateUserInfo();
  471. $ret = array(
  472. 'task' => ctx()->task,
  473. );
  474. return Resp::ok($ret);
  475. }
  476. /**
  477. * 6805 战斗: 复活花费
  478. * @return type
  479. * @version 2024年5月17日 重整利用为复活扣除消耗功能
  480. */
  481. public static function ReliveCost() {
  482. // 复活可以扣除复活币(暂无)或者元宝,(客户端看广告复活不需要跟服务器通讯)
  483. list($reliveNum) = req()->paras;
  484. $arr = explode(',', glc()->Relive_cost);
  485. my_Assert($reliveNum >= 0 && $reliveNum <= Count($arr), ErrCode::paras_err); # 参数范围>0
  486. $amt = $arr[$reliveNum];
  487. my_Assert(ctx()->base(true)->Consume_Cash($amt), ErrCode::notenought_yuanbao);
  488. UserProc::updateUserInfo();
  489. return Resp::ok();
  490. }
  491. /**
  492. * 6804 挑战关卡: 奖励领取
  493. * @return type
  494. */
  495. public static function GateChallengeRewards() {
  496. list($finalLayer, $killedMonster, $killedBoss) = req()->paras; # 战斗结束时的层数
  497. $lastLayer = ctx()->gates()->TowerGateInfo()->CurLayer;
  498. $arr = GameConfig::waves_getItemArray(glc()->TowerGateId);
  499. TaskProc::OnFightNumChallengeGate();
  500. TaskProc::OnKillCommonNumMonster($killedMonster);
  501. TaskProc::OnKillleaderNumMonster($killedBoss);
  502. if ($finalLayer > $lastLayer) {
  503. foreach ($arr as $layerId => $layerMo) {
  504. if ($layerMo->waveId >= $lastLayer && $layerMo->waveId < $finalLayer) {
  505. my_Assert($layerMo != null, ErrCode::err_const_no);
  506. StoreProc::AddMultiItemInStore($layerMo->rewards); # 发放奖励
  507. }
  508. }
  509. ctx()->gates()->TowerGateInfo()->CurLayer = $finalLayer;
  510. TaskProc::OnPassLayer_ChallengeGate($finalLayer - 1);
  511. UserProc::updateUserInfo();
  512. $ret = array(
  513. 'store' => ctx()->store,
  514. 'gold' => ctx()->base()->gold,
  515. 'cash' => ctx()->base()->cash,
  516. 'task' => ctx()->task,
  517. );
  518. return Resp::ok($ret);
  519. } else if ($finalLayer == $lastLayer) {
  520. $ret = array(
  521. 'store' => ctx()->store,
  522. 'gold' => ctx()->base()->gold,
  523. 'cash' => ctx()->base()->cash,
  524. 'task' => ctx()->task,
  525. );
  526. return Resp::ok($ret);
  527. }
  528. return Resp::err(ErrCode::tower_rewardNo); # 没有奖励
  529. }
  530. // </editor-fold>
  531. /**
  532. * 6803 关卡选择
  533. * @return type
  534. */
  535. public static function SelectGate() {
  536. list($gateId) = req()->paras;
  537. ctx()->gates->CurrentGateId = $gateId;
  538. UserProc::updateUserInfo();
  539. $ret = array(
  540. 'gates' => ctx()->gates,
  541. );
  542. return Resp::ok($ret);
  543. }
  544. /**
  545. * 6802 章节宝箱的领取
  546. * @return type
  547. */
  548. public static function PassGateTsPrizeReceive() {
  549. list($gateId, $index) = req()->paras;
  550. $gateMo = GameConfig::gate_getItem($gateId);
  551. my_Assert($gateMo != null, ErrCode::err_const_no);
  552. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  553. $gateInfo = ctx()->gates->GateList->$gateId;
  554. $tag = false;
  555. $prize = "";
  556. $mask = 0;
  557. switch ($index) {
  558. case 1:
  559. $ts = $gateMo->first_ts1 * 60;
  560. if ($gateInfo->MaxSeconds >= $ts || $gateInfo->pass > 0) {
  561. $tag = true;
  562. }
  563. $mask = 1;
  564. $prize = $gateMo->first_reward1;
  565. break;
  566. case 2:
  567. $ts = $gateMo->first_ts2 * 60;
  568. if ($gateInfo->MaxSeconds >= $ts || $gateInfo->pass > 0) {
  569. $tag = true;
  570. }
  571. $mask = 2;
  572. $prize = $gateMo->first_reward2;
  573. break;
  574. case 3:
  575. if ($gateInfo->pass > 0) {
  576. $tag = true;
  577. }
  578. $mask = 3;
  579. $prize = $gateMo->first_reward3;
  580. break;
  581. default:
  582. break;
  583. }
  584. if ($tag) {
  585. my_Assert(!in_array($mask, $gateInfo->FirstReward), ErrCode::gate_GatePriceHasReceive);
  586. $gateInfo->FirstReward[] = $mask;
  587. GuideProc::HeroChange_Guide_Trigger($gateId, $index);
  588. StoreProc::AddMultiItemInStore($prize);
  589. }
  590. ctx()->gates->GateList->$gateId = $gateInfo;
  591. TaskProc::OnReceiveGateBoxReward();
  592. UserProc::updateUserInfo();
  593. $ret = array(
  594. 'gates' => ctx()->gates,
  595. 'store' => ctx()->store,
  596. 'task' => ctx()->task,
  597. 'gold' => ctx()->baseInfo->gold,
  598. 'cash' => ctx()->baseInfo->cash,
  599. 'reward' => StoreProc::$reward,
  600. 'reward_Gem' => StoreProc::$reward_Gem,
  601. 'reward_equip' => StoreProc::$reward_equip,
  602. 'heros' => ctx()->heros,
  603. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  604. 'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
  605. 'funUnlockRecord_3' => ctx()->privateState->funUnlockRecord_3,
  606. );
  607. return Resp::ok($ret);
  608. }
  609. /**
  610. * [6801]关卡战斗结算
  611. * @return type
  612. */
  613. public static function Settle() {
  614. list($resultType, $gateId, $gold, $curTs, $pickups,
  615. $finalLayer, $finalHpPercent, $killMonsterNum, $killBossNum,
  616. $finalLevel, $reliveNum) = req()->paras;
  617. # 客户端需要增加参数: killmonserNum,killBosssNum, finalHpPercent(最终血量百分比)
  618. $gateMo = GameConfig::gate_getItem($gateId);
  619. my_Assert($gateMo != null, ErrCode::err_const_no);
  620. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  621. $gateInfo = ctx()->gates->GateList->$gateId;
  622. $ts = $gateInfo->MaxSeconds;
  623. if ($curTs >= $ts) {
  624. $gateInfo->MaxSeconds = $curTs;
  625. }
  626. self::funUnlock_Gate($resultType, $gateId); //备注:这个接口的位置不能动 里面有关卡第一次胜利解锁的功能提示校验
  627. //self::subFunUnlock($resultType, $gateId);
  628. if ($resultType) { # 胜利
  629. self::skillUnlock_gate($resultType, $gateId); //备注 这个接口位置不能动
  630. GuideProc::GateBoxReceived_Guide_Trigger($gateId, 1);
  631. if (ctx()->gates->GateList->$gateId->pass == 0) {
  632. ctx()->gates->GateList->$gateId->pass = 1;
  633. $maxGateId = ctx()->gates->maxPassGateNumId();
  634. if ($maxGateId > 0) {
  635. self::Ranking_MainGateIndex($maxGateId);
  636. self::IsAchievedMainGate_PassReward($maxGateId);
  637. }
  638. }
  639. TaskProc::OnPassGate_X($gateId); # 刷新任务进度: 通关第X关
  640. TaskProc::OnPassGate_X_state($gateId);
  641. if (Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate) {
  642. ctx()->gates()->UnlockNextPlotGate($gateId); # 解锁下一主线关卡
  643. // ctx()->gates()->UnlockMainChallengeGate($gateId); # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  644. } else { # 不是主线关卡, 暂时没有其他逻辑
  645. }
  646. // StoreProc::AddMultiItemInStore($gateMo->reward_win); # 发放胜利奖励(2024.5.30 过期)
  647. } else {
  648. ctx()->gates->GateList->$gateId->fightNum_fail += 1;
  649. self::skillUnlock_fightNum($resultType); //这个接口位置不能动
  650. }
  651. // else { # 失败
  652. //// StoreProc::AddMultiItemInStore($gateMo->reward_fail); # 发放失败奖励(2024.5.30 过期)
  653. // }
  654. StoreProc::AddMultiItemInStore($pickups); # 战场拾取道具直接入背包
  655. //ctx()->base()->Add_Gold($gold); # 战场拾取的金币直接入背包
  656. //ctx()->base()->Add_Exp($exp);
  657. $waveMo = GameConfig::waveItem_getItem($gateId, $finalLayer);
  658. my_Assert(null != $waveMo, ErrCode::err_const_no);
  659. $oldLevel = ctx()->baseInfo->level;
  660. StoreProc::AddMultiItemInStore('4,' . $waveMo->rewardExp);
  661. //ctx()->base()->Add_Exp($waveMo->rewardExp); # 指挥官经验
  662. $newLevel = ctx()->baseInfo->level;
  663. if ($oldLevel != $newLevel) {
  664. ctx()->privateData(true)->oldLevel = $oldLevel;
  665. ctx()->privateData(true)->upLevel = $newLevel;
  666. }
  667. //ctx()->base()->Add_Gold($waveMo->rewardGold); # 金币奖励
  668. //$pickups .= ";1," . $gold + $waveMo->rewardGold;
  669. $str = "1," . $gold + $waveMo->rewardGold;
  670. StoreProc::AddMultiItemInStore($str);
  671. if ($waveMo->rewardItem != null) {
  672. $reward = StoreProc::Distribute_Rewards($waveMo->rewardItem);
  673. StoreProc::AddMultiItemInStore($reward);
  674. // if(count(StoreProc::$reward_equip) > 0){
  675. // self::funUnlock_equip_firstTime();
  676. // }
  677. }
  678. # 图纸奖励: 数量min-max, 部位随机
  679. if (strlen($waveMo->rewardTuZhi) > 0 && str_contains($waveMo->rewardTuZhi, '-')) {
  680. list($tz_min, $tz_max) = explode('-', $waveMo->rewardTuZhi); # 图纸数量
  681. $tz_n = rand($tz_min, $tz_max);
  682. # 图纸部位数据源 1001, 1002, 1003, 1004, 1005, 1006
  683. for ($i = 0; $i < $tz_n; $i++) {
  684. $id = 1000 + rand(1, 6);
  685. StoreProc::AddMultiItemInStore("$id,1"); # 获得图纸
  686. //$pickups .= ";$id,1";
  687. }
  688. }
  689. # 宝石奖励: 数量min-max;品质:权重,品质:权重...
  690. if (strlen($waveMo->rewardGem) > 0) {
  691. //self::funUnlock_Gem();
  692. list($gs_num, $gs_props) = explode(';', $waveMo->rewardGem);
  693. list($gem_min, $gem_max) = explode('-', $gs_num); # 宝石数量
  694. $gem_n = rand($gem_min, $gem_max);
  695. $arr = explode(",", $gs_props);
  696. $pool = array();
  697. $n = 0;
  698. foreach ($arr as $str) {
  699. list($qual, $props) = explode(':', $str);
  700. $pool[] = array('q' => $qual, 'p' => $props);
  701. $n += $props;
  702. }
  703. for ($i = 0; $i < $gem_n; $i++) { # 随机n块宝石
  704. $r = rand(1, $n); # 投色子
  705. $l = 0;
  706. foreach ($pool as $item) {
  707. if ($r <= ($l + $item['p'])) {
  708. $gemId = $item['q'] * 100000 + rand(1, 6) * 1000;
  709. SystemProc::GetGem_GreaterOrangeQual_MainGate(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($gateId), $gateMo->gateName, $gemId); //广播
  710. //StoreProc::PutGemInStore($gemId); # 发放宝石并退出本次投色子
  711. //$pickups .= ";$gemId,1";
  712. StoreProc::AddMultiItemInStore("$gemId,1");
  713. break;
  714. }
  715. $l += $item['p']; # 累计到下一段
  716. }
  717. }
  718. }
  719. ctx()->gates->GateList->$gateId->fightNum += 1;
  720. GuideProc::MainTaskRewardReceived_Guide_Trigger($gateId, ctx()->gates->GateList->$gateId->fightNum);
  721. //TaskProc::Day7TaskReset();
  722. TaskProc::OnFightNumMainGate();
  723. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  724. TaskProc::OnKillleaderNumMonster($killBossNum);
  725. TaskProc::OnFightGate_X($gateId);
  726. if ($gateId == 11000) {
  727. ctx()->gates()->UnlockNextPlotGate(11000);
  728. ctx()->gates(true)->CurrentGateId = 11001;
  729. StlUtil::dictRemove(ctx()->gates->GateList, 11000);
  730. ctx()->baseInfo->animation = 1;
  731. }
  732. UserProc::updateUserInfo();
  733. $ret = array(
  734. 'gates' => ctx()->gates,
  735. 'store' => ctx()->store,
  736. 'task' => ctx()->task,
  737. 'baseInfo' => ctx()->base(),
  738. 'gold' => $gold + $waveMo->rewardGold,
  739. 'exp' => $waveMo->rewardExp,
  740. //'rewardStr' => $pickups
  741. 'reward' => StoreProc::$reward,
  742. 'reward_Gem' => StoreProc::$reward_Gem,
  743. 'reward_equip' => StoreProc::$reward_equip,
  744. 'oldLevel' => $oldLevel,
  745. 'newLevel' => $newLevel,
  746. //'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  747. //'funUnlockRecord_2' => ctx()->privateState->funUnlockRecord_2,
  748. //'LoginDays'=> ctx()->privateState->LoginDays,
  749. //'skillUnlockRecord' => ctx()->privateState->skillUnlockRecord,
  750. 'heros' => ctx()->heros,
  751. 'privateState' => ctx()->privateState,
  752. );
  753. return Resp::ok($ret);
  754. }
  755. /**
  756. * 装备概率结算
  757. * @param type $equipStr
  758. */
  759. private static function EquipSettle($equipStr) {
  760. StoreProc::DistributeItemsBox($itemId);
  761. }
  762. // <editor-fold defaultstate="collapsed" desc="功能解锁">
  763. /**
  764. * 检测功能解锁的 关卡
  765. * @param type $resultType
  766. * @param type $gateId
  767. * @return type
  768. */
  769. static function funUnlock_Gate($resultType, $gateId) {
  770. $dic = GameConfig::fun_unlock();
  771. foreach ($dic as $id => $mo) {
  772. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  773. $tag = false;
  774. if ($mo->unlockType1 != null) {
  775. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  776. switch ($mo->unlockType1) {
  777. case Enum_FunUnlockType::battle_Gate:
  778. if ($mo->unlockParas1 == $gateId && ctx()->gates->GateList->$gateId->fightNum == 0) {
  779. $tag = true;
  780. }
  781. break;
  782. case Enum_FunUnlockType::passBattle_Gate:
  783. if ($resultType == true && $mo->unlockParas1 == $gateId && ctx()->gates->GateList->$gateId->pass == 0) {
  784. $tag = true;
  785. }
  786. break;
  787. default:
  788. break;
  789. }
  790. }
  791. if ($mo->unlockType2 != null) {
  792. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  793. switch ($mo->unlockType2) {
  794. case Enum_FunUnlockType::battle_Gate:
  795. if ($mo->unlockParas2 == $gateId && ctx()->gates->GateList->$gateId->fightNum == 0) {
  796. $tag = true;
  797. }
  798. break;
  799. case Enum_FunUnlockType::passBattle_Gate:
  800. if ($resultType == true && $mo->unlockParas2 == $gateId && ctx()->gates->GateList->$gateId->pass == 0) {
  801. $tag = true;
  802. }
  803. break;
  804. default:
  805. break;
  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. if ($id == 13 || $id == 16 || $id == 14) {
  812. self::unlockGuideType($id);
  813. //ctx()->privateData(true)->funUnlockRecord_3[] =
  814. }
  815. self::SubFunDateInit_FunUnlock($id);
  816. }
  817. }
  818. }
  819. }
  820. public static function unlockGuideType($id) {
  821. GuideProc::Qingling_EquipWear_Guide_Trigger($id);
  822. // $type = 0;
  823. // switch ($id) {
  824. // case 16://启灵
  825. // $type = E_GuideTypeState::Qingling_Guide;
  826. // break;
  827. // case 14://装备 首次获得装备 装备功能解锁 同时开启装备穿戴引导
  828. // $type = E_GuideTypeState::EquipWear_Guide;
  829. // break;
  830. // default:
  831. // break;
  832. // }
  833. //
  834. // if($type >0 && !in_array($type,ctx()->privateData(true)->funUnlockRecord_3)){
  835. // ctx()->privateData(true)->funUnlockRecord_3[] = $type;
  836. // }
  837. //return $type;
  838. }
  839. /**
  840. * 初次得到装备 功能解锁
  841. */
  842. static function funUnlock_equip_firstTime() {
  843. $dic = GameConfig::fun_unlock();
  844. foreach ($dic as $id => $mo) {
  845. $tag = false;
  846. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  847. if ($mo->unlockType1 != null && $mo->unlockType1 == Enum_FunUnlockType::equip_firstTime && count(StlUtil::dictToArray(ctx()->store->equip)) == 0) {
  848. $tag = true;
  849. }
  850. if ($mo->unlockType2 != null && $mo->unlockType2 == Enum_FunUnlockType::equip_firstTime && count(StlUtil::dictToArray(ctx()->store->equip)) == 0) {
  851. $tag = true;
  852. }
  853. }
  854. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  855. ctx()->privateData(true)->funUnlockRecord[] = $id;
  856. ctx()->privateData(true)->funUnlockRecord_2[] = $id;
  857. if ($id == 13 || $id == 16 || $id == 14) {
  858. self::unlockGuideType($id);
  859. //ctx()->privateData(true)->funUnlockRecord_3[] =
  860. }
  861. self::SubFunDateInit_FunUnlock($id);
  862. }
  863. }
  864. }
  865. /**
  866. * 玩家等级要求 功能解锁
  867. */
  868. static function funUnlock_userLv($level) {
  869. $dic = GameConfig::fun_unlock();
  870. foreach ($dic as $id => $mo) {
  871. $tag = false;
  872. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  873. if ($mo->unlockType1 != null && $mo->unlockType1 == Enum_FunUnlockType::userLv && $mo->unlockParas1 == $level) {
  874. $tag = true;
  875. }
  876. if ($mo->unlockType2 != null && $mo->unlockType2 == Enum_FunUnlockType::userLv && $mo->unlockParas2 == $level) {
  877. $tag = true;
  878. }
  879. }
  880. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  881. ctx()->privateData(true)->funUnlockRecord[] = $id;
  882. ctx()->privateData(true)->funUnlockRecord_2[] = $id;
  883. if ($id == 13 || $id == 16 || $id == 14) {
  884. self::unlockGuideType($id);
  885. //ctx()->privateData(true)->funUnlockRecord_3[] = self::unlockGuideType($id);
  886. }
  887. self::SubFunDateInit_FunUnlock($id);
  888. }
  889. }
  890. }
  891. /**
  892. * 主线挑战 功能解锁
  893. */
  894. static function funUnlock_mainChallengeGate_State($result, $gateId, $state) {
  895. $dic = GameConfig::fun_unlock();
  896. foreach ($dic as $id => $mo) {
  897. $tag = false;
  898. if ($mo->unlockTip == 1) {//$mo->unlockGateId == $gateId
  899. if ($mo->unlockType1 != null && $result = true && $mo->unlockType1 == Enum_FunUnlockType::mainChallengeGate_State) {
  900. $str = explode(',', $mo->unlockParas1);
  901. $uGateId = $str[0];
  902. $gateState = $str[1];
  903. if ($uGateId == $gateId && StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId) && ctx()->gates->GateList->$gateId->tz_state == $gateState - 1) {
  904. $tag = true;
  905. }
  906. }
  907. if ($mo->unlockType2 != null && $result = true && $mo->unlockType2 == Enum_FunUnlockType::mainChallengeGate_State) {
  908. $str = explode(',', $mo->unlockParas2);
  909. $uGateId = $str[0];
  910. $gateState = $str[1];
  911. if ($uGateId == $gateId && StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId) && ctx()->gates->GateList->$gateId->tz_state == $gateState - 1) {
  912. $tag = true;
  913. }
  914. }
  915. }
  916. if ($tag && !in_array($id, ctx()->privateState->funUnlockRecord_2)) {
  917. ctx()->privateData(true)->funUnlockRecord[] = $id;
  918. ctx()->privateData(true)->funUnlockRecord_2[] = $id;
  919. if ($id == 13 || $id == 16 || $id == 14) {
  920. self::unlockGuideType($id);
  921. //ctx()->privateData(true)->funUnlockRecord_3[] = self::unlockGuideType($id);
  922. }
  923. self::SubFunDateInit_FunUnlock($id);
  924. }
  925. }
  926. }
  927. /**
  928. * 查看某功能是否解锁
  929. * @param type $id
  930. */
  931. static function isFunUnlock($id) {
  932. $funMo = GameConfig::fun_unlock_getItem($id);
  933. if ($funMo->unlockType1 != null && self::unlockCondition($funMo->unlockType1, $funMo->unlockParas1)) {
  934. return true;
  935. }
  936. if ($funMo->unlockType2 != null && self::unlockCondition($funMo->unlockType2, $funMo->unlockParas2)) {
  937. return true;
  938. }
  939. return false;
  940. }
  941. /**
  942. * 解锁条件id
  943. * @param type $conditionId
  944. */
  945. static function unlockCondition($conditionId, $paras) {
  946. $funUnlock = false;
  947. switch ($conditionId) {
  948. case Enum_FunUnlockType::battle_Gate:
  949. $gateId = $paras;
  950. if (ctx()->gates->GateList->$gateId->fightNum > 0) {
  951. $funUnlock = true;
  952. }
  953. break;
  954. case Enum_FunUnlockType::passBattle_Gate:
  955. $gateId = $paras;
  956. if (ctx()->gates->GateList->$gateId->pass >= 1) {
  957. $funUnlock = true;
  958. }
  959. break;
  960. case Enum_FunUnlockType::equip_firstTime:
  961. if (ctx()->store->equip != null) {
  962. $funUnlock = true;
  963. }
  964. break;
  965. case Enum_FunUnlockType::userLv:
  966. if (ctx()->baseInfo->level >= $paras) {
  967. $funUnlock = true;
  968. }
  969. break;
  970. case Enum_FunUnlockType::mainChallengeGate_State:
  971. $str = explode(',', $paras);
  972. $uGateId = $str[0];
  973. $gateState = $str[1];
  974. if (StlUtil::dictHasProperty(ctx()->gates->GateList, $uGateId) && ctx()->gates->GateList->$uGateId->tz_state >= $gateState) {
  975. $funUnlock = true;
  976. }
  977. break;
  978. default:
  979. break;
  980. }
  981. return $funUnlock;
  982. }
  983. /**
  984. * 次级功能解锁数据初始化
  985. */
  986. static function SubFunDateInit_FunUnlock($type) {
  987. $dic = GameConfig::subfun_unlock();
  988. foreach ($dic as $id => $mo) {
  989. if ($mo->funTypeId != $type) {
  990. continue;
  991. }
  992. if ($mo->funTypeId == 6 && $mo->id == Enum_SubFunType::Day7_Happy) {
  993. TaskProc::Day7TaskReset();
  994. }
  995. if ($mo->funTypeId == 5 && $mo->id == Enum_SubFunType::DailyTask) {
  996. TaskProc::DailyTaskReset(true);
  997. }
  998. if ($mo->funTypeId == 5 && $mo->id == Enum_SubFunType::WeekTask) {
  999. TaskProc::WeekTaskReset(true);
  1000. }
  1001. if ($mo->funTypeId == 5 && $mo->id == Enum_SubFunType::Day7_Sign) {
  1002. ActiveProc::DailyResetDay7Task(true);
  1003. }
  1004. if ($mo->funTypeId == 21 && $mo->id == Enum_SubFunType::Day7_Sign_NewPlayer) {
  1005. ActiveProc::InitDay7_Sign_NewPlayer(true);
  1006. ctx()->privateState->day7_drawed_newPlayer_startTs = now();
  1007. }
  1008. }
  1009. }
  1010. /**
  1011. * 次级功能解锁数据初始化
  1012. */
  1013. static function SubFunDateInit_Config() {
  1014. $dic = GameConfig::subfun_unlock();
  1015. foreach ($dic as $id => $mo) {
  1016. if ($mo->type == 3 && $mo->id == Enum_SubFunType::LimitTsSale && ctx()->privateState->nextDayLogin == 0 && now() >= $mo->startTs) {
  1017. ActiveProc::ResetLimitTsBuy();
  1018. }
  1019. if ($mo->type == 3 && $mo->id == Enum_SubFunType::ActivePoint_BattlePass && ctx()->privateState->battlePass_activePoint_refersh_ts == 0 && now() >= $mo->startTs) {
  1020. ctx()->privateState->battlePass_activePoint_refersh_ts = TimeUtil::getNextDayTs($mo->startTs, $mo->ts);
  1021. ctx()->privateData(true)->battlePass_activePoint_cost_ts = 0;
  1022. ctx()->privateData(true)->battlePass_taskPoint = 0;
  1023. ActiveProc::ResetBattlePassReward(Enum_SubFunType::ActivePoint_BattlePass);
  1024. }
  1025. if ($mo->type == 3 && $mo->id == Enum_SubFunType::Tili_BattleBass && ctx()->privateState->battlePass_tili_refersh_ts == 0 && now() >= $mo->startTs) {
  1026. ctx()->privateState->battlePass_tili_refersh_ts = TimeUtil::getNextDayTs($mo->startTs, $mo->ts);
  1027. ctx()->privateData(true)->battlePass_tili_cost_ts = 0;
  1028. ctx()->privateData(true)->battlePass_tili = 0;
  1029. ActiveProc::ResetBattlePassReward(Enum_SubFunType::Tili_BattleBass);
  1030. }
  1031. }
  1032. }
  1033. // </editor-fold>
  1034. // <editor-fold defaultstate="collapsed" desc="技能解锁">
  1035. /**
  1036. * 检测技能解锁的 1 关卡解锁,游玩到一定关卡解锁技能
  1037. * @param type $resultType
  1038. * @param type $gateId
  1039. * @return type
  1040. */
  1041. static function skillUnlock_gate($resultType, $gateId) {
  1042. $dic = GameConfig::skills();
  1043. $gateIndex = Ins_GateInfo::gateNum($gateId);
  1044. foreach ($dic as $id => $mo) {
  1045. if ($mo->unlock_acc_id_new == null) {
  1046. continue;
  1047. }
  1048. $strList = explode(':', $mo->unlock_acc_id_new);
  1049. $unlockType = $strList[0];
  1050. $unlockId = $strList[1];
  1051. if ($unlockType == 1 && $unlockId == $gateIndex && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  1052. ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
  1053. }
  1054. }
  1055. }
  1056. /**
  1057. * 检测技能解锁的 2://皮肤解锁,获取到人物解锁后对应皮肤技能
  1058. * @param type $resultType
  1059. * @param type $gateId
  1060. * @return type
  1061. */
  1062. static function skillUnlock_heroUnlock($heroId) {
  1063. $dic = GameConfig::skills();
  1064. foreach ($dic as $id => $mo) {
  1065. if ($mo->unlock_acc_id_new == null) {
  1066. continue;
  1067. }
  1068. $strList = explode(':', $mo->unlock_acc_id_new);
  1069. $unlockType = $strList[0];
  1070. $unlockId = $strList[1];
  1071. if ($unlockType != 2) {
  1072. continue;
  1073. }
  1074. $heroMo = GameConfig::hero_getItem($heroId);
  1075. $heroTypeId = $heroMo->typeID;
  1076. $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
  1077. if ($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  1078. ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
  1079. }
  1080. }
  1081. }
  1082. /**
  1083. * 检测技能解锁的 3://玩家失败X次后解锁
  1084. * @param type $resultType
  1085. * @param type $gateId
  1086. * @return type
  1087. */
  1088. static function skillUnlock_fightNum($resultType) {
  1089. if ($resultType) {
  1090. return;
  1091. }
  1092. $GateList = ctx()->gates->GateList;
  1093. $num = 0;
  1094. foreach ($GateList as $gateId => $Ins_GateInfo) {
  1095. $num += $Ins_GateInfo->fightNum_fail;
  1096. }
  1097. $dic = GameConfig::skills();
  1098. foreach ($dic as $id => $mo) {
  1099. if ($mo->unlock_acc_id_new == null) {
  1100. continue;
  1101. }
  1102. $strList = explode(':', $mo->unlock_acc_id_new);
  1103. $unlockType = $strList[0];
  1104. $unlockId = $strList[1];
  1105. if ($unlockType != 3) {
  1106. continue;
  1107. }
  1108. if ($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  1109. ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
  1110. }
  1111. }
  1112. }
  1113. /**
  1114. * 玩家等级解锁技能
  1115. * @param type $curLevel
  1116. */
  1117. static function skillUnlock_userLevel($curLevel) {
  1118. $dic = GameConfig::skills();
  1119. foreach ($dic as $id => $mo) {
  1120. if ($mo->unlock_acc_id_new == null) {
  1121. continue;
  1122. }
  1123. $strList = explode(':', $mo->unlock_acc_id_new);
  1124. $unlockType = $strList[0];
  1125. $unlockId = $strList[1];
  1126. if ($unlockType != 5) { // 玩家等级
  1127. continue;
  1128. }
  1129. if ($unlockId == $curLevel && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  1130. ctx()->privateData(true)->skillUnlockRecord[] = $mo->typeId;
  1131. }
  1132. }
  1133. }
  1134. // </editor-fold>
  1135. // <editor-fold defaultstate="collapsed" desc="排行榜">
  1136. /**
  1137. * 参与主线关卡排行榜
  1138. * @param type $gateIndex
  1139. */
  1140. public static function Ranking_MainGateIndex($maxGateIndex) {
  1141. $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
  1142. $mem = gMem();
  1143. $uid = req()->uid;
  1144. $score = self::GetRankScoreUid($uid, 1);
  1145. if ($maxGateIndex > $score) {
  1146. $arr = array();
  1147. $arr["$uid"] = self::createScore($maxGateIndex);
  1148. $mem->zadd($memKey, $arr);
  1149. }
  1150. $length = $mem->zlen($memKey);
  1151. if ($length > glc()->Rank_MainGateIndex_OnListRank) {
  1152. $num = $length - glc()->Rank_MainGateIndex_OnListRank;
  1153. $mem->zremrangebyrank($memKey, 0, $num - 1);
  1154. }
  1155. }
  1156. public static function createScore($score) {
  1157. if ($score > 0) {
  1158. $newScore = $score . '.' . (9999999999 - now());
  1159. return $newScore;
  1160. }
  1161. return 0;
  1162. }
  1163. /**
  1164. * 战力榜
  1165. * @param type $gateIndex
  1166. */
  1167. public static function Ranking_FightPower() {
  1168. $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
  1169. $mem = gMem();
  1170. $uid = req()->uid;
  1171. $score = self::GetRankScoreUid($uid, 2);
  1172. //$power = self::countUserFightPower();
  1173. $power = FightPower_Calculate::GetFightPower();
  1174. $arr = array();
  1175. $arr["$uid"] = self::createScore($power);
  1176. $mem->zadd($memKey, $arr);
  1177. if ($power >= $score) {
  1178. self::IsAchievedFightPower_PassReward($power);
  1179. }
  1180. $length = $mem->zlen($memKey);
  1181. if ($length > glc()->Rank_FightPower_OnListRank) {
  1182. $num = $length - glc()->Rank_FightPower_OnListRank;
  1183. $mem->zremrangebyrank($memKey, 0, $num - 1);
  1184. }
  1185. }
  1186. public static function GetRankScoreUid($uid_rank, $type) {
  1187. if ($type == 1) {
  1188. $score = gMem()->zscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid_rank);
  1189. } else {
  1190. $score = gMem()->zscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid_rank);
  1191. }
  1192. if ($score == null) {
  1193. $score = 0;
  1194. }
  1195. return intval($score);
  1196. }
  1197. /**
  1198. * 6811 获取主线关卡排行榜信息
  1199. * @return type
  1200. */
  1201. public static function GetRankInfo() {
  1202. list($type) = req()->paras;
  1203. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  1204. $selfExtraInfo = 0;
  1205. $isExistFinishReward = 0;
  1206. $isExistFinishReward_other = 0;
  1207. if ($type == 1) {
  1208. $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  1209. $selfExtraInfo = ctx()->gates->maxPassGateNumId();
  1210. $isExistFinishReward = self::isExistNoDrawed_MainGate();
  1211. $isExistFinishReward_other = self::isExistNoDrawed_FightPower();
  1212. } else {
  1213. $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1214. //$selfExtraInfo = self::countUserFightPower();
  1215. $selfExtraInfo = FightPower_Calculate::GetFightPower();
  1216. $isExistFinishReward = self::isExistNoDrawed_FightPower();
  1217. $isExistFinishReward_other = self::isExistNoDrawed_MainGate();
  1218. }
  1219. if ($isExistFinishReward == 1) {
  1220. $isExistFinishReward = true;
  1221. } else {
  1222. $isExistFinishReward = false;
  1223. }
  1224. if ($isExistFinishReward_other == 1) {
  1225. $isExistFinishReward_other = true;
  1226. } else {
  1227. $isExistFinishReward_other = false;
  1228. }
  1229. $selfRank = null;
  1230. $retArr = array();
  1231. if (count($list) > 0) {
  1232. foreach ($list as $uid => $score) {
  1233. $rankInfo = self::initOtherUidRankInfo($uid, $score, $type);
  1234. if ($rankInfo->uid == req()->uid) {
  1235. $selfIsHasRank = 1;
  1236. $selfRank = $rankInfo;
  1237. }
  1238. $retArr[] = $rankInfo;
  1239. }
  1240. }
  1241. if ($selfRank == null) {
  1242. $selfRank = self::initOtherUidRankInfo(req()->uid, $selfExtraInfo, $type);
  1243. }
  1244. UserProc::updateUserInfo();
  1245. $ret = array(
  1246. 'rankInfo' => $retArr,
  1247. 'selfRank' => $selfRank,
  1248. 'selfIsHasRank' => $selfIsHasRank,
  1249. 'isExistFinishReward' => $isExistFinishReward,
  1250. 'isExistFinishReward_other' => $isExistFinishReward_other,
  1251. );
  1252. return Resp::ok($ret);
  1253. }
  1254. /**
  1255. * 初始化玩家rank
  1256. * @param type $uid
  1257. * @param type $score
  1258. * @return \loyalsoft\Ins_rank
  1259. */
  1260. static function initOtherUidRankInfo($uid, $score, $type = null) {
  1261. $ins_rank = new Ins_rank();
  1262. if ($type == 1) {
  1263. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  1264. } else if ($type == 2) {
  1265. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1266. } elseif ($type == 3) {
  1267. $memKey = self::GetWorldBoss_DamageMemKey();
  1268. $lv = gMem()->zrevrank($memKey, $uid);
  1269. }
  1270. if ($lv === null) {
  1271. $lv = -1;
  1272. }
  1273. $ins_rank->rank = $lv + 1;
  1274. $ins_rank->uid = $uid;
  1275. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  1276. $ins_rank->name = $userInfo->baseInfo->name;
  1277. $ins_rank->headImg = $userInfo->baseInfo->headImg;
  1278. $ins_rank->score = intval($score);
  1279. return $ins_rank;
  1280. }
  1281. /**
  1282. * 6812 获取排行榜内玩家的装备信息
  1283. * @return type
  1284. */
  1285. public static function GetUidEquipInfo_Rank() {
  1286. list($uid) = req()->paras;
  1287. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  1288. $store = $userInfo->store;
  1289. $heros = $userInfo->heros;
  1290. $gates = $userInfo->gates;
  1291. UserProc::updateUserInfo();
  1292. $ret = array(
  1293. 'store' => $store,
  1294. 'heros' => $heros,
  1295. 'gates' => $gates,
  1296. );
  1297. return Resp::ok($ret);
  1298. }
  1299. /**
  1300. * 通关奖励是否达成
  1301. * @param type $maxGateIndex
  1302. */
  1303. public static function IsAchievedMainGate_PassReward($maxGateIndex) {
  1304. $rewards = GameConfig::rank_passgatereward();
  1305. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1306. foreach ($rewards as $passGateId => $mo) {
  1307. if ($passGateId == $maxGateIndex && !gMem()->hexists($memKey, $maxGateIndex)) {
  1308. $ins_rank = new Ins_rank();
  1309. $ins_rank->uid = req()->uid;
  1310. $ins_rank->name = ctx()->baseInfo->name;
  1311. $ins_rank->headImg = ctx()->baseInfo->headImg;
  1312. $ins_rank->score = $passGateId;
  1313. gMem()->hset($memKey, $maxGateIndex, $ins_rank);
  1314. break;
  1315. }
  1316. }
  1317. }
  1318. /*
  1319. * 战力奖励是否达成
  1320. */
  1321. public static function IsAchievedFightPower_PassReward($power) {
  1322. $rewards = GameConfig::rank_fightpowerreward();
  1323. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1324. foreach ($rewards as $fightPower => $mo) {
  1325. if ($power >= $fightPower && !gMem()->hexists($memKey, $fightPower)) {
  1326. $ins_rank = new Ins_rank();
  1327. $ins_rank->uid = req()->uid;
  1328. $ins_rank->name = ctx()->baseInfo->name;
  1329. $ins_rank->headImg = ctx()->baseInfo->headImg;
  1330. $ins_rank->score = $fightPower;
  1331. gMem()->hset($memKey, $fightPower, $ins_rank);
  1332. }
  1333. }
  1334. }
  1335. public static function isExistNoDrawed_MainGate() {
  1336. $isExistFinishReward = 0;
  1337. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1338. $dic = gMem()->hgetall($memKey);
  1339. foreach ($dic as $gateId => $ins_rank) {
  1340. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1341. $isExistFinishReward = 1;
  1342. break;
  1343. }
  1344. }
  1345. ctx()->privateData(true)->redTip_RewardMainGateRank = $isExistFinishReward;
  1346. return $isExistFinishReward;
  1347. }
  1348. public static function isExistNoDrawed_FightPower() {
  1349. $isExistFinishReward = 0;
  1350. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1351. $dic = gMem()->hgetall($memKey);
  1352. foreach ($dic as $fightPower => $ins_rank) {
  1353. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1354. $isExistFinishReward = 1;
  1355. break;
  1356. }
  1357. }
  1358. ctx()->privateData(true)->redTip_RewardFightPowerRank = $isExistFinishReward;
  1359. return $isExistFinishReward;
  1360. }
  1361. /**
  1362. * 6813
  1363. * @return type
  1364. */
  1365. public static function GetmainGate_RankRewardInfo() {
  1366. //list($type) = req()->paras;
  1367. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1368. $dic = gMem()->hgetall($memKey);
  1369. if ($dic == null) {
  1370. $dic = new \stdClass();
  1371. }
  1372. UserProc::updateUserInfo();
  1373. $ret = array(
  1374. 'rankReward' => $dic,
  1375. );
  1376. return Resp::ok($ret);
  1377. }
  1378. /**
  1379. * 6814
  1380. * @return type
  1381. */
  1382. public static function GetFightPower_RankRewardInfo() {
  1383. //list($type) = req()->paras;
  1384. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1385. $dic = gMem()->hgetall($memKey);
  1386. if ($dic == null) {
  1387. $dic = new \stdClass();
  1388. }
  1389. UserProc::updateUserInfo();
  1390. $ret = array(
  1391. 'rankReward' => $dic,
  1392. );
  1393. return Resp::ok($ret);
  1394. }
  1395. /**
  1396. * 6815 领取通关荣誉榜奖励
  1397. * @return type
  1398. */
  1399. public static function ReceiveRankReward_MainGate() {
  1400. list($gateId) = req()->paras;
  1401. my_Assert(!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate), ErrCode::rankReward_HasReceive);
  1402. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  1403. my_Assert($mo != null, ErrCode::err_const_no);
  1404. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1405. if (gMem()->hexists($memKey, $gateId)) {
  1406. StoreProc::AddMultiItemInStore($mo->reward);
  1407. ctx()->privateData(true)->rankReward_drawed_MainGate[] = $gateId;
  1408. TaskProc::OnRankPrize_Num();
  1409. }
  1410. $tag = self::isExistNoDrawed_MainGate();
  1411. UserProc::updateUserInfo();
  1412. $ret = array('redTip' => $tag, 'task' => ctx()->task, 'store' => ctx()->store, 'cash' => ctx()->baseInfo->cash, 'reward' => StoreProc::$reward);
  1413. return Resp::ok($ret);
  1414. }
  1415. /**
  1416. * 6816 领取战力荣誉榜奖励
  1417. * @return type
  1418. */
  1419. public static function ReceiveRankReward_FightPower() {
  1420. list($fightPower) = req()->paras;
  1421. my_Assert(!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower), ErrCode::rankReward_HasReceive);
  1422. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  1423. my_Assert($mo != null, ErrCode::err_const_no);
  1424. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1425. if (gMem()->hexists($memKey, $fightPower)) {
  1426. StoreProc::AddMultiItemInStore($mo->reward);
  1427. ctx()->privateData(true)->rankReward_drawed_fightPower[] = $fightPower;
  1428. TaskProc::OnFightRankPrize_Num();
  1429. }
  1430. $tag = self::isExistNoDrawed_FightPower();
  1431. UserProc::updateUserInfo();
  1432. $ret = array('redTip' => $tag, 'task' => ctx()->task, 'store' => ctx()->store, 'cash' => ctx()->baseInfo->cash, 'reward' => StoreProc::$reward);
  1433. return Resp::ok($ret);
  1434. }
  1435. /**
  1436. * 6824 排行奖励一键领取
  1437. */
  1438. static function ReceiveRankReward() {
  1439. list($type) = req()->paras; # 解锁数量
  1440. if ($type == 1) {
  1441. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1442. $dic = gMem()->hgetall($memKey);
  1443. foreach ($dic as $gateId => $ins_rank) {
  1444. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1445. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  1446. StoreProc::AddMultiItemInStore($mo->reward);
  1447. ctx()->privateData(true)->rankReward_drawed_MainGate[] = $gateId;
  1448. TaskProc::OnRankPrize_Num();
  1449. }
  1450. }
  1451. } else {
  1452. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1453. $dic2 = gMem()->hgetall($memKey2);
  1454. foreach ($dic2 as $fightPower => $ins_rank) {
  1455. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1456. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  1457. StoreProc::AddMultiItemInStore($mo->reward);
  1458. ctx()->privateData(true)->rankReward_drawed_fightPower[] = $fightPower;
  1459. TaskProc::OnFightRankPrize_Num();
  1460. }
  1461. }
  1462. }
  1463. UserProc::updateUserInfo();
  1464. $ret = array('redTip' => 0,
  1465. 'task' => ctx()->task,
  1466. 'store' => ctx()->store,
  1467. 'cash' => ctx()->baseInfo->cash,
  1468. 'reward' => StoreProc::$reward,
  1469. 'rankReward_drawed_fightPower' => ctx()->privateState->rankReward_drawed_fightPower,
  1470. 'rankReward_drawed_MainGate' => ctx()->privateState->rankReward_drawed_MainGate,
  1471. );
  1472. return Resp::ok($ret);
  1473. }
  1474. /**
  1475. * 6817
  1476. */
  1477. public static function IsExistRankReward() {
  1478. //list($type) = req()->paras;
  1479. $type = 0;
  1480. $isExistFinishReward = false;
  1481. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1482. $dic = gMem()->hgetall($memKey);
  1483. foreach ($dic as $gateId => $ins_rank) {
  1484. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1485. $isExistFinishReward = true;
  1486. $type = 1;
  1487. break;
  1488. }
  1489. }
  1490. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1491. $dic2 = gMem()->hgetall($memKey2);
  1492. foreach ($dic2 as $fightPower => $ins_rank) {
  1493. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1494. $isExistFinishReward = true;
  1495. $type = 2;
  1496. break;
  1497. }
  1498. }
  1499. UserProc::updateUserInfo();
  1500. $ret = array(
  1501. 'isExistFinishReward' => $isExistFinishReward,
  1502. 'type' => $type,
  1503. );
  1504. return Resp::ok($ret);
  1505. }
  1506. /*
  1507. * 删除排行榜内注销账号的玩家
  1508. */
  1509. public static function DeleteRankInvalidUser($uid2) {
  1510. $dic1 = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  1511. foreach ($dic1 as $uid => $score) {
  1512. if ($uid == $uid2) {
  1513. gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  1514. break;
  1515. }
  1516. }
  1517. $dic2 = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1518. foreach ($dic2 as $uid => $score) {
  1519. if ($uid == $uid2) {
  1520. gMem()->zrem(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1521. break;
  1522. }
  1523. }
  1524. }
  1525. /*
  1526. * 排行玩家修改昵称
  1527. */
  1528. public static function UpdateRankUserName($uid, $newName) {
  1529. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1530. $dic = gMem()->hgetall($memKey1);
  1531. foreach ($dic as $gateId => $ins_rank) {
  1532. if ($ins_rank->uid == $uid) {
  1533. $ins_rank->name = $newName;
  1534. gMem()->hset($memKey1, $gateId, $ins_rank);
  1535. }
  1536. }
  1537. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1538. $dic2 = gMem()->hgetall($memKey2);
  1539. foreach ($dic2 as $fightPower => $ins_rank) {
  1540. if ($ins_rank->uid == $uid) {
  1541. $ins_rank->name = $newName;
  1542. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1543. }
  1544. }
  1545. }
  1546. /*
  1547. * 排行玩家头像变动
  1548. */
  1549. public static function UpdateRankUserHeadImg($uid, $headImg) {
  1550. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1551. $dic = gMem()->hgetall($memKey1);
  1552. foreach ($dic as $gateId => $ins_rank) {
  1553. if ($ins_rank->uid == $uid) {
  1554. $ins_rank->headImg = $headImg;
  1555. gMem()->hset($memKey1, $gateId, $ins_rank);
  1556. }
  1557. }
  1558. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1559. $dic2 = gMem()->hgetall($memKey2);
  1560. foreach ($dic2 as $fightPower => $ins_rank) {
  1561. if ($ins_rank->uid == $uid) {
  1562. $ins_rank->headImg = $headImg;
  1563. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1564. }
  1565. }
  1566. }
  1567. /*
  1568. * 统计战力 战斗力=攻击x(生命-伤害减免值)x(1+暴击率/100x(暴击伤害倍率-1))改为 //战斗力=攻击x(生命-伤害减免值)x(1+暴击率 x(暴击伤害倍率-1))2024-8-30
  1569. */
  1570. public static function countUserFightPower() {
  1571. $CurrentHeroId = ctx()->heros->CurrentHeroId;
  1572. //$hero = ctx()->heros->Dic->$CurrentHeroId;
  1573. list($addHp, $addAtk, $addDecDamage, $addEatFood) = ctx()->gates()->GetEnvovleBuffs(); // 启灵加成
  1574. $mo = GameConfig::hero_getItem($CurrentHeroId);
  1575. my_Assert($mo != null, ErrCode::err_const_no);
  1576. $heroBashAttack = $mo->attack;
  1577. $heroBashHp = $mo->hp;
  1578. $attck = 0;
  1579. $hp = 0;
  1580. $equipDic = ctx()->store->equipLocation;
  1581. foreach ($equipDic as $index => $equipUid) {
  1582. $ins_Equip = new Ins_Equip(ctx()->store->equip->$equipUid);
  1583. if ($ins_Equip->mo()->position % 2 == 1) {
  1584. $attck += GameConfig::equip_levelupgrade_getItem($ins_Equip->mo()->rarity, $ins_Equip->qual, $ins_Equip->mo()->position, $ins_Equip->level)->attckNum;
  1585. } elseif ($ins_Equip->mo()->position % 2 == 0) {
  1586. $hp += GameConfig::equip_levelupgrade_getItem($ins_Equip->mo()->rarity, $ins_Equip->qual, $ins_Equip->mo()->position, $ins_Equip->level)->hpNum;
  1587. }
  1588. }
  1589. // $equipDic = ctx()->store->equipPosition;
  1590. // $attck = 0;
  1591. // $hp = 0;
  1592. // foreach ($equipDic as $index => $ins_equip) {
  1593. // $Ins_Equip = new Ins_EquipPosition($ins_equip);
  1594. // if ($Ins_Equip->mo()->upgradeType == 1) {//攻击力
  1595. // $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1596. // } elseif ($Ins_Equip->mo()->upgradeType == 2) {
  1597. // $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1598. // } else {
  1599. // $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1600. // $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1601. // }
  1602. // }
  1603. $heroAttck = $heroBashAttack + $attck + $addAtk; # 英雄基础攻击力+装备宝石词条攻击力+启灵攻击力
  1604. $heroHp = $heroBashHp + $hp + $addHp; # 英雄基础hp + 装备宝石词条hp + 启灵hp
  1605. $pag = ctx()->store->equipPag;
  1606. $gemDic = ctx()->store->gemEquip->$pag; //Dictionary<E_EquipPosition, Dictionary<int, Ins_Gem>>
  1607. $per = 0;
  1608. $parasVal = 0;
  1609. $per_hp = 0;
  1610. $parasVal_hp = 0;
  1611. foreach ($equipDic as $index => $ins_equip) {
  1612. if (StlUtil::dictHasProperty($gemDic, $index)) {
  1613. $dic = $gemDic->$index;
  1614. foreach ($dic as $k => $gem) {
  1615. $ins_Gem = new Ins_Gem($gem);
  1616. if ($ins_Gem->predicateMo()->actionType == "mulDamage") {
  1617. $per += $ins_Gem->predicateMo()->actionParam1;
  1618. } elseif ($ins_Gem->predicateMo()->actionType == "addDamage") {
  1619. $parasVal += $ins_Gem->predicateMo()->actionParam1;
  1620. } elseif ($ins_Gem->predicateMo()->actionType == "mulHp") {
  1621. $per_hp += $ins_Gem->predicateMo()->actionParam1;
  1622. } elseif ($ins_Gem->predicateMo()->actionType == "addHp") {
  1623. $parasVal_hp += $ins_Gem->predicateMo()->actionParam1;
  1624. }
  1625. }
  1626. }
  1627. }
  1628. if ($per != 0) {
  1629. $heroAttck = round($heroAttck + $heroAttck * $per);
  1630. }
  1631. if ($parasVal != 0) {
  1632. $heroAttck += $parasVal;
  1633. }
  1634. if ($per_hp != 0) {
  1635. $heroHp = round($heroHp + $heroHp * $per_hp);
  1636. }
  1637. if ($parasVal_hp != 0) {
  1638. $heroHp += $parasVal_hp;
  1639. }
  1640. $dec_demage = $mo->dec_demage + $addDecDamage; # 英雄基础减伤 + 启灵减伤
  1641. $bigHit_Val = $mo->bigHit_Val;
  1642. $bigHit_rate = $mo->bigHit_rate;
  1643. $val = $heroAttck * ($heroHp - $dec_demage) * (1 + $bigHit_rate * ($bigHit_Val - 1));
  1644. return intval($val);
  1645. }
  1646. // </editor-fold>
  1647. // <editor-fold defaultstate="collapsed" desc=" 世界boss 排行榜">
  1648. /**
  1649. * 结算世界boss排行奖励[定时发放奖励接口]
  1650. */
  1651. public static function triggerSettleRankReward_worldBoss() {
  1652. //校验下是否处在发放奖励信息的时间点 【每个轮次最后一天的最后10分钟】
  1653. $mo = GameConfig::subfun_unlock_getItem(Enum_SubFunType::WorldBoss);
  1654. if ($mo == null) {
  1655. return;
  1656. }
  1657. if (now() < $mo->startTs) {
  1658. return;
  1659. }
  1660. echo '----发放世界boss的排行奖励程序开始运行-----';
  1661. $curDay = TimeUtil::totalDays();
  1662. $turnNum = self::GetCurTurnNum();
  1663. $turnnumMo = GameConfig::worldboss_turnnum_getItem($turnNum);
  1664. if ($turnnumMo != null) {
  1665. $lastDay = TimeUtil::totalDays($turnnumMo->endTs);
  1666. if ($curDay == $lastDay && $turnnumMo->endTs - now() < 600) {
  1667. $damageMemKey = self::GetWorldBoss_DamageMemKey();
  1668. echo '发放奖励的menkey===============:';
  1669. echo "$damageMemKey";
  1670. $mem = gMem();
  1671. if ($mem->exists($damageMemKey)) {
  1672. FightProc::settleRankReward_worldBoss($turnnumMo->orderId);
  1673. }
  1674. }
  1675. }
  1676. echo '----世界boss的排行奖励-发放完成----';
  1677. }
  1678. public static function settleRankReward_worldBoss($orderId) {
  1679. echo '----开始发放世界boss的排行奖励-----';
  1680. $dic = GameConfig::worldboss_rankreward();
  1681. if ($dic == null) {
  1682. return;
  1683. }
  1684. $memKey = self::GetWorldBoss_DamageMemKey();
  1685. $index = 0;
  1686. foreach ($dic as $id => $mo) {
  1687. $list = gMem()->zrevrange($memKey, $mo->rank_start - 1, $mo->rank_end - 1, true);
  1688. if (count($list) == 0) {
  1689. continue;
  1690. }
  1691. foreach ($list as $uid => $score) {
  1692. $index += 1;
  1693. self::settleDamageReward_worldBoss($orderId,$uid,$score);
  1694. EmailProc::SendWorldBossRewardMail(req()->zoneid, $uid, $mo->reward, $index);
  1695. }
  1696. }
  1697. gMem()->delete($memKey);
  1698. // $list = gMem()->zrevrange($memKey, 0, GameConfig::glc2()->WorldBoss_RankRewardStatistics, true);
  1699. // if (count($list) <= 0) {
  1700. //
  1701. // }
  1702. }
  1703. public static function settleDamageReward_worldBoss($orderId,$uid,$demageVal) {
  1704. $demageList = GameConfig::worldboss_demagereward_getItemArray($orderId);
  1705. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  1706. $worldBoss_received = $userInfo->privateState->worldBoss_received;
  1707. $dic = new \stdClass();
  1708. foreach ($demageList as $dMo) {
  1709. if ($demageVal >= $dMo->demageValId && !in_array($dMo->demageValId, $worldBoss_received)) {
  1710. if ($dMo->reward != null) {
  1711. $list = explode(';', $dMo->reward);
  1712. foreach ($list as $value) {
  1713. $strList = explode(',', $value);
  1714. $rewardId = $strList[0];
  1715. $rewardNum = $strList[1];
  1716. if(StlUtil::dictHasProperty($dic, $rewardId)){
  1717. $dic->$rewardId += $rewardNum;
  1718. } else {
  1719. $dic->$rewardId = $rewardNum;
  1720. }
  1721. }
  1722. }
  1723. }
  1724. }
  1725. $str = '';
  1726. foreach ($dic as $k => $val) {
  1727. $s = $k.','.$val;
  1728. if($str == ''){
  1729. $str = $s;
  1730. } else {
  1731. $str = $str.';'.$s;
  1732. }
  1733. }
  1734. if($str != null){
  1735. EmailProc::SendWorldBossDamageRewardMail(req()->zoneid, $uid,$str);
  1736. }
  1737. }
  1738. /**
  1739. * 重置每个赛季的开始时间 一个重置每个赛季的开始时间赛季完成后 排名数据清理掉 同时轮次要改变 [定时接口]----废弃
  1740. */
  1741. public static function ResetWorldBossRank_StartTs() {
  1742. return;
  1743. // $mo = GameConfig::subfun_unlock_getItem(Enum_SubFunType::WorldBoss);
  1744. // if ($mo == null) {
  1745. // return;
  1746. // }
  1747. // if (now() < $mo->startTs) {
  1748. // return;
  1749. // }
  1750. // echo '赛季的开始时间重置程序开始运行**********';
  1751. // $memKey = MemKey_GameRun::WorldBoss_StartTs(req()->zoneid);
  1752. // $mem = gMem();
  1753. //
  1754. // $ts = $mem->get($memKey);
  1755. // $durationTs = $mo->ts * 24 * 60 * 60;
  1756. // if ($ts == null && now() - $mo->startTs < $durationTs) {
  1757. // $mem->set($memKey, $mo->startTs);
  1758. // $ts = $mo->startTs;
  1759. // }
  1760. //
  1761. // if (now() - $ts > $durationTs) {
  1762. // $nextTs = TimeUtil::getNextDayTs($ts, $mo->ts);
  1763. // $mem->set($memKey, $nextTs); //下一轮赛季的开始时间回存
  1764. // echo '完成重置下一个赛季的开始时间';
  1765. // //清理排行榜
  1766. // self::ClearWorldBossRank();
  1767. // }
  1768. }
  1769. /**
  1770. * 清理世界boss排行榜数据
  1771. */
  1772. public static function ClearWorldBossRank() {
  1773. $mem = gMem();
  1774. $arr = array();
  1775. for ($i = 1; $i <= 9; $i++) {
  1776. $memKey = MemKey_GameRun::WorldBoss_Rank($i, req()->zoneid);
  1777. $arr[] = $memKey;
  1778. }
  1779. $mem->deleteMulti($arr);
  1780. }
  1781. /**
  1782. * 每天登录的时候 检测轮次变化
  1783. */
  1784. public static function ResetTurnNum() {
  1785. if (!FightProc::isFunUnlock(25)) {
  1786. return;
  1787. }
  1788. $subMo = GameConfig::subfun_unlock_getItem(Enum_SubFunType::WorldBoss);
  1789. if (ctx()->privateState->worldBoss_turnNum < 0) {
  1790. ctx()->privateState->worldBoss_turnNum = 0;
  1791. }
  1792. if (now() < $subMo->startTs) {
  1793. return;
  1794. }
  1795. $num = self::GetCurTurnNum();
  1796. if ($num != ctx()->privateState->worldBoss_turnNum) {
  1797. ctx()->privateState->worldBoss_turnNum = $num;
  1798. ctx()->privateState->worldBoss_received = array();
  1799. }
  1800. }
  1801. /**
  1802. * 当前所在世界boss 的轮次 //当前轮次可以算出来
  1803. */
  1804. public static function GetCurTurnNum() {
  1805. $dic = GameConfig::worldboss_turnnum();
  1806. foreach ($dic as $turnId => $mo) {
  1807. if (now() >= $mo->startTs && now() < $mo->endTs) {
  1808. return $turnId;
  1809. }
  1810. }
  1811. return 0;
  1812. // $memKey = MemKey_GameRun::WorldBoss_StartTs(req()->zoneid);
  1813. // $mem = gMem();
  1814. // $ts = $mem->get($memKey);
  1815. //
  1816. // $curDay = TimeUtil::totalDays(now());
  1817. // $lastDay = TimeUtil::totalDays($ts);
  1818. //
  1819. // $val = $curDay - $lastDay;
  1820. // $num = intval($val / 3);
  1821. //
  1822. // return $num + 1;
  1823. }
  1824. /**
  1825. * 世界boss排名榜 memkey
  1826. * @return type
  1827. */
  1828. public static function GetWorldBoss_DamageMemKey() {
  1829. $num = self::GetCurTurnNum();
  1830. $memKey = MemKey_GameRun::WorldBoss_Rank($num, req()->zoneid);
  1831. return $memKey;
  1832. }
  1833. /**
  1834. * 世界boss榜 伤害值入榜
  1835. * @param type $gateIndex
  1836. */
  1837. public static function Ranking_DamageVal($damageVal) {
  1838. //$num = self::GetCurTurnNum();
  1839. $memKey = self::GetWorldBoss_DamageMemKey(); // MemKey_GameRun::WorldBoss_Rank($num, req()->zoneid);
  1840. $mem = gMem();
  1841. $uid = req()->uid;
  1842. $val = gMem()->zscore($memKey, $uid);
  1843. if ($damageVal > $val) {
  1844. $arr = array();
  1845. $arr["$uid"] = self::createScore($damageVal);
  1846. $mem->zadd($memKey, $arr);
  1847. }
  1848. $length = $mem->zlen($memKey);
  1849. if ($length > GameConfig::glc2()->WorldBoss_RankRewardStatistics) {
  1850. $num = $length - GameConfig::glc2()->WorldBoss_RankRewardStatistics;
  1851. $mem->zremrangebyrank($memKey, 0, $num - 1);
  1852. }
  1853. }
  1854. /**
  1855. * 6826 世界boss的排名信息
  1856. * @return type
  1857. */
  1858. public static function GetWorldBoss_RankInfo() {
  1859. //list() = req()->paras;
  1860. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  1861. //$num = self::GetCurTurnNum();
  1862. //$memKey = MemKey_GameRun::WorldBoss_Rank($num, req()->zoneid);
  1863. $memKey = self::GetWorldBoss_DamageMemKey();
  1864. $list = gMem()->zrevrange($memKey, 0, GameConfig::glc2()->WorldBoss_RankRewardStatistics, true);
  1865. $rankStatistics = GameConfig::glc2()->WorldBoss_RankStatistics;
  1866. $selfRank = null;
  1867. $retArr = array();
  1868. $index = 0;
  1869. if (count($list) > 0) {
  1870. foreach ($list as $uid => $score) {
  1871. $index += 1;
  1872. $rankInfo = self::initOtherUidRankInfo($uid, $score, 3);
  1873. if ($rankInfo->uid == req()->uid && $index <= $rankStatistics) {
  1874. $selfIsHasRank = 1;
  1875. $selfRank = $rankInfo;
  1876. }
  1877. $retArr[] = $rankInfo;
  1878. }
  1879. }
  1880. if ($selfRank == null) {
  1881. $selfRank = self::initOtherUidRankInfo(req()->uid, 0);
  1882. }
  1883. UserProc::updateUserInfo();
  1884. $ret = array(
  1885. 'rankInfo' => $retArr,
  1886. 'selfRank' => $selfRank,
  1887. 'selfIsHasRank' => $selfIsHasRank,
  1888. );
  1889. return Resp::ok($ret);
  1890. }
  1891. /**
  1892. * 6827 当前轮次下 自己的最高伤害值
  1893. * @return type
  1894. */
  1895. public static function GetWorldBoss_RankDamageVal() {
  1896. $val = gMem()->zscore(self::GetWorldBoss_DamageMemKey(), req()->uid);
  1897. if ($val == null) {
  1898. $val = 0;
  1899. }
  1900. UserProc::updateUserInfo();
  1901. $ret = array(
  1902. 'DamageVal' => intval($val),
  1903. );
  1904. return Resp::ok($ret);
  1905. }
  1906. /**
  1907. * 6828 获取自己的排名信息
  1908. * @return type
  1909. */
  1910. public static function GetWorldBoss_GetSelfRank() {
  1911. // $lv = gMem()->zrevrank(self::GetWorldBoss_DamageMemKey(), req()->uid);
  1912. // if($lv == null){
  1913. // $lv = 0;
  1914. // }
  1915. $damageval = gMem()->zscore(self::GetWorldBoss_DamageMemKey(), req()->uid);
  1916. if ($damageval == null) {
  1917. $damageval = 0;
  1918. }
  1919. $ins_rank = self::initOtherUidRankInfo(req()->uid, $damageval, 3);
  1920. //$tsMemKey = MemKey_GameRun::WorldBoss_StartTs(req()->zoneid);
  1921. //$ts = gMem()->get($tsMemKey);
  1922. //ctx()->privateState->worldBoss_startTs = $ts;
  1923. UserProc::updateUserInfo();
  1924. $ret = array(
  1925. 'selfRank' => $ins_rank,
  1926. );
  1927. return Resp::ok($ret);
  1928. }
  1929. /**
  1930. * 6829 领取世界boss奖励
  1931. * @return type
  1932. */
  1933. public static function GetWorldBoss_ClaimRewards() {
  1934. list($damageValId) = req()->paras;
  1935. my_Assert(!in_array($damageValId, ctx()->privateState->worldBoss_received), ErrCode::active_hasgetted);
  1936. $val = gMem()->zscore(self::GetWorldBoss_DamageMemKey(), req()->uid);
  1937. if ($val == null) {
  1938. $val = 0;
  1939. }
  1940. my_Assert($damageValId <= $val, ErrCode::active_worldBoss_notClaimRewards);
  1941. $turnNum = self::GetCurTurnNum();
  1942. $turnnumMo = GameConfig::worldboss_turnnum_getItem($turnNum);
  1943. my_Assert($turnnumMo != null, ErrCode::err_const_no);
  1944. $list = GameConfig::worldboss_demagereward_getItemArray($turnnumMo->orderId);
  1945. foreach ($list as $key => $mo) {
  1946. if ($mo->demageValId == $damageValId && $mo->orderId == $turnnumMo->orderId) {
  1947. StoreProc::AddMultiItemInStore($mo->reward);
  1948. break;
  1949. }
  1950. }
  1951. ctx()->privateState->worldBoss_received[] = $damageValId;
  1952. UserProc::updateUserInfo();
  1953. $ret = array(
  1954. 'store' => ctx()->store,
  1955. 'cash' => ctx()->baseInfo->cash,
  1956. 'reward' => StoreProc::$reward,
  1957. 'reward_Gem' => StoreProc::$reward_Gem,
  1958. 'reward_equip' => StoreProc::$reward_equip,
  1959. );
  1960. return Resp::ok($ret);
  1961. }
  1962. /**
  1963. * 6830 世界boss结算
  1964. */
  1965. public static function WorldBoss_settle() {
  1966. list($damageNum) = req()->paras; //战斗结束伤害值
  1967. //校验每个轮次最后10分钟, 不能战斗
  1968. my_Assert(FightProc::isFunUnlock(25), ErrCode::active_funUnlock);
  1969. $tag = true;
  1970. $curDay = TimeUtil::totalDays();
  1971. $turnNum = self::GetCurTurnNum();
  1972. $turnnumMo = GameConfig::worldboss_turnnum_getItem($turnNum);
  1973. if ($turnnumMo != null) {
  1974. $lastDay = TimeUtil::totalDays($turnnumMo->endTs);
  1975. if ($curDay == $lastDay && $turnnumMo->endTs - now() < 600) {
  1976. $tag = false;
  1977. }
  1978. }
  1979. if (ctx()->privateState->worldBoss_turnNum != $turnNum){
  1980. ctx()->privateState->worldBoss_turnNum = $turnNum;
  1981. ctx()->privateState->worldBoss_received = array();
  1982. $tag = false;
  1983. }
  1984. if($tag){
  1985. self::Ranking_DamageVal($damageNum);
  1986. }
  1987. UserProc::updateUserInfo();
  1988. return Resp::ok(array());
  1989. }
  1990. // </editor-fold>
  1991. }