FightProc.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 战斗模块
  5. * @author c'y'zhao
  6. */
  7. class FightProc {
  8. public const TowerGateId = 940011999;
  9. /**
  10. * 逻辑分发
  11. * 所有的Proc中必须有这样一个方法
  12. * @param Req $req
  13. */
  14. public static function procMain($req) {
  15. switch ($req->cmd) {
  16. case CmdCode::fight_settle: # 6801 主线战斗结算
  17. return FightProc::Settle();
  18. case CmdCode::fight_PassGateTsPrizeReceive: # 6802 章节宝箱的领取
  19. return FightProc::PassGateTsPrizeReceive();
  20. case CmdCode::fight_selectGate: # 6803 主线剧情关卡选择
  21. return FightProc::SelectGate();
  22. case CmdCode::fight_gateChallengeRewards: # 6804 挑战关卡: 领取奖励
  23. return FightProc::GateChallengeRewards();
  24. case CmdCode::fihgt_towerStart: # 6805 挑战关卡: 开始挑战
  25. return FightProc::ChallengeGateStartFight();
  26. case CmdCode::fight_plotSav: # 6806 主线剧情(已播放)回存
  27. return FightProc::PlotSav();
  28. case CmdCode::fight_sweep: # 6807 主线扫荡
  29. return FightProc::FightSweep();
  30. case CmdCode::fight_startFight: # 6808 主线剧情关卡开始挑战
  31. return self::StartFight();
  32. case CmdCode::fight_tower_RefreshSkills: # 6809 挑战关卡: 刷新初始技能
  33. return self::TowerRefreshSkills();
  34. case CmdCode::fight_tower_updatelocklist: # 6810 挑战关卡: 更新技能锁定列表
  35. return self::TowerUpdateLockskillList();
  36. case CmdCode::fight_rankInfo: # 6811 获取主线关卡排行榜信息
  37. return self::GetRankInfo();
  38. case CmdCode::fight_rank_uidEquipInfo: # 6812 获取主线关卡榜内玩家的装备信息
  39. return self::GetUidEquipInfo_Rank();
  40. default:
  41. Err(ErrCode::cmd_err);
  42. }
  43. }
  44. /**
  45. * 6807 扫荡
  46. * @return type
  47. */
  48. public static function FightSweep() {
  49. //list($gateId) = req()->paras;
  50. my_Assert(ctx()->gates->UnlockedGatesMaxId != 0, ErrCode::gate_NoSweep);
  51. $mo = GameConfig::gate_getItem(ctx()->gates->UnlockedGatesMaxId);
  52. $costTili = glc()->sweep_cost_tili;
  53. my_Assert(ctx()->baseInfo->tili >= $costTili, ErrCode::notenough_tili);
  54. $max = glc()->sweepMaxNum;
  55. my_Assert(ctx()->gates->fightSweepNum < $max, ErrCode::gate_SweepMaxNum_limit);
  56. ctx()->gates->fightSweepNum += 1;
  57. ctx()->baseInfo->Consume_tili($costTili);
  58. $prizeArr = array();
  59. $prizeArr[] = $mo->reward_win;
  60. if ($mo->sweep_gold != null) {
  61. $goodsStr = self::sweepRandReward($mo->sweep_gold);
  62. $prizeArr[] = $goodsStr;
  63. StoreProc::AddMultiItemInStore($goodsStr);
  64. }
  65. if ($mo->sweep_tuzhi != null) {
  66. $goodsStr = self::sweepRandReward($mo->sweep_tuzhi);
  67. $prizeArr[] = $goodsStr;
  68. StoreProc::AddMultiItemInStore($goodsStr);
  69. }
  70. if ($mo->sweep_gem != null) {
  71. $goodsStr = self::sweepRandReward($mo->sweep_gem);
  72. $list = explode(',', $goodsStr);
  73. $posId = rand(1, 6);
  74. $qual = $list[0];
  75. $dic = GameConfig::gem();
  76. foreach ($dic as $key => $gemMo) {
  77. if ($gemMo->qual == $qual && $gemMo->position == $posId) {
  78. $prizeArr[] = $gemMo->typeId . ',' . $list[1];
  79. StoreProc::PutGemInStore($gemMo->typeId, $list[1]);
  80. break;
  81. }
  82. }
  83. }
  84. if ($mo->sweep_qiling != null) {
  85. $goodsStr = self::sweepRandReward($mo->sweep_qiling);
  86. $prizeArr[] = $goodsStr;
  87. StoreProc::AddMultiItemInStore($goodsStr);
  88. }
  89. UserProc::updateUserInfo();
  90. $ret = array(
  91. 'tili' => ctx()->baseInfo->tili,
  92. 'fightSweepNum' => ctx()->gates->fightSweepNum,
  93. 'prizeArr' => $prizeArr,
  94. 'store' => ctx()->store,
  95. 'task'=> ctx()->task,
  96. );
  97. return Resp::ok($ret);
  98. }
  99. static function sweepRandReward($rewardStr) {
  100. $ctxArr = explode(';', $rewardStr);
  101. $numArr = explode('-', $ctxArr[0]);
  102. $num = rand($numArr[0], $numArr[1]);
  103. $randNum = rand(1, 100);
  104. $start = 0;
  105. $end = 0;
  106. $res = "";
  107. $itemArr = explode(',', $ctxArr[1]);
  108. foreach ($itemArr as $str) {
  109. $arr = explode(':', $str);
  110. $itemId = $arr[0];
  111. $per = $arr[1];
  112. $end += $per;
  113. if ($randNum >= $start && $randNum < $end) {
  114. $res = $itemId;
  115. break;
  116. }
  117. $start = $end;
  118. }
  119. return $res . ',' . $num;
  120. }
  121. /**
  122. * 6808 开始挑战 (主线关卡:扣除体力, 挑战关卡: 增加次数)
  123. */
  124. private static function StartFight() {
  125. list($gateId, $layerNum) = req()->paras;
  126. my_Assert($gateId > 0, ErrCode::paras_err);
  127. $mo = GameConfig::gate_getItem($gateId);
  128. my_Assert(null != $mo, ErrCode::err_const_no);
  129. if (Ints::Slice($gateId, 0, 1) == 9) { # 爬塔模式
  130. // list($layerNum) = req()->paras;
  131. if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) { # 起始层数校验
  132. Err(ErrCode::tower_layerNum);
  133. }
  134. if (ctx()->gates()->TowerGateInfo()->TodayChanNum < 1) { # 剩余次数校验
  135. Err(ErrCode::tower_timeNo);
  136. }
  137. ctx()->gates()->TowerGateInfo()->TodayChanNum--; # 增加次数
  138. } else { # 主线剧情
  139. my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
  140. }
  141. UserProc::updateUserInfo();
  142. return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
  143. }
  144. /**
  145. * [废弃] 6807 巡逻奖励领取
  146. * @return type
  147. */
  148. public static function XunluoPrizeReceived() {
  149. list($type) = req()->paras;
  150. $gateId = ctx()->gates->UnlockedGatesMaxId;
  151. $gateMo = GameConfig::gate_getItem($gateId);
  152. my_Assert($gateMo != null, ErrCode::err_const_no);
  153. if ($type == 1) {//巡逻
  154. $curTs = now();
  155. $startTs = ctx()->gates->xunluo_StartTs;
  156. $ts = $curTs - $startTs;
  157. $ts2 = intval($ts / 60); //总的分钟数
  158. $fenzhong = intval($ts2 / 10); //有几个10分钟
  159. $gold = 0;
  160. $exp = 0;
  161. $price = "";
  162. if ($fenzhong > 0) {
  163. $gold = intval($gateMo->gold_xunluo / 6 * $fenzhong);
  164. $exp = intval($gateMo->exp_xunluo / 6 * $fenzhong);
  165. $price = "1," . $gold . ';' . "4," . $exp;
  166. }
  167. $itemStr = explode(';', $gateMo->xunluo_item_ts);
  168. $itemId = 0;
  169. $itemNum = 0;
  170. $tempTs = 0;
  171. foreach ($itemStr as $s) {
  172. $arr = explode('-', $s);
  173. $tsItemArr = explode(',', $arr[0]);
  174. $sTs = $tsItemArr[0]; //开始时间
  175. $eTs = $tsItemArr[1]; //终止时间
  176. $produceTs = $tsItemArr[2]; //间隔
  177. while (true) {
  178. $tempTs += $produceTs;
  179. if ($tempTs <= $eTs && $tempTs <= $ts2) {
  180. $sList = explode(',', $arr[1]);
  181. $itemId = $sList[0];
  182. $itemNum += $sList[1];
  183. }
  184. if ($tempTs >= $ts2) {
  185. break;
  186. }
  187. if ($tempTs >= $eTs) {
  188. $tempTs = $eTs;
  189. break;
  190. }
  191. }
  192. if ($tempTs >= $ts2) {
  193. break;
  194. }
  195. }
  196. if ($itemNum > 0) {
  197. $price = $price . ";" . $itemId . ',' . $itemNum;
  198. }
  199. //---------------------------
  200. $tuzhiStr = explode(';', $gateMo->xunluo_tuzhi_ts);
  201. $tuzhiId = 0;
  202. $tuzhiNum = 0;
  203. $tempTs2 = 0;
  204. foreach ($tuzhiStr as $s) {
  205. $arr = explode('-', $s);
  206. $tsItemArr = explode(',', $arr[0]);
  207. $sTs = $tsItemArr[0]; //开始时间
  208. $eTs = $tsItemArr[1]; //终止时间
  209. $produceTs = $tsItemArr[2]; //间隔
  210. while (true) {
  211. $tempTs2 += $produceTs;
  212. if ($tempTs2 <= $eTs && $tempTs2 <= $ts2) {
  213. $sList = explode(',', $arr[1]);
  214. $tuzhiId = $sList[0];
  215. $tuzhiNum += $sList[1];
  216. }
  217. if ($tempTs2 >= $ts2) {
  218. break;
  219. }
  220. if ($tempTs2 >= $eTs) {
  221. $tempTs2 = $eTs;
  222. break;
  223. }
  224. }
  225. if ($tempTs2 >= $ts2) {
  226. break;
  227. }
  228. }
  229. if ($tuzhiNum > 0) {
  230. $price = $price . ";" . $tuzhiId . ',' . $tuzhiNum;
  231. }
  232. //---------------------
  233. $equipStr = explode(';', $gateMo->xunluo_equip_ts);
  234. $equipId = 0;
  235. $equipNum = 0;
  236. $tempTs3 = 0;
  237. foreach ($equipStr as $s) {
  238. $arr = explode('-', $s);
  239. $tsItemArr = explode(',', $arr[0]);
  240. $sTs = $tsItemArr[0]; //开始时间
  241. $eTs = $tsItemArr[1]; //终止时间
  242. $produceTs = $tsItemArr[2]; //间隔
  243. while (true) {
  244. $tempTs3 += $produceTs;
  245. if ($tempTs3 <= $eTs && $tempTs3 <= $ts2) {
  246. $sList = explode(',', $arr[1]);
  247. $equipId = $sList[0];
  248. $equipNum += $sList[1];
  249. }
  250. if ($tempTs3 >= $ts2) {
  251. break;
  252. }
  253. if ($tempTs3 >= $eTs) {
  254. $tempTs3 = $eTs;
  255. break;
  256. }
  257. }
  258. if ($tempTs3 >= $ts2) {
  259. break;
  260. }
  261. }
  262. if ($equipNum > 0) {
  263. $price = $price . ";" . $equipId . ',' . $equipNum;
  264. }
  265. StoreProc::AddMultiItemInStore($price);
  266. ctx()->gates->xunluo_StartTs = now();
  267. } else {//快速巡逻
  268. my_Assert(ctx()->gates->xunluo_quick_buyRecord < $gateMo->xueluo_quick_num, ErrCode::err_const_no);
  269. ctx()->gates->xunluo_quick_buyRecord += 1;
  270. ctx()->baseInfo->Consume_tili(15);
  271. StoreProc::AddMultiItemInStore($gateMo->xueluo_quick_reward);
  272. }
  273. UserProc::updateUserInfo();
  274. $ret = array(
  275. 'tili' => ctx()->baseInfo->tili,
  276. 'gates' => ctx()->gates,
  277. );
  278. return Resp::ok($ret);
  279. }
  280. public static function FightDailyClear() {
  281. //ctx()->gates->xunluo_quick_buyRecord = 0;
  282. ctx()->gates->fightSweepNum = 0;
  283. ctx()->gates()->TowerGateInfo()->RefreshSkillTimes = 0;
  284. ctx()->gates()->TowerGateInfo()->TodayChanNum = glc()->tower_daily_chanceNum;
  285. }
  286. /**
  287. * 6806 剧情回存
  288. * @return type
  289. */
  290. public static function PlotSav() {
  291. list($gateId) = req()->paras;
  292. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no);
  293. ctx()->gates->GateList->$gateId->plotStart = 1;
  294. UserProc::updateUserInfo();
  295. $ret = array(
  296. 'ok' => 1,
  297. );
  298. return Resp::ok($ret);
  299. }
  300. // <editor-fold defaultstate="collapsed" desc="挑战模块">
  301. /**
  302. * 6810 挑战关卡: 更新锁定技能列表
  303. */
  304. public static function TowerUpdateLockskillList() {
  305. list($li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  306. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  307. $t->skill_zhudong = $li_zd;
  308. $t->skill_beidong = $li_bd;
  309. $t->skill_zhudong_lockState = $li_zds;
  310. $t->skill_beidong_lockState = $li_bds;
  311. UserProc::updateUserInfo();
  312. return Resp::ok();
  313. }
  314. /**
  315. * 6809 挑战关卡: 刷新初始技能(扣除免费次数/cost)
  316. */
  317. public static function TowerRefreshSkills() {
  318. list($isFree, $li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  319. if ($isFree) {
  320. if (ctx()->gates()->TowerGateInfo()->RefreshSkillTimes >= glc()->tower_daily_refreshChanceNum) {
  321. Err(ErrCode::tower_refreshNo); # 免费次数不足
  322. }
  323. } else {
  324. list($type, $num) = explode(':', glc()->tower_refreshCost); # 二级货币类型(1:金币,2:元宝):数量
  325. if ($type == 1) { # 金币
  326. my_Assert(ctx()->base()->Consume_Gold($num), ErrCode::notenough_gold_msg);
  327. } else if ($type == 2) { # 元宝
  328. my_Assert(ctx()->base()->Consume_Cash($num), ErrCode::notenough_cash_msg);
  329. } else {
  330. Err(ErrCode::err_const_no, "检查刷新扣费配置信息!");
  331. }
  332. }
  333. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  334. $t->RefreshSkillTimes++;
  335. $t->skill_zhudong = $li_zd;
  336. $t->skill_beidong = $li_bd;
  337. $t->skill_zhudong_lockState = $li_zds;
  338. $t->skill_beidong_lockState = $li_bds;
  339. UserProc::updateUserInfo();
  340. $ret = array(
  341. 'task'=> ctx()->task,
  342. );
  343. return Resp::ok($ret);
  344. }
  345. /**
  346. * 6805
  347. * @return type
  348. * @deprecated since version 2024年5月17日
  349. */
  350. public static function ChallengeGateStartFight() {
  351. list($layerNum) = req()->paras;
  352. if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) { # 起始层数校验
  353. return Resp::err(ErrCode::tower_layerNum);
  354. }
  355. if (ctx()->gates()->TowerGateInfo()->TodayChanNum < 1) { # 剩余次数校验
  356. return Resp::err(ErrCode::tower_timeNo);
  357. }
  358. ctx()->gates()->TowerGateInfo()->TodayChanNum--; # 增加次数
  359. UserProc::updateUserInfo();
  360. return Resp::ok();
  361. }
  362. /**
  363. * 6804 挑战关卡: 奖励领取
  364. * @return type
  365. */
  366. public static function GateChallengeRewards() {
  367. list($finalLayer) = req()->paras; # 战斗结束时的层数
  368. $lastLayer = ctx()->gates()->TowerGateInfo()->CurLayer;
  369. $arr = GameConfig::waves_getItemArray(self::TowerGateId);
  370. if ($finalLayer > $lastLayer) {
  371. foreach ($arr as $layerId => $layerMo) {
  372. if ($layerId >= $lastLayer && $layerId < $finalLayer) {
  373. my_Assert($layerMo != null, ErrCode::err_const_no);
  374. StoreProc::AddMultiItemInStore($layerMo->rewards); # 发放奖励
  375. }
  376. }
  377. ctx()->gates()->TowerGateInfo()->CurLayer = $finalLayer;
  378. UserProc::updateUserInfo();
  379. $ret = array(
  380. 'store' => ctx()->store,
  381. 'gold' => ctx()->base()->gold,
  382. 'cash' => ctx()->base()->cash,
  383. 'task'=> ctx()->task,
  384. );
  385. return Resp::ok($ret);
  386. }
  387. return Resp::err(ErrCode::tower_rewardNo); # 没有奖励
  388. }
  389. // </editor-fold>
  390. /**
  391. * 6803 关卡选择
  392. * @return type
  393. */
  394. public static function SelectGate() {
  395. list($gateId) = req()->paras;
  396. ctx()->gates->CurrentGateId = $gateId;
  397. UserProc::updateUserInfo();
  398. $ret = array(
  399. 'gates' => ctx()->gates,
  400. );
  401. return Resp::ok($ret);
  402. }
  403. /**
  404. * 6802 章节宝箱的领取
  405. * @return type
  406. */
  407. public static function PassGateTsPrizeReceive() {
  408. list($gateId, $index) = req()->paras;
  409. $gateMo = GameConfig::gate_getItem($gateId);
  410. my_Assert($gateMo != null, ErrCode::err_const_no);
  411. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  412. $gateInfo = ctx()->gates->GateList->$gateId;
  413. $tag = false;
  414. $prize = "";
  415. $mask = 0;
  416. switch ($index) {
  417. case 1:
  418. $ts = $gateMo->first_ts1 * 60;
  419. if ($gateInfo->MaxSeconds >= $ts) {
  420. $tag = true;
  421. }
  422. $mask = 1;
  423. $prize = $gateMo->first_reward1;
  424. break;
  425. case 2:
  426. $ts = $gateMo->first_ts2 * 60;
  427. if ($gateInfo->MaxSeconds >= $ts) {
  428. $tag = true;
  429. }
  430. $mask = 2;
  431. $prize = $gateMo->first_reward2;
  432. break;
  433. case 3:
  434. if ($gateInfo->pass > 0) {
  435. $tag = true;
  436. }
  437. $mask = 3;
  438. $prize = $gateMo->first_reward3;
  439. break;
  440. default:
  441. break;
  442. }
  443. if ($tag) {
  444. my_Assert($mask > $gateInfo->FirstReward, ErrCode::gate_GatePriceHasReceive);
  445. $gateInfo->FirstReward = $mask;
  446. StoreProc::AddMultiItemInStore($prize);
  447. }
  448. ctx()->gates->GateList->$gateId = $gateInfo;
  449. UserProc::updateUserInfo();
  450. $ret = array(
  451. 'gates' => ctx()->gates,
  452. 'store' => ctx()->store,
  453. 'task'=> ctx()->task,
  454. 'gold'=> ctx()->baseInfo->gold,
  455. );
  456. return Resp::ok($ret);
  457. }
  458. /**
  459. * [6801]关卡战斗结算
  460. * @return type
  461. */
  462. public static function Settle() {
  463. list($resultType, $gateId, $gold, $curTs, $pickups) = req()->paras;
  464. $gateMo = GameConfig::gate_getItem($gateId);
  465. my_Assert($gateMo != null, ErrCode::err_const_no);
  466. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  467. $gateInfo = ctx()->gates->GateList->$gateId;
  468. $ts = $gateInfo->MaxSeconds;
  469. if ($curTs >= $ts) {
  470. $gateInfo->MaxSeconds = $curTs;
  471. }
  472. if ($resultType) { # 胜利
  473. if (ctx()->gates->GateList->$gateId->pass == 0) {
  474. ctx()->gates->GateList->$gateId->pass = 1;
  475. TaskProc::Day7TaskReset($gateId);
  476. }
  477. TaskProc::OnPassGate_X($gateId);
  478. StoreProc::AddMultiItemInStore($gateMo->reward_win);
  479. if (Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate) {
  480. ctx()->gates->UnlockNextPlotGate();
  481. $dic = GameConfig::gate();
  482. $index = 0; # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  483. foreach ($dic as $id => $item) {
  484. if (Ins_GateInfo::GateTypeFromId($id) == Enum_GateType::MainChallengeGate && $item->challengeGateId == $gateId) {
  485. $index += 1;
  486. $gate = new Ins_GateInfo();
  487. $gate->GateId = $id;
  488. ctx()->gates->GateList->$id = $gate;
  489. }
  490. if ($index >= 3) {
  491. break;
  492. }
  493. }
  494. } else {
  495. }
  496. } else { # 失败
  497. StoreProc::AddMultiItemInStore($gateMo->reward_fail);
  498. }
  499. StoreProc::AddMultiItemInStore($pickups); # 战场拾取道具
  500. ctx()->baseInfo->Add_Gold($gold);
  501. //ctx()->baseInfo->Add_Exp($exp);
  502. if(Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate){
  503. TaskProc::OnFightNumMainGate();
  504. } else if(Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainChallengeGate){
  505. TaskProc::OnFightNumChallengeGate();
  506. }
  507. TaskProc::OnKillCommonNumMonster(1000);
  508. TaskProc::OnKillleaderNumMonster(500);
  509. UserProc::updateUserInfo();
  510. $ret = array(
  511. 'gates' => ctx()->gates,
  512. 'store' => ctx()->store,
  513. 'task'=> ctx()->task,
  514. );
  515. return Resp::ok($ret);
  516. }
  517. /**
  518. * 参与主线关卡排行榜
  519. * @param type $uid
  520. * @param type $gateIndex
  521. */
  522. public static function Ranking_MainGateIndex($uid,$maxGateIndex) {
  523. $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
  524. $mem = gMem();
  525. $arr = array();
  526. $arr["$uid"] = $maxGateIndex;
  527. $mem->zadd($memKey,$arr);
  528. $length = $mem->zlen($memKey);
  529. if($length > glc()->Rank_MainGateIndex_OnListRank){
  530. $num = $length - glc()->Rank_MainGateIndex_ShowRank;
  531. $mem->zremrangebyrank($memKey,0, $num-1);
  532. }
  533. }
  534. /**
  535. * 6811 获取主线关卡排行榜信息
  536. * @return type
  537. */
  538. public static function GetRankInfo() {
  539. list($type) = req()->paras;
  540. $selfRank = 0;
  541. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  542. $selfExtraInfo = 0;
  543. if($type == 1){
  544. $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid),0, glc()->Rank_MainGateIndex_OnListRank, true);
  545. $selfExtraInfo = ctx()->gates->UnlockedGatesMaxId;
  546. } else {
  547. $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid),0, glc()->Rank_FightPower_OnListRank, true);
  548. $selfExtraInfo = 0;//战力还没有
  549. }
  550. $retArr = array();
  551. if(count($list)>0){
  552. foreach ($list as $uid => $score) {
  553. $rankInfo = self::initOtherUidRankInfo($uid, $score);
  554. if($rankInfo->uid == req()->uid){
  555. $selfIsHasRank = 1;
  556. $selfRank = $rankInfo->rank;
  557. }
  558. $retArr[] = $rankInfo;
  559. }
  560. }
  561. UserProc::updateUserInfo();
  562. $ret = array(
  563. 'rankInfo' => $retArr,
  564. 'selfRank' =>$selfRank,
  565. 'selfIsHasRank' => $selfIsHasRank,
  566. 'selfExtraInfo'=> $selfExtraInfo,
  567. );
  568. return Resp::ok($ret);
  569. }
  570. /**
  571. * 初始化玩家rank
  572. * @param type $uid
  573. * @param type $score
  574. * @return \loyalsoft\Ins_rank
  575. */
  576. static function initOtherUidRankInfo($uid,$score) {
  577. $ins_rank = new Ins_rank();
  578. $ins_rank->rank = gMem()->zrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid)+1;
  579. $ins_rank->uid = $uid;
  580. $ins_rank->name = UserProc::getUserGame(req()->zoneid, $uid)->baseInfo->name;
  581. $ins_rank->score = $score;
  582. return $ins_rank;
  583. }
  584. /**
  585. * 6812 获取排行榜内玩家的装备信息
  586. * @return type
  587. */
  588. public static function GetUidEquipInfo_Rank() {
  589. list($uid) = req()->paras;
  590. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  591. $attackNum = 0;
  592. $hp = 0;
  593. $equip = $userInfo->store->equip;
  594. $gem = $userInfo->store->gemEquip;
  595. $equipPag = $userInfo->store->equipPag;
  596. UserProc::updateUserInfo();
  597. $ret = array(
  598. 'attackNum' => $attackNum,
  599. 'hp' =>$hp,
  600. 'equip' => $equip,
  601. 'gem'=>$gem,
  602. 'equipPag'=>$equipPag,
  603. );
  604. return Resp::ok($ret);
  605. }
  606. }