FightProc.php 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  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_reliveCost: # 6805 战斗: 复活花费
  25. return FightProc::ReliveCost();
  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. case CmdCode::fight_rank_GetMainGateRankRewardInfo: # 6813 获取通关荣誉榜信息
  41. return self::GetmainGate_RankRewardInfo();
  42. case CmdCode::fight_rank_GetFightPowerRankRewardInfo: # 6814 获取战力荣誉榜信息
  43. return self::GetFightPower_RankRewardInfo();
  44. case CmdCode::fight_rank_ReceiveRankReward_MainGate: # 6815 领取通关荣誉榜奖励
  45. return self::ReceiveRankReward_MainGate();
  46. case CmdCode::fight_rank_ReceiveRankReward_FightPower: # 6816 领取战力荣誉榜奖励
  47. return self::ReceiveRankReward_FightPower();
  48. case CmdCode::fight_rank_IsExistRankReward: # 6817 是否存在未领取的荣誉榜奖励
  49. return self::IsExistRankReward();
  50. case CmdCode::fight_evolveUnlock: # 6818 启灵解锁
  51. return self::EvolveUnlock();
  52. default:
  53. Err(ErrCode::cmd_err);
  54. }
  55. }
  56. /**
  57. * 6805 进化解锁
  58. * @return type
  59. */
  60. public static function EvolveUnlock() {
  61. list($type, $id) = req()->paras; //$id废弃 因为玩家可能不安顺序点
  62. if ($type == 1) {
  63. $nextId = ctx()->gates->evolveMaxId_left + 1;
  64. my_Assert($id == $nextId, ErrCode::err_const_no);
  65. $mo = GameConfig::evolve_getItem($nextId);
  66. my_Assert($mo != null, ErrCode::err_const_no);
  67. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  68. my_Assert(ctx()->baseInfo->gold >= $mo->needGold_unlock, ErrCode::notenough_gold_msg);
  69. ctx()->baseInfo->Consume_Gold($mo->needGold_unlock);
  70. ctx()->gates->evolveMaxId_left = $nextId;
  71. } else {
  72. $nextId = ctx()->gates->evolveMaxId_right + 1;
  73. my_Assert($id == $nextId, ErrCode::err_const_no);
  74. $dic = GameConfig::evolve();
  75. foreach ($dic as $key => $value) {
  76. if ($value->specificEvolveId == $nextId) {
  77. $mo = $value;
  78. }
  79. }
  80. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  81. my_Assert($mo != null, ErrCode::err_const_no);
  82. if ($mo->specificEvolveCost != null) {
  83. $cost = explode(',', $mo->specificEvolveCost);
  84. $costId = $cost[0];
  85. $costNum = $cost[1];
  86. my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $costId) && ctx()->store->items->$costId >= $costNum, ErrCode::notenough_item);
  87. ctx()->store->removeItem($costId, $costNum);
  88. }
  89. ctx()->gates->evolveMaxId_right = $id;
  90. }
  91. UserProc::updateUserInfo();
  92. $ret = array(
  93. 'gold' => ctx()->baseInfo->gold,
  94. 'items' => ctx()->store->items,
  95. 'evolveMaxId_right' => ctx()->gates->evolveMaxId_right,
  96. 'evolveMaxId_left' => ctx()->gates->evolveMaxId_left,
  97. );
  98. return Resp::ok($ret);
  99. }
  100. /**
  101. * 6807 扫荡
  102. * @return type
  103. */
  104. public static function FightSweep() {
  105. //list($gateId) = req()->paras;
  106. $passGateId = ctx()->gates->maxPassGateId();
  107. my_Assert($passGateId != 0, ErrCode::gate_NoSweep);
  108. $mo = GameConfig::gate_getItem($passGateId);
  109. $gateName = $mo->gateName;
  110. $costTili = glc()->sweep_cost_tili;
  111. $curTili = ctx()->baseInfo->CurTili();
  112. my_Assert($curTili >= $costTili, ErrCode::notenough_tili);
  113. if (ctx()->privateState->honourCardShop_ts == 0) {
  114. $max = glc()->sweepMaxNum;
  115. my_Assert(ctx()->gates->fightSweepNum < $max, ErrCode::gate_SweepMaxNum_limit);
  116. }
  117. ctx()->gates->fightSweepNum += 1;
  118. ctx()->baseInfo->Consume_tili($costTili);
  119. $wavesArr = GameConfig::waves_getItemArray($passGateId);
  120. $count = count($wavesArr);
  121. $wavesMo = $wavesArr[$count - 1];
  122. $gold = $wavesMo->rewardGold;
  123. StoreProc::AddMultiItemInStore("1," . $gold);
  124. $oldLevel = ctx()->baseInfo->level;
  125. $exp = $wavesMo->rewardExp;
  126. StoreProc::AddMultiItemInStore("4," . $exp);
  127. $newLevel = ctx()->baseInfo->level;
  128. if ($wavesMo->rewardTuZhi != null) {
  129. $tuzhi = explode('-', $wavesMo->rewardTuZhi);
  130. $n = rand($tuzhi[0], $tuzhi[1]);
  131. $tuzhiArr = array();
  132. $item = GameConfig::item();
  133. foreach ($item as $id => $mo) {
  134. if ($mo->itemType == 100) {
  135. $tuzhiArr[] = $id;
  136. }
  137. }
  138. for ($i = 0; $i < $n; $i++) {
  139. $index = rand(0, count($tuzhiArr) - 1);
  140. $goodsStr = $tuzhiArr[$index] . ',' . 1;
  141. $prizeArr[] = $goodsStr;
  142. StoreProc::AddMultiItemInStore($goodsStr);
  143. }
  144. }
  145. if ($wavesMo->rewardGem != null) {
  146. $goodsStr = self::sweepRandReward($wavesMo->rewardGem);
  147. $str = explode(';', $goodsStr);
  148. $dic = GameConfig::gem();
  149. foreach ($str as $value) {
  150. $list = explode(',', $value);
  151. $posId = rand(1, 6);
  152. $qual = $list[0];
  153. foreach ($dic as $key => $gemMo) {
  154. if ($gemMo->qual == $qual && $gemMo->position == $posId) {
  155. $gemStr = $gemMo->typeId . ',' . $list[1];
  156. SystemProc::GetGem_GreaterOrangeQual_SweepMainGateIndex(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($passGateId), $gateName, $gemMo->typeId);
  157. //StoreProc::PutGemInStore($gemMo->typeId, $list[1]);
  158. StoreProc::AddMultiItemInStore($gemStr);
  159. break;
  160. }
  161. }
  162. }
  163. }
  164. UserProc::updateUserInfo();
  165. $ret = array(
  166. 'gold' => ctx()->baseInfo->gold,
  167. 'cash' => ctx()->baseInfo->cash,
  168. 'tili' => ctx()->baseInfo->tili,
  169. 'tili_ts' => ctx()->baseInfo->tili_ts,
  170. 'xp' => ctx()->baseInfo->xp,
  171. 'maxXp' => ctx()->baseInfo->maxXp,
  172. 'level' => ctx()->baseInfo->level,
  173. 'fightSweepNum' => ctx()->gates->fightSweepNum,
  174. //'prizeArr' => $prizeArr,
  175. 'store' => ctx()->store,
  176. 'task' => ctx()->task,
  177. 'reward' => StoreProc::$reward,
  178. 'reward_Gem' => StoreProc::$reward_Gem,
  179. 'oldLevel' => $oldLevel,
  180. 'newLevel' => $newLevel,
  181. );
  182. return Resp::ok($ret);
  183. }
  184. static function sweepRandReward($rewardStr) {
  185. $ctxArr = explode(';', $rewardStr);
  186. $numArr = explode('-', $ctxArr[0]);
  187. $num = rand($numArr[0], $numArr[1]);
  188. $rand = 0;
  189. $itemArr = explode(',', $ctxArr[1]);
  190. foreach ($itemArr as $value) {
  191. $arr = explode(':', $value);
  192. $itemId = $arr[0];
  193. $per = $arr[1];
  194. $rand += $per;
  195. }
  196. $res = "";
  197. for ($i = 0; $i < $num; $i++) {
  198. $start = 0;
  199. $end = 0;
  200. $randNum = rand(1, $rand);
  201. $id = 0;
  202. foreach ($itemArr as $str) {
  203. $arr = explode(':', $str);
  204. $itemId = $arr[0];
  205. $per = $arr[1];
  206. $end += $per;
  207. if ($randNum > $start && $randNum <= $end) {
  208. $id = $itemId;
  209. break;
  210. }
  211. $start = $end;
  212. }
  213. if ($id != 0) {
  214. $str = $id . ',1';
  215. if ($res == "") {
  216. $res = $str;
  217. } else {
  218. $res = $res . ';' . $str;
  219. }
  220. }
  221. }
  222. return $res;
  223. }
  224. /**
  225. * 6808 开始挑战 (主线关卡:扣除体力, 挑战关卡: 增加次数)
  226. */
  227. private static function StartFight() {
  228. list($gateId, $layerNum) = req()->paras;
  229. my_Assert($gateId > 0, ErrCode::paras_err);
  230. $mo = GameConfig::gate_getItem($gateId);
  231. my_Assert(null != $mo, ErrCode::err_const_no);
  232. if (Ints::Slice($gateId, 0, 1) == 9) { # 爬塔模式
  233. // list($layerNum) = req()->paras;
  234. if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) { # 起始层数校验
  235. Err(ErrCode::tower_layerNum);
  236. }
  237. if (ctx()->gates()->TowerGateInfo()->TodayChanNum < 1) { # 剩余次数校验
  238. Err(ErrCode::tower_timeNo);
  239. }
  240. ctx()->gates()->TowerGateInfo()->TodayChanNum--; # 增加次数
  241. } else { # 主线剧情
  242. my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
  243. }
  244. UserProc::updateUserInfo();
  245. return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
  246. }
  247. public static function FightDailyClear() {
  248. //ctx()->gates->xunluo_quick_buyRecord = 0;
  249. ctx()->gates->fightSweepNum = 0;
  250. ctx()->gates()->TowerGateInfo()->RefreshSkillTimes = 0;
  251. ctx()->gates()->TowerGateInfo()->TodayChanNum = glc()->tower_daily_chanceNum;
  252. }
  253. /**
  254. * 6806 剧情回存
  255. * @return type
  256. */
  257. public static function PlotSav() {
  258. list($gateId) = req()->paras;
  259. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no);
  260. ctx()->gates->GateList->$gateId->plotStart = 1;
  261. UserProc::updateUserInfo();
  262. $ret = array(
  263. 'ok' => 1,
  264. );
  265. return Resp::ok($ret);
  266. }
  267. // <editor-fold defaultstate="collapsed" desc="挑战模块">
  268. /**
  269. * 6810 挑战关卡: 更新锁定技能列表
  270. */
  271. public static function TowerUpdateLockskillList() {
  272. list($li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  273. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  274. $t->skill_zhudong = $li_zd;
  275. $t->skill_beidong = $li_bd;
  276. $t->skill_zhudong_lockState = $li_zds;
  277. $t->skill_beidong_lockState = $li_bds;
  278. UserProc::updateUserInfo();
  279. return Resp::ok();
  280. }
  281. /**
  282. * 6809 挑战关卡: 刷新初始技能(扣除免费次数/cost)
  283. */
  284. public static function TowerRefreshSkills() {
  285. list($isFree, $li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  286. if ($isFree) {
  287. if (ctx()->gates()->TowerGateInfo()->RefreshSkillTimes > glc()->tower_daily_refreshChanceNum) {
  288. Err(ErrCode::tower_refreshNo); # 免费次数不足
  289. }
  290. } else {
  291. list($type, $num) = explode(':', glc()->tower_refreshCost); # 二级货币类型(1:金币,2:元宝):数量
  292. if ($type == 1) { # 金币
  293. my_Assert(ctx()->base()->Consume_Gold($num), ErrCode::notenough_gold_msg);
  294. } else if ($type == 2) { # 元宝
  295. my_Assert(ctx()->base()->Consume_Cash($num), ErrCode::notenough_cash_msg);
  296. } else {
  297. Err(ErrCode::err_const_no, "检查刷新扣费配置信息!");
  298. }
  299. }
  300. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  301. $t->RefreshSkillTimes++;
  302. $t->skill_zhudong = $li_zd;
  303. $t->skill_beidong = $li_bd;
  304. $t->skill_zhudong_lockState = $li_zds;
  305. $t->skill_beidong_lockState = $li_bds;
  306. UserProc::updateUserInfo();
  307. $ret = array(
  308. 'task' => ctx()->task,
  309. );
  310. return Resp::ok($ret);
  311. }
  312. /**
  313. * 6805 战斗: 复活花费
  314. * @return type
  315. * @version 2024年5月17日 重整利用为复活扣除消耗功能
  316. */
  317. public static function ReliveCost() {
  318. // 复活可以扣除复活币(暂无)或者元宝,(客户端看广告复活不需要跟服务器通讯)
  319. list($reliveNum) = req()->paras;
  320. $arr = explode(',', glc()->Relive_cost);
  321. my_Assert($reliveNum >= 0 && $reliveNum <= Count($arr), ErrCode::paras_err); # 参数范围>0
  322. $amt = $arr[$reliveNum];
  323. my_Assert(ctx()->base()->Consume_Cash($amt), ErrCode::notenought_yuanbao);
  324. UserProc::updateUserInfo();
  325. return Resp::ok();
  326. }
  327. /**
  328. * 6804 挑战关卡: 奖励领取
  329. * @return type
  330. */
  331. public static function GateChallengeRewards() {
  332. list($finalLayer, $killedMonster, $killedBoss) = req()->paras; # 战斗结束时的层数
  333. $lastLayer = ctx()->gates()->TowerGateInfo()->CurLayer;
  334. $arr = GameConfig::waves_getItemArray(self::TowerGateId);
  335. TaskProc::OnFightNumChallengeGate();
  336. TaskProc::OnKillCommonNumMonster($killedMonster);
  337. TaskProc::OnKillleaderNumMonster($killedBoss);
  338. if ($finalLayer > $lastLayer) {
  339. foreach ($arr as $layerId => $layerMo) {
  340. if ($layerMo->waveId >= $lastLayer && $layerMo->waveId < $finalLayer) {
  341. my_Assert($layerMo != null, ErrCode::err_const_no);
  342. StoreProc::AddMultiItemInStore($layerMo->rewards); # 发放奖励
  343. }
  344. }
  345. ctx()->gates()->TowerGateInfo()->CurLayer = $finalLayer;
  346. TaskProc::OnPassLayer_ChallengeGate($finalLayer - 1);
  347. UserProc::updateUserInfo();
  348. $ret = array(
  349. 'store' => ctx()->store,
  350. 'gold' => ctx()->base()->gold,
  351. 'cash' => ctx()->base()->cash,
  352. 'task' => ctx()->task,
  353. );
  354. return Resp::ok($ret);
  355. } else if ($finalLayer == $lastLayer) {
  356. $ret = array(
  357. 'store' => ctx()->store,
  358. 'gold' => ctx()->base()->gold,
  359. 'cash' => ctx()->base()->cash,
  360. 'task' => ctx()->task,
  361. );
  362. return Resp::ok($ret);
  363. }
  364. return Resp::err(ErrCode::tower_rewardNo); # 没有奖励
  365. }
  366. // </editor-fold>
  367. /**
  368. * 6803 关卡选择
  369. * @return type
  370. */
  371. public static function SelectGate() {
  372. list($gateId) = req()->paras;
  373. ctx()->gates->CurrentGateId = $gateId;
  374. UserProc::updateUserInfo();
  375. $ret = array(
  376. 'gates' => ctx()->gates,
  377. );
  378. return Resp::ok($ret);
  379. }
  380. /**
  381. * 6802 章节宝箱的领取
  382. * @return type
  383. */
  384. public static function PassGateTsPrizeReceive() {
  385. list($gateId, $index) = req()->paras;
  386. $gateMo = GameConfig::gate_getItem($gateId);
  387. my_Assert($gateMo != null, ErrCode::err_const_no);
  388. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  389. $gateInfo = ctx()->gates->GateList->$gateId;
  390. $tag = false;
  391. $prize = "";
  392. $mask = 0;
  393. switch ($index) {
  394. case 1:
  395. $ts = $gateMo->first_ts1 * 60;
  396. if ($gateInfo->MaxSeconds >= $ts) {
  397. $tag = true;
  398. }
  399. $mask = 1;
  400. $prize = $gateMo->first_reward1;
  401. break;
  402. case 2:
  403. $ts = $gateMo->first_ts2 * 60;
  404. if ($gateInfo->MaxSeconds >= $ts) {
  405. $tag = true;
  406. }
  407. $mask = 2;
  408. $prize = $gateMo->first_reward2;
  409. break;
  410. case 3:
  411. if ($gateInfo->pass > 0) {
  412. $tag = true;
  413. }
  414. $mask = 3;
  415. $prize = $gateMo->first_reward3;
  416. break;
  417. default:
  418. break;
  419. }
  420. if ($tag) {
  421. my_Assert(!in_array($mask, $gateInfo->FirstReward), ErrCode::gate_GatePriceHasReceive);
  422. $gateInfo->FirstReward[] = $mask;
  423. StoreProc::AddMultiItemInStore($prize);
  424. }
  425. ctx()->gates->GateList->$gateId = $gateInfo;
  426. UserProc::updateUserInfo();
  427. $ret = array(
  428. 'gates' => ctx()->gates,
  429. 'store' => ctx()->store,
  430. 'task' => ctx()->task,
  431. 'gold' => ctx()->baseInfo->gold,
  432. 'cash' => ctx()->baseInfo->cash,
  433. 'reward' => StoreProc::$reward,
  434. 'reward_Gem' => StoreProc::$reward_Gem,
  435. );
  436. return Resp::ok($ret);
  437. }
  438. /**
  439. * [6801]关卡战斗结算
  440. * @return type
  441. */
  442. public static function Settle() {
  443. list($resultType, $gateId, $gold, $curTs, $pickups,
  444. $finalLayer, $finalHpPercent, $killMonsterNum, $killBossNum) = req()->paras;
  445. # 客户端需要增加参数: killmonserNum,killBosssNum, finalHpPercent(最终血量百分比)
  446. $gateMo = GameConfig::gate_getItem($gateId);
  447. my_Assert($gateMo != null, ErrCode::err_const_no);
  448. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  449. $gateInfo = ctx()->gates->GateList->$gateId;
  450. $ts = $gateInfo->MaxSeconds;
  451. if ($curTs >= $ts) {
  452. $gateInfo->MaxSeconds = $curTs;
  453. }
  454. self::funUnlock($resultType, $gateId); //备注:这个接口的位置不能动 里面有关卡第一次胜利解锁的功能提示校验
  455. if ($resultType) { # 胜利
  456. self::skillUnlock_gate($resultType, $gateId);//备注 这个接口位置不能动
  457. if (ctx()->gates->GateList->$gateId->pass == 0) {
  458. ctx()->gates->GateList->$gateId->pass = 1;
  459. TaskProc::Day7TaskReset($gateId); # 刷新七日任务
  460. $maxGateId = ctx()->gates->maxPassGateNumId();
  461. if ($maxGateId > 0) {
  462. self::Ranking_MainGateIndex($maxGateId);
  463. self::IsAchievedMainGate_PassReward($maxGateId);
  464. }
  465. }
  466. TaskProc::OnPassGate_X($gateId); # 刷新任务进度: 通关第X关
  467. if (Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate) {
  468. ctx()->gates()->UnlockNextPlotGate($gateId); # 解锁下一主线关卡
  469. // ctx()->gates()->UnlockMainChallengeGate($gateId); # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  470. } else { # 不是主线关卡, 暂时没有其他逻辑
  471. }
  472. // StoreProc::AddMultiItemInStore($gateMo->reward_win); # 发放胜利奖励(2024.5.30 过期)
  473. } else {
  474. ctx()->gates->GateList->$gateId->fightNum_fail += 1;
  475. self::skillUnlock_fightNum($resultType);//这个接口位置不能动
  476. }
  477. // else { # 失败
  478. //// StoreProc::AddMultiItemInStore($gateMo->reward_fail); # 发放失败奖励(2024.5.30 过期)
  479. // }
  480. StoreProc::AddMultiItemInStore($pickups); # 战场拾取道具直接入背包
  481. ctx()->base()->Add_Gold($gold); # 战场拾取的金币直接入背包
  482. //ctx()->base()->Add_Exp($exp);
  483. $waveMo = GameConfig::waveItem_getItem($gateId, $finalLayer);
  484. my_Assert(null != $waveMo, ErrCode::err_const_no);
  485. $oldLevel = ctx()->baseInfo->level;
  486. ctx()->base()->Add_Exp($waveMo->rewardExp); # 指挥官经验
  487. $newLevel = ctx()->baseInfo->level;
  488. ctx()->base()->Add_Gold($waveMo->rewardGold); # 金币奖励
  489. //$pickups .= ";1," . $gold + $waveMo->rewardGold;
  490. $str = "1," . $gold + $waveMo->rewardGold;
  491. StoreProc::AddMultiItemInStore($str);
  492. # 图纸奖励: 数量min-max, 部位随机
  493. if (strlen($waveMo->rewardTuZhi) > 0 && str_contains($waveMo->rewardTuZhi, '-')) {
  494. list($tz_min, $tz_max) = explode('-', $waveMo->rewardTuZhi); # 图纸数量
  495. $tz_n = rand($tz_min, $tz_max);
  496. # 图纸部位数据源 1001, 1002, 1003, 1004, 1005, 1006
  497. for ($i = 0; $i < $tz_n; $i++) {
  498. $id = 1000 + rand(1, 6);
  499. StoreProc::AddMultiItemInStore("$id,1"); # 获得图纸
  500. //$pickups .= ";$id,1";
  501. }
  502. }
  503. # 宝石奖励: 数量min-max;品质:权重,品质:权重...
  504. if (strlen($waveMo->rewardGem) > 0) {
  505. list($gs_num, $gs_props) = explode(';', $waveMo->rewardGem);
  506. list($gem_min, $gem_max) = explode('-', $gs_num); # 宝石数量
  507. $gem_n = rand($gem_min, $gem_max);
  508. $arr = explode(",", $gs_props);
  509. $pool = array();
  510. $n = 0;
  511. foreach ($arr as $str) {
  512. list($qual, $props) = explode(':', $str);
  513. $pool[] = array('q' => $qual, 'p' => $props);
  514. $n += $props;
  515. }
  516. for ($i = 0; $i < $gem_n; $i++) { # 随机n块宝石
  517. $r = rand(1, $n); # 投色子
  518. $l = 0;
  519. foreach ($pool as $item) {
  520. if ($r <= ($l + $item['p'])) {
  521. $gemId = $item['q'] * 100000 + rand(1, 6) * 1000;
  522. SystemProc::GetGem_GreaterOrangeQual_MainGate(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($gateId), $gateMo->gateName, $gemId); //广播
  523. //StoreProc::PutGemInStore($gemId); # 发放宝石并退出本次投色子
  524. //$pickups .= ";$gemId,1";
  525. StoreProc::AddMultiItemInStore("$gemId,1");
  526. break;
  527. }
  528. $l += $item['p']; # 累计到下一段
  529. }
  530. }
  531. }
  532. ctx()->gates->GateList->$gateId->fightNum += 1;
  533. TaskProc::OnFightNumMainGate();
  534. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  535. TaskProc::OnKillleaderNumMonster($killBossNum);
  536. UserProc::updateUserInfo();
  537. $ret = array(
  538. 'gates' => ctx()->gates,
  539. 'store' => ctx()->store,
  540. 'task' => ctx()->task,
  541. 'baseInfo' => ctx()->base(),
  542. 'gold' => $gold + $waveMo->rewardGold,
  543. 'exp' => $waveMo->rewardExp,
  544. //'rewardStr' => $pickups
  545. 'reward' => StoreProc::$reward,
  546. 'reward_Gem' => StoreProc::$reward_Gem,
  547. 'oldLevel' => $oldLevel,
  548. 'newLevel' => $newLevel,
  549. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  550. 'skillUnlockRecord' => ctx()->privateState->skillUnlockRecord,
  551. );
  552. return Resp::ok($ret);
  553. }
  554. /**
  555. * 检测功能解锁的
  556. * @param type $resultType
  557. * @param type $gateId
  558. * @return type
  559. */
  560. static function funUnlock($resultType, $gateId) {
  561. $dic = GameConfig::fun_unlock();
  562. foreach ($dic as $id => $mo) {
  563. if ($mo->unlockTip == 1 && $mo->unlockGateId == $gateId) {
  564. $tag = false;
  565. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  566. switch ($mo->unlockType) {
  567. case 1:
  568. if (ctx()->gates->GateList->$gateId->fightNum == 0) {
  569. $tag = true;
  570. }
  571. break;
  572. case 2:
  573. if ($resultType == true && ctx()->gates->GateList->$gateId->pass == 0) {
  574. $tag = true;
  575. }
  576. break;
  577. default:
  578. break;
  579. }
  580. if ($tag) {
  581. ctx()->privateState->funUnlockRecord[] = $id;
  582. }
  583. }
  584. }
  585. }
  586. /**
  587. * 检测技能解锁的 1 关卡解锁,游玩到一定关卡解锁技能
  588. * @param type $resultType
  589. * @param type $gateId
  590. * @return type
  591. */
  592. static function skillUnlock_gate($resultType, $gateId) {
  593. $dic = GameConfig::skills();
  594. foreach ($dic as $id => $mo) {
  595. if ($mo->unlock_acc_id_new == null) {
  596. continue;
  597. }
  598. $strList = explode(':', $mo->unlock_acc_id_new);
  599. $unlockType = $strList[0];
  600. $unlockId = $strList[1];
  601. if($unlockType == 1 && $unlockId == $gateId && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
  602. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  603. }
  604. }
  605. }
  606. /**
  607. * 检测技能解锁的 2://皮肤解锁,获取到人物解锁后对应皮肤技能
  608. * @param type $resultType
  609. * @param type $gateId
  610. * @return type
  611. */
  612. static function skillUnlock_heroUnlock($heroId) {
  613. $dic = GameConfig::skills();
  614. foreach ($dic as $id => $mo) {
  615. if ($mo->unlock_acc_id_new == null) {
  616. continue;
  617. }
  618. $strList = explode(':', $mo->unlock_acc_id_new);
  619. $unlockType = $strList[0];
  620. $unlockId = $strList[1];
  621. if($unlockType != 2){
  622. continue;
  623. }
  624. $heroMo = GameConfig::hero_getItem($heroId);
  625. $heroTypeId = $heroMo->typeID;
  626. $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
  627. if($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
  628. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  629. }
  630. }
  631. }
  632. /**
  633. * 检测技能解锁的 3://玩家失败X次后解锁
  634. * @param type $resultType
  635. * @param type $gateId
  636. * @return type
  637. */
  638. static function skillUnlock_fightNum($resultType) {
  639. if(!$resultType){
  640. return;
  641. }
  642. $GateList = ctx()->gates->GateList;
  643. $num = 0;
  644. foreach ($GateList as $gateId => $Ins_GateInfo) {
  645. $num += $Ins_GateInfo->fightNum_fail;
  646. }
  647. $dic = GameConfig::skills();
  648. foreach ($dic as $id => $mo) {
  649. if ($mo->unlock_acc_id_new == null) {
  650. continue;
  651. }
  652. $strList = explode(':', $mo->unlock_acc_id_new);
  653. $unlockType = $strList[0];
  654. $unlockId = $strList[1];
  655. if($unlockType != 3){
  656. continue;
  657. }
  658. if($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
  659. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  660. }
  661. }
  662. }
  663. // <editor-fold defaultstate="collapsed" desc="排行榜">
  664. /**
  665. * 参与主线关卡排行榜
  666. * @param type $gateIndex
  667. */
  668. public static function Ranking_MainGateIndex($maxGateIndex) {
  669. $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
  670. $mem = gMem();
  671. $uid = req()->uid;
  672. $score = self::GetRankScoreUid($uid, 1);
  673. if ($maxGateIndex > $score) {
  674. $arr = array();
  675. $arr["$uid"] = self::createScore($maxGateIndex);
  676. $mem->zadd($memKey, $arr);
  677. }
  678. $length = $mem->zlen($memKey);
  679. if ($length > glc()->Rank_MainGateIndex_OnListRank) {
  680. $num = $length - glc()->Rank_MainGateIndex_OnListRank;
  681. $mem->zremrangebyrank($memKey, 0, $num - 1);
  682. }
  683. }
  684. public static function createScore($score) {
  685. if ($score > 0) {
  686. $newScore = $score . '.' . (9999999999 - now());
  687. return $newScore;
  688. }
  689. return 0;
  690. }
  691. /**
  692. * 战力榜
  693. * @param type $gateIndex
  694. */
  695. public static function Ranking_FightPower() {
  696. $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
  697. $mem = gMem();
  698. $uid = req()->uid;
  699. $score = self::GetRankScoreUid($uid, 2);
  700. $power = self::countUserFightPower();
  701. if ($power > $score) {
  702. $arr = array();
  703. $arr["$uid"] = self::createScore($power);
  704. $mem->zadd($memKey, $arr);
  705. self::IsAchievedFightPower_PassReward($power);
  706. }
  707. $length = $mem->zlen($memKey);
  708. if ($length > glc()->Rank_FightPower_OnListRank) {
  709. $num = $length - glc()->Rank_FightPower_OnListRank;
  710. $mem->zremrangebyrank($memKey, 0, $num - 1);
  711. }
  712. }
  713. public static function GetRankScoreUid($uid_rank, $type) {
  714. if ($type == 1) {
  715. $score = gMem()->zscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid_rank);
  716. } else {
  717. $score = gMem()->zscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid_rank);
  718. }
  719. if ($score == null) {
  720. $score = 0;
  721. }
  722. return intval($score);
  723. }
  724. /**
  725. * 6811 获取主线关卡排行榜信息
  726. * @return type
  727. */
  728. public static function GetRankInfo() {
  729. list($type) = req()->paras;
  730. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  731. $selfExtraInfo = 0;
  732. $isExistFinishReward = 0;
  733. $isExistFinishReward_other = 0;
  734. if ($type == 1) {
  735. $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  736. $selfExtraInfo = ctx()->gates->maxPassGateNumId();
  737. $isExistFinishReward = self::isExistNoDrawed_MainGate();
  738. $isExistFinishReward_other = self::isExistNoDrawed_FightPower();
  739. } else {
  740. $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  741. $selfExtraInfo = self::countUserFightPower();
  742. $isExistFinishReward = self::isExistNoDrawed_FightPower();
  743. $isExistFinishReward_other = self::isExistNoDrawed_MainGate();
  744. }
  745. if ($isExistFinishReward == 1) {
  746. $isExistFinishReward = true;
  747. } else {
  748. $isExistFinishReward = false;
  749. }
  750. if ($isExistFinishReward_other == 1) {
  751. $isExistFinishReward_other = true;
  752. } else {
  753. $isExistFinishReward_other = false;
  754. }
  755. $selfRank = null;
  756. $retArr = array();
  757. if (count($list) > 0) {
  758. foreach ($list as $uid => $score) {
  759. $rankInfo = self::initOtherUidRankInfo($uid, $score, $type);
  760. if ($rankInfo->uid == req()->uid) {
  761. $selfIsHasRank = 1;
  762. $selfRank = $rankInfo;
  763. }
  764. $retArr[] = $rankInfo;
  765. }
  766. }
  767. if ($selfRank == null) {
  768. $selfRank = self::initOtherUidRankInfo(req()->uid, $selfExtraInfo, $type);
  769. }
  770. UserProc::updateUserInfo();
  771. $ret = array(
  772. 'rankInfo' => $retArr,
  773. 'selfRank' => $selfRank,
  774. 'selfIsHasRank' => $selfIsHasRank,
  775. 'isExistFinishReward' => $isExistFinishReward,
  776. 'isExistFinishReward_other' => $isExistFinishReward_other,
  777. );
  778. return Resp::ok($ret);
  779. }
  780. /**
  781. * 初始化玩家rank
  782. * @param type $uid
  783. * @param type $score
  784. * @return \loyalsoft\Ins_rank
  785. */
  786. static function initOtherUidRankInfo($uid, $score, $type = null) {
  787. $ins_rank = new Ins_rank();
  788. if ($type == 1) {
  789. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  790. } else {
  791. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  792. }
  793. if ($lv == null) {
  794. $lv = 0;
  795. }
  796. $ins_rank->rank = $lv + 1;
  797. $ins_rank->uid = $uid;
  798. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  799. $ins_rank->name = $userInfo->baseInfo->name;
  800. $ins_rank->headImg = $userInfo->baseInfo->headImg;
  801. //$ret = intval($score);
  802. // if(!$isToRank){
  803. // $ret = $score;
  804. // }
  805. $ins_rank->score = intval($score);
  806. return $ins_rank;
  807. }
  808. /**
  809. * 6812 获取排行榜内玩家的装备信息
  810. * @return type
  811. */
  812. public static function GetUidEquipInfo_Rank() {
  813. list($uid) = req()->paras;
  814. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  815. $store = $userInfo->store;
  816. $heros = $userInfo->heros;
  817. UserProc::updateUserInfo();
  818. $ret = array(
  819. 'store' => $store,
  820. 'heros' => $heros,
  821. );
  822. return Resp::ok($ret);
  823. }
  824. /**
  825. * 通关奖励是否达成
  826. * @param type $maxGateIndex
  827. */
  828. public static function IsAchievedMainGate_PassReward($maxGateIndex) {
  829. $rewards = GameConfig::rank_passgatereward();
  830. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  831. foreach ($rewards as $passGateId => $mo) {
  832. if ($passGateId == $maxGateIndex && !gMem()->hexists($memKey, $maxGateIndex)) {
  833. $ins_rank = new Ins_rank();
  834. $ins_rank->uid = req()->uid;
  835. $ins_rank->name = ctx()->baseInfo->name;
  836. $ins_rank->headImg = ctx()->baseInfo->headImg;
  837. $ins_rank->score = $passGateId;
  838. gMem()->hset($memKey, $maxGateIndex, $ins_rank);
  839. break;
  840. }
  841. }
  842. }
  843. /*
  844. * 战力奖励是否达成
  845. */
  846. public static function IsAchievedFightPower_PassReward($power) {
  847. $rewards = GameConfig::rank_fightpowerreward();
  848. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  849. foreach ($rewards as $fightPower => $mo) {
  850. if ($power >= $fightPower && !gMem()->hexists($memKey, $fightPower)) {
  851. $ins_rank = new Ins_rank();
  852. $ins_rank->uid = req()->uid;
  853. $ins_rank->name = ctx()->baseInfo->name;
  854. $ins_rank->headImg = ctx()->baseInfo->headImg;
  855. $ins_rank->score = $fightPower;
  856. gMem()->hset($memKey, $fightPower, $ins_rank);
  857. }
  858. }
  859. }
  860. public static function isExistNoDrawed_MainGate() {
  861. $isExistFinishReward = 0;
  862. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  863. $dic = gMem()->hgetall($memKey);
  864. foreach ($dic as $gateId => $ins_rank) {
  865. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  866. $isExistFinishReward = 1;
  867. break;
  868. }
  869. }
  870. ctx()->privateState->redTip_RewardMainGateRank = $isExistFinishReward;
  871. return $isExistFinishReward;
  872. }
  873. public static function isExistNoDrawed_FightPower() {
  874. $isExistFinishReward = 0;
  875. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  876. $dic = gMem()->hgetall($memKey);
  877. foreach ($dic as $fightPower => $ins_rank) {
  878. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  879. $isExistFinishReward = 1;
  880. break;
  881. }
  882. }
  883. ctx()->privateState->redTip_RewardFightPowerRank = $isExistFinishReward;
  884. return $isExistFinishReward;
  885. }
  886. /**
  887. * 6813
  888. * @return type
  889. */
  890. public static function GetmainGate_RankRewardInfo() {
  891. //list($type) = req()->paras;
  892. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  893. $dic = gMem()->hgetall($memKey);
  894. if ($dic == null) {
  895. $dic = new \stdClass();
  896. }
  897. UserProc::updateUserInfo();
  898. $ret = array(
  899. 'rankReward' => $dic,
  900. );
  901. return Resp::ok($ret);
  902. }
  903. /**
  904. * 6814
  905. * @return type
  906. */
  907. public static function GetFightPower_RankRewardInfo() {
  908. //list($type) = req()->paras;
  909. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  910. $dic = gMem()->hgetall($memKey);
  911. if ($dic == null) {
  912. $dic = new \stdClass();
  913. }
  914. UserProc::updateUserInfo();
  915. $ret = array(
  916. 'rankReward' => $dic,
  917. );
  918. return Resp::ok($ret);
  919. }
  920. /**
  921. * 6815 领取通关荣誉榜奖励
  922. * @return type
  923. */
  924. public static function ReceiveRankReward_MainGate() {
  925. list($gateId) = req()->paras;
  926. my_Assert(!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate), ErrCode::rankReward_HasReceive);
  927. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  928. my_Assert($mo != null, ErrCode::err_const_no);
  929. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  930. if (gMem()->hexists($memKey, $gateId)) {
  931. StoreProc::AddMultiItemInStore($mo->reward);
  932. ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
  933. }
  934. $tag = self::isExistNoDrawed_MainGate();
  935. UserProc::updateUserInfo();
  936. $ret = array('redTip' => $tag,);
  937. return Resp::ok($ret);
  938. }
  939. /**
  940. * 6816 领取战力荣誉榜奖励
  941. * @return type
  942. */
  943. public static function ReceiveRankReward_FightPower() {
  944. list($fightPower) = req()->paras;
  945. my_Assert(!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower), ErrCode::rankReward_HasReceive);
  946. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  947. my_Assert($mo != null, ErrCode::err_const_no);
  948. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  949. if (gMem()->hexists($memKey, $fightPower)) {
  950. StoreProc::AddMultiItemInStore($mo->reward);
  951. ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
  952. }
  953. $tag = self::isExistNoDrawed_FightPower();
  954. UserProc::updateUserInfo();
  955. $ret = array('redTip' => $tag,);
  956. return Resp::ok($ret);
  957. }
  958. /**
  959. * 6817
  960. */
  961. public static function IsExistRankReward() {
  962. //list($type) = req()->paras;
  963. $type = 0;
  964. $isExistFinishReward = false;
  965. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  966. $dic = gMem()->hgetall($memKey);
  967. foreach ($dic as $gateId => $ins_rank) {
  968. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  969. $isExistFinishReward = true;
  970. $type = 1;
  971. break;
  972. }
  973. }
  974. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  975. $dic2 = gMem()->hgetall($memKey2);
  976. foreach ($dic2 as $fightPower => $ins_rank) {
  977. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  978. $isExistFinishReward = true;
  979. $type = 2;
  980. break;
  981. }
  982. }
  983. UserProc::updateUserInfo();
  984. $ret = array(
  985. 'isExistFinishReward' => $isExistFinishReward,
  986. 'type' => $type,
  987. );
  988. return Resp::ok($ret);
  989. }
  990. /*
  991. * 删除排行榜内注销账号的玩家
  992. */
  993. public static function DeleteRankInvalidUser($uid2) {
  994. $dic1 = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  995. foreach ($dic1 as $uid => $score) {
  996. if ($uid == $uid2) {
  997. gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  998. break;
  999. }
  1000. }
  1001. $dic2 = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1002. foreach ($dic2 as $uid => $score) {
  1003. if ($uid == $uid2) {
  1004. gMem()->zrem(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1005. break;
  1006. }
  1007. }
  1008. }
  1009. /*
  1010. * 排行玩家头像变动
  1011. */
  1012. public static function UpdateRankUserHeadImg($uid, $headImg) {
  1013. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1014. $dic = gMem()->hgetall($memKey1);
  1015. foreach ($dic as $gateId => $ins_rank) {
  1016. if ($ins_rank->uid == $uid) {
  1017. $ins_rank->headImg = $headImg;
  1018. gMem()->hset($memKey1, $gateId, $ins_rank);
  1019. }
  1020. }
  1021. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1022. $dic2 = gMem()->hgetall($memKey2);
  1023. foreach ($dic2 as $fightPower => $ins_rank) {
  1024. if ($ins_rank->uid == $uid) {
  1025. $ins_rank->headImg = $headImg;
  1026. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1027. }
  1028. }
  1029. }
  1030. /*
  1031. * 统计战力 战斗力=攻击x(生命-伤害减免值)x(1+暴击率/100x(暴击伤害倍率-1))
  1032. */
  1033. public static function countUserFightPower() {
  1034. $CurrentHeroId = ctx()->heros->CurrentHeroId;
  1035. //$hero = ctx()->heros->Dic->$CurrentHeroId;
  1036. list($addHp, $addAtk, $addDecDamage, $addEatFood) = ctx()->gates()->GetEnvovleBuffs(); // 启灵加成
  1037. $mo = GameConfig::hero_getItem($CurrentHeroId);
  1038. my_Assert($mo != null, ErrCode::err_const_no);
  1039. $heroBashAttack = $mo->attack;
  1040. $heroBashHp = $mo->hp;
  1041. $equipDic = ctx()->store->equip;
  1042. $attck = 0;
  1043. $hp = 0;
  1044. foreach ($equipDic as $index => $ins_equip) {
  1045. $Ins_Equip = new Ins_Equip($ins_equip);
  1046. if ($Ins_Equip->mo()->upgradeType == 1) {//攻击力
  1047. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1048. } elseif ($Ins_Equip->mo()->upgradeType == 2) {
  1049. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1050. } else {
  1051. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1052. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1053. }
  1054. }
  1055. $heroAttck = $heroBashAttack + $attck + $addAtk; # 英雄基础攻击力+装备宝石词条攻击力+启灵攻击力
  1056. $heroHp = $heroBashHp + $hp + $addHp; # 英雄基础hp + 装备宝石词条hp + 启灵hp
  1057. $pag = ctx()->store->equipPag;
  1058. $gemDic = ctx()->store->gemEquip->$pag; //Dictionary<E_EquipPosition, Dictionary<int, Ins_Gem>>
  1059. $per = 0;
  1060. $parasVal = 0;
  1061. $per_hp = 0;
  1062. $parasVal_hp = 0;
  1063. foreach ($equipDic as $index => $ins_equip) {
  1064. if (StlUtil::dictHasProperty($gemDic, $index)) {
  1065. $dic = $gemDic->$index;
  1066. foreach ($dic as $k => $gem) {
  1067. $ins_Gem = new Ins_Gem($gem);
  1068. if ($ins_Gem->predicateMo()->actionType == "mulDamage") {
  1069. $per += $ins_Gem->predicateMo()->actionParam1;
  1070. } elseif ($ins_Gem->predicateMo()->actionType == "addDamage") {
  1071. $parasVal += $ins_Gem->predicateMo()->actionParam1;
  1072. } elseif ($ins_Gem->predicateMo()->actionType == "mulHp") {
  1073. $per_hp += $ins_Gem->predicateMo()->actionParam1;
  1074. } elseif ($ins_Gem->predicateMo()->actionType == "addHp") {
  1075. $parasVal_hp += $ins_Gem->predicateMo()->actionParam1;
  1076. }
  1077. }
  1078. }
  1079. }
  1080. if ($per != 0) {
  1081. $heroAttck = round($heroAttck + $heroAttck * $per);
  1082. }
  1083. if ($parasVal != 0) {
  1084. $heroAttck += $parasVal;
  1085. }
  1086. if ($per_hp != 0) {
  1087. $heroHp = round($heroHp + $heroHp * $per_hp);
  1088. }
  1089. if ($parasVal_hp != 0) {
  1090. $heroHp += $parasVal_hp;
  1091. }
  1092. $dec_demage = $mo->dec_demage + $addDecDamage; # 英雄基础减伤 + 启灵减伤
  1093. $bigHit_Val = $mo->bigHit_Val / 100;
  1094. $bigHit_rate = $mo->bigHit_rate / 100;
  1095. $val = $heroAttck * ($heroHp - $dec_demage) * (1 + $bigHit_rate * ($bigHit_Val - 1));
  1096. return intval($val);
  1097. }
  1098. // </editor-fold>
  1099. }