FightProc.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  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. StoreProc::AddMultiItemInStore('4,'.$waveMo->rewardExp);
  487. //ctx()->base()->Add_Exp($waveMo->rewardExp); # 指挥官经验
  488. $newLevel = ctx()->baseInfo->level;
  489. if($oldLevel != $newLevel){
  490. ctx()->privateState->oldLevel = $oldLevel;
  491. ctx()->privateState->upLevel = $newLevel;
  492. }
  493. //ctx()->base()->Add_Gold($waveMo->rewardGold); # 金币奖励
  494. //$pickups .= ";1," . $gold + $waveMo->rewardGold;
  495. $str = "1," . $gold + $waveMo->rewardGold;
  496. StoreProc::AddMultiItemInStore($str);
  497. # 图纸奖励: 数量min-max, 部位随机
  498. if (strlen($waveMo->rewardTuZhi) > 0 && str_contains($waveMo->rewardTuZhi, '-')) {
  499. list($tz_min, $tz_max) = explode('-', $waveMo->rewardTuZhi); # 图纸数量
  500. $tz_n = rand($tz_min, $tz_max);
  501. # 图纸部位数据源 1001, 1002, 1003, 1004, 1005, 1006
  502. for ($i = 0; $i < $tz_n; $i++) {
  503. $id = 1000 + rand(1, 6);
  504. StoreProc::AddMultiItemInStore("$id,1"); # 获得图纸
  505. //$pickups .= ";$id,1";
  506. }
  507. }
  508. # 宝石奖励: 数量min-max;品质:权重,品质:权重...
  509. if (strlen($waveMo->rewardGem) > 0) {
  510. list($gs_num, $gs_props) = explode(';', $waveMo->rewardGem);
  511. list($gem_min, $gem_max) = explode('-', $gs_num); # 宝石数量
  512. $gem_n = rand($gem_min, $gem_max);
  513. $arr = explode(",", $gs_props);
  514. $pool = array();
  515. $n = 0;
  516. foreach ($arr as $str) {
  517. list($qual, $props) = explode(':', $str);
  518. $pool[] = array('q' => $qual, 'p' => $props);
  519. $n += $props;
  520. }
  521. for ($i = 0; $i < $gem_n; $i++) { # 随机n块宝石
  522. $r = rand(1, $n); # 投色子
  523. $l = 0;
  524. foreach ($pool as $item) {
  525. if ($r <= ($l + $item['p'])) {
  526. $gemId = $item['q'] * 100000 + rand(1, 6) * 1000;
  527. SystemProc::GetGem_GreaterOrangeQual_MainGate(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($gateId), $gateMo->gateName, $gemId); //广播
  528. //StoreProc::PutGemInStore($gemId); # 发放宝石并退出本次投色子
  529. //$pickups .= ";$gemId,1";
  530. StoreProc::AddMultiItemInStore("$gemId,1");
  531. break;
  532. }
  533. $l += $item['p']; # 累计到下一段
  534. }
  535. }
  536. }
  537. ctx()->gates->GateList->$gateId->fightNum += 1;
  538. TaskProc::OnFightNumMainGate();
  539. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  540. TaskProc::OnKillleaderNumMonster($killBossNum);
  541. UserProc::updateUserInfo();
  542. $ret = array(
  543. 'gates' => ctx()->gates,
  544. 'store' => ctx()->store,
  545. 'task' => ctx()->task,
  546. 'baseInfo' => ctx()->base(),
  547. 'gold' => $gold + $waveMo->rewardGold,
  548. 'exp' => $waveMo->rewardExp,
  549. //'rewardStr' => $pickups
  550. 'reward' => StoreProc::$reward,
  551. 'reward_Gem' => StoreProc::$reward_Gem,
  552. 'oldLevel' => $oldLevel,
  553. 'newLevel' => $newLevel,
  554. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  555. 'skillUnlockRecord' => ctx()->privateState->skillUnlockRecord,
  556. );
  557. return Resp::ok($ret);
  558. }
  559. /**
  560. * 检测功能解锁的
  561. * @param type $resultType
  562. * @param type $gateId
  563. * @return type
  564. */
  565. static function funUnlock($resultType, $gateId) {
  566. $dic = GameConfig::fun_unlock();
  567. foreach ($dic as $id => $mo) {
  568. if ($mo->unlockTip == 1 && $mo->unlockGateId == $gateId) {
  569. $tag = false;
  570. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  571. switch ($mo->unlockType) {
  572. case 1:
  573. if (ctx()->gates->GateList->$gateId->fightNum == 0) {
  574. $tag = true;
  575. }
  576. break;
  577. case 2:
  578. if ($resultType == true && ctx()->gates->GateList->$gateId->pass == 0) {
  579. $tag = true;
  580. }
  581. break;
  582. default:
  583. break;
  584. }
  585. if ($tag) {
  586. ctx()->privateState->funUnlockRecord[] = $id;
  587. }
  588. }
  589. }
  590. }
  591. /**
  592. * 检测技能解锁的 1 关卡解锁,游玩到一定关卡解锁技能
  593. * @param type $resultType
  594. * @param type $gateId
  595. * @return type
  596. */
  597. static function skillUnlock_gate($resultType, $gateId) {
  598. $dic = GameConfig::skills();
  599. $gateIndex = Ins_GateInfo::gateNum($gateId);
  600. foreach ($dic as $id => $mo) {
  601. if ($mo->unlock_acc_id_new == null) {
  602. continue;
  603. }
  604. $strList = explode(':', $mo->unlock_acc_id_new);
  605. $unlockType = $strList[0];
  606. $unlockId = $strList[1];
  607. if($unlockType == 1 && $unlockId == $gateIndex && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
  608. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  609. }
  610. }
  611. }
  612. /**
  613. * 检测技能解锁的 2://皮肤解锁,获取到人物解锁后对应皮肤技能
  614. * @param type $resultType
  615. * @param type $gateId
  616. * @return type
  617. */
  618. static function skillUnlock_heroUnlock($heroId) {
  619. $dic = GameConfig::skills();
  620. foreach ($dic as $id => $mo) {
  621. if ($mo->unlock_acc_id_new == null) {
  622. continue;
  623. }
  624. $strList = explode(':', $mo->unlock_acc_id_new);
  625. $unlockType = $strList[0];
  626. $unlockId = $strList[1];
  627. if($unlockType != 2){
  628. continue;
  629. }
  630. $heroMo = GameConfig::hero_getItem($heroId);
  631. $heroTypeId = $heroMo->typeID;
  632. $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
  633. if($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
  634. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  635. }
  636. }
  637. }
  638. /**
  639. * 检测技能解锁的 3://玩家失败X次后解锁
  640. * @param type $resultType
  641. * @param type $gateId
  642. * @return type
  643. */
  644. static function skillUnlock_fightNum($resultType) {
  645. if(!$resultType){
  646. return;
  647. }
  648. $GateList = ctx()->gates->GateList;
  649. $num = 0;
  650. foreach ($GateList as $gateId => $Ins_GateInfo) {
  651. $num += $Ins_GateInfo->fightNum_fail;
  652. }
  653. $dic = GameConfig::skills();
  654. foreach ($dic as $id => $mo) {
  655. if ($mo->unlock_acc_id_new == null) {
  656. continue;
  657. }
  658. $strList = explode(':', $mo->unlock_acc_id_new);
  659. $unlockType = $strList[0];
  660. $unlockId = $strList[1];
  661. if($unlockType != 3){
  662. continue;
  663. }
  664. if($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
  665. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  666. }
  667. }
  668. }
  669. // <editor-fold defaultstate="collapsed" desc="排行榜">
  670. /**
  671. * 参与主线关卡排行榜
  672. * @param type $gateIndex
  673. */
  674. public static function Ranking_MainGateIndex($maxGateIndex) {
  675. $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
  676. $mem = gMem();
  677. $uid = req()->uid;
  678. $score = self::GetRankScoreUid($uid, 1);
  679. if ($maxGateIndex > $score) {
  680. $arr = array();
  681. $arr["$uid"] = self::createScore($maxGateIndex);
  682. $mem->zadd($memKey, $arr);
  683. }
  684. $length = $mem->zlen($memKey);
  685. if ($length > glc()->Rank_MainGateIndex_OnListRank) {
  686. $num = $length - glc()->Rank_MainGateIndex_OnListRank;
  687. $mem->zremrangebyrank($memKey, 0, $num - 1);
  688. }
  689. }
  690. public static function createScore($score) {
  691. if ($score > 0) {
  692. $newScore = $score . '.' . (9999999999 - now());
  693. return $newScore;
  694. }
  695. return 0;
  696. }
  697. /**
  698. * 战力榜
  699. * @param type $gateIndex
  700. */
  701. public static function Ranking_FightPower() {
  702. $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
  703. $mem = gMem();
  704. $uid = req()->uid;
  705. $score = self::GetRankScoreUid($uid, 2);
  706. $power = self::countUserFightPower();
  707. if ($power > $score) {
  708. $arr = array();
  709. $arr["$uid"] = self::createScore($power);
  710. $mem->zadd($memKey, $arr);
  711. self::IsAchievedFightPower_PassReward($power);
  712. }
  713. $length = $mem->zlen($memKey);
  714. if ($length > glc()->Rank_FightPower_OnListRank) {
  715. $num = $length - glc()->Rank_FightPower_OnListRank;
  716. $mem->zremrangebyrank($memKey, 0, $num - 1);
  717. }
  718. }
  719. public static function GetRankScoreUid($uid_rank, $type) {
  720. if ($type == 1) {
  721. $score = gMem()->zscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid_rank);
  722. } else {
  723. $score = gMem()->zscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid_rank);
  724. }
  725. if ($score == null) {
  726. $score = 0;
  727. }
  728. return intval($score);
  729. }
  730. /**
  731. * 6811 获取主线关卡排行榜信息
  732. * @return type
  733. */
  734. public static function GetRankInfo() {
  735. list($type) = req()->paras;
  736. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  737. $selfExtraInfo = 0;
  738. $isExistFinishReward = 0;
  739. $isExistFinishReward_other = 0;
  740. if ($type == 1) {
  741. $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  742. $selfExtraInfo = ctx()->gates->maxPassGateNumId();
  743. $isExistFinishReward = self::isExistNoDrawed_MainGate();
  744. $isExistFinishReward_other = self::isExistNoDrawed_FightPower();
  745. } else {
  746. $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  747. $selfExtraInfo = self::countUserFightPower();
  748. $isExistFinishReward = self::isExistNoDrawed_FightPower();
  749. $isExistFinishReward_other = self::isExistNoDrawed_MainGate();
  750. }
  751. if ($isExistFinishReward == 1) {
  752. $isExistFinishReward = true;
  753. } else {
  754. $isExistFinishReward = false;
  755. }
  756. if ($isExistFinishReward_other == 1) {
  757. $isExistFinishReward_other = true;
  758. } else {
  759. $isExistFinishReward_other = false;
  760. }
  761. $selfRank = null;
  762. $retArr = array();
  763. if (count($list) > 0) {
  764. foreach ($list as $uid => $score) {
  765. $rankInfo = self::initOtherUidRankInfo($uid, $score, $type);
  766. if ($rankInfo->uid == req()->uid) {
  767. $selfIsHasRank = 1;
  768. $selfRank = $rankInfo;
  769. }
  770. $retArr[] = $rankInfo;
  771. }
  772. }
  773. if ($selfRank == null) {
  774. $selfRank = self::initOtherUidRankInfo(req()->uid, $selfExtraInfo, $type);
  775. }
  776. UserProc::updateUserInfo();
  777. $ret = array(
  778. 'rankInfo' => $retArr,
  779. 'selfRank' => $selfRank,
  780. 'selfIsHasRank' => $selfIsHasRank,
  781. 'isExistFinishReward' => $isExistFinishReward,
  782. 'isExistFinishReward_other' => $isExistFinishReward_other,
  783. );
  784. return Resp::ok($ret);
  785. }
  786. /**
  787. * 初始化玩家rank
  788. * @param type $uid
  789. * @param type $score
  790. * @return \loyalsoft\Ins_rank
  791. */
  792. static function initOtherUidRankInfo($uid, $score, $type = null) {
  793. $ins_rank = new Ins_rank();
  794. if ($type == 1) {
  795. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  796. } else {
  797. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  798. }
  799. if ($lv == null) {
  800. $lv = 0;
  801. }
  802. $ins_rank->rank = $lv + 1;
  803. $ins_rank->uid = $uid;
  804. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  805. $ins_rank->name = $userInfo->baseInfo->name;
  806. $ins_rank->headImg = $userInfo->baseInfo->headImg;
  807. //$ret = intval($score);
  808. // if(!$isToRank){
  809. // $ret = $score;
  810. // }
  811. $ins_rank->score = intval($score);
  812. return $ins_rank;
  813. }
  814. /**
  815. * 6812 获取排行榜内玩家的装备信息
  816. * @return type
  817. */
  818. public static function GetUidEquipInfo_Rank() {
  819. list($uid) = req()->paras;
  820. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  821. $store = $userInfo->store;
  822. $heros = $userInfo->heros;
  823. UserProc::updateUserInfo();
  824. $ret = array(
  825. 'store' => $store,
  826. 'heros' => $heros,
  827. );
  828. return Resp::ok($ret);
  829. }
  830. /**
  831. * 通关奖励是否达成
  832. * @param type $maxGateIndex
  833. */
  834. public static function IsAchievedMainGate_PassReward($maxGateIndex) {
  835. $rewards = GameConfig::rank_passgatereward();
  836. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  837. foreach ($rewards as $passGateId => $mo) {
  838. if ($passGateId == $maxGateIndex && !gMem()->hexists($memKey, $maxGateIndex)) {
  839. $ins_rank = new Ins_rank();
  840. $ins_rank->uid = req()->uid;
  841. $ins_rank->name = ctx()->baseInfo->name;
  842. $ins_rank->headImg = ctx()->baseInfo->headImg;
  843. $ins_rank->score = $passGateId;
  844. gMem()->hset($memKey, $maxGateIndex, $ins_rank);
  845. break;
  846. }
  847. }
  848. }
  849. /*
  850. * 战力奖励是否达成
  851. */
  852. public static function IsAchievedFightPower_PassReward($power) {
  853. $rewards = GameConfig::rank_fightpowerreward();
  854. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  855. foreach ($rewards as $fightPower => $mo) {
  856. if ($power >= $fightPower && !gMem()->hexists($memKey, $fightPower)) {
  857. $ins_rank = new Ins_rank();
  858. $ins_rank->uid = req()->uid;
  859. $ins_rank->name = ctx()->baseInfo->name;
  860. $ins_rank->headImg = ctx()->baseInfo->headImg;
  861. $ins_rank->score = $fightPower;
  862. gMem()->hset($memKey, $fightPower, $ins_rank);
  863. }
  864. }
  865. }
  866. public static function isExistNoDrawed_MainGate() {
  867. $isExistFinishReward = 0;
  868. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  869. $dic = gMem()->hgetall($memKey);
  870. foreach ($dic as $gateId => $ins_rank) {
  871. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  872. $isExistFinishReward = 1;
  873. break;
  874. }
  875. }
  876. ctx()->privateState->redTip_RewardMainGateRank = $isExistFinishReward;
  877. return $isExistFinishReward;
  878. }
  879. public static function isExistNoDrawed_FightPower() {
  880. $isExistFinishReward = 0;
  881. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  882. $dic = gMem()->hgetall($memKey);
  883. foreach ($dic as $fightPower => $ins_rank) {
  884. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  885. $isExistFinishReward = 1;
  886. break;
  887. }
  888. }
  889. ctx()->privateState->redTip_RewardFightPowerRank = $isExistFinishReward;
  890. return $isExistFinishReward;
  891. }
  892. /**
  893. * 6813
  894. * @return type
  895. */
  896. public static function GetmainGate_RankRewardInfo() {
  897. //list($type) = req()->paras;
  898. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  899. $dic = gMem()->hgetall($memKey);
  900. if ($dic == null) {
  901. $dic = new \stdClass();
  902. }
  903. UserProc::updateUserInfo();
  904. $ret = array(
  905. 'rankReward' => $dic,
  906. );
  907. return Resp::ok($ret);
  908. }
  909. /**
  910. * 6814
  911. * @return type
  912. */
  913. public static function GetFightPower_RankRewardInfo() {
  914. //list($type) = req()->paras;
  915. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  916. $dic = gMem()->hgetall($memKey);
  917. if ($dic == null) {
  918. $dic = new \stdClass();
  919. }
  920. UserProc::updateUserInfo();
  921. $ret = array(
  922. 'rankReward' => $dic,
  923. );
  924. return Resp::ok($ret);
  925. }
  926. /**
  927. * 6815 领取通关荣誉榜奖励
  928. * @return type
  929. */
  930. public static function ReceiveRankReward_MainGate() {
  931. list($gateId) = req()->paras;
  932. my_Assert(!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate), ErrCode::rankReward_HasReceive);
  933. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  934. my_Assert($mo != null, ErrCode::err_const_no);
  935. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  936. if (gMem()->hexists($memKey, $gateId)) {
  937. StoreProc::AddMultiItemInStore($mo->reward);
  938. ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
  939. }
  940. $tag = self::isExistNoDrawed_MainGate();
  941. UserProc::updateUserInfo();
  942. $ret = array('redTip' => $tag,);
  943. return Resp::ok($ret);
  944. }
  945. /**
  946. * 6816 领取战力荣誉榜奖励
  947. * @return type
  948. */
  949. public static function ReceiveRankReward_FightPower() {
  950. list($fightPower) = req()->paras;
  951. my_Assert(!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower), ErrCode::rankReward_HasReceive);
  952. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  953. my_Assert($mo != null, ErrCode::err_const_no);
  954. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  955. if (gMem()->hexists($memKey, $fightPower)) {
  956. StoreProc::AddMultiItemInStore($mo->reward);
  957. ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
  958. }
  959. $tag = self::isExistNoDrawed_FightPower();
  960. UserProc::updateUserInfo();
  961. $ret = array('redTip' => $tag,);
  962. return Resp::ok($ret);
  963. }
  964. /**
  965. * 6817
  966. */
  967. public static function IsExistRankReward() {
  968. //list($type) = req()->paras;
  969. $type = 0;
  970. $isExistFinishReward = false;
  971. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  972. $dic = gMem()->hgetall($memKey);
  973. foreach ($dic as $gateId => $ins_rank) {
  974. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  975. $isExistFinishReward = true;
  976. $type = 1;
  977. break;
  978. }
  979. }
  980. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  981. $dic2 = gMem()->hgetall($memKey2);
  982. foreach ($dic2 as $fightPower => $ins_rank) {
  983. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  984. $isExistFinishReward = true;
  985. $type = 2;
  986. break;
  987. }
  988. }
  989. UserProc::updateUserInfo();
  990. $ret = array(
  991. 'isExistFinishReward' => $isExistFinishReward,
  992. 'type' => $type,
  993. );
  994. return Resp::ok($ret);
  995. }
  996. /*
  997. * 删除排行榜内注销账号的玩家
  998. */
  999. public static function DeleteRankInvalidUser($uid2) {
  1000. $dic1 = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  1001. foreach ($dic1 as $uid => $score) {
  1002. if ($uid == $uid2) {
  1003. gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  1004. break;
  1005. }
  1006. }
  1007. $dic2 = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1008. foreach ($dic2 as $uid => $score) {
  1009. if ($uid == $uid2) {
  1010. gMem()->zrem(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1011. break;
  1012. }
  1013. }
  1014. }
  1015. /*
  1016. * 排行玩家头像变动
  1017. */
  1018. public static function UpdateRankUserHeadImg($uid, $headImg) {
  1019. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1020. $dic = gMem()->hgetall($memKey1);
  1021. foreach ($dic as $gateId => $ins_rank) {
  1022. if ($ins_rank->uid == $uid) {
  1023. $ins_rank->headImg = $headImg;
  1024. gMem()->hset($memKey1, $gateId, $ins_rank);
  1025. }
  1026. }
  1027. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1028. $dic2 = gMem()->hgetall($memKey2);
  1029. foreach ($dic2 as $fightPower => $ins_rank) {
  1030. if ($ins_rank->uid == $uid) {
  1031. $ins_rank->headImg = $headImg;
  1032. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1033. }
  1034. }
  1035. }
  1036. /*
  1037. * 统计战力 战斗力=攻击x(生命-伤害减免值)x(1+暴击率/100x(暴击伤害倍率-1))
  1038. */
  1039. public static function countUserFightPower() {
  1040. $CurrentHeroId = ctx()->heros->CurrentHeroId;
  1041. //$hero = ctx()->heros->Dic->$CurrentHeroId;
  1042. list($addHp, $addAtk, $addDecDamage, $addEatFood) = ctx()->gates()->GetEnvovleBuffs(); // 启灵加成
  1043. $mo = GameConfig::hero_getItem($CurrentHeroId);
  1044. my_Assert($mo != null, ErrCode::err_const_no);
  1045. $heroBashAttack = $mo->attack;
  1046. $heroBashHp = $mo->hp;
  1047. $equipDic = ctx()->store->equip;
  1048. $attck = 0;
  1049. $hp = 0;
  1050. foreach ($equipDic as $index => $ins_equip) {
  1051. $Ins_Equip = new Ins_Equip($ins_equip);
  1052. if ($Ins_Equip->mo()->upgradeType == 1) {//攻击力
  1053. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1054. } elseif ($Ins_Equip->mo()->upgradeType == 2) {
  1055. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1056. } else {
  1057. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1058. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1059. }
  1060. }
  1061. $heroAttck = $heroBashAttack + $attck + $addAtk; # 英雄基础攻击力+装备宝石词条攻击力+启灵攻击力
  1062. $heroHp = $heroBashHp + $hp + $addHp; # 英雄基础hp + 装备宝石词条hp + 启灵hp
  1063. $pag = ctx()->store->equipPag;
  1064. $gemDic = ctx()->store->gemEquip->$pag; //Dictionary<E_EquipPosition, Dictionary<int, Ins_Gem>>
  1065. $per = 0;
  1066. $parasVal = 0;
  1067. $per_hp = 0;
  1068. $parasVal_hp = 0;
  1069. foreach ($equipDic as $index => $ins_equip) {
  1070. if (StlUtil::dictHasProperty($gemDic, $index)) {
  1071. $dic = $gemDic->$index;
  1072. foreach ($dic as $k => $gem) {
  1073. $ins_Gem = new Ins_Gem($gem);
  1074. if ($ins_Gem->predicateMo()->actionType == "mulDamage") {
  1075. $per += $ins_Gem->predicateMo()->actionParam1;
  1076. } elseif ($ins_Gem->predicateMo()->actionType == "addDamage") {
  1077. $parasVal += $ins_Gem->predicateMo()->actionParam1;
  1078. } elseif ($ins_Gem->predicateMo()->actionType == "mulHp") {
  1079. $per_hp += $ins_Gem->predicateMo()->actionParam1;
  1080. } elseif ($ins_Gem->predicateMo()->actionType == "addHp") {
  1081. $parasVal_hp += $ins_Gem->predicateMo()->actionParam1;
  1082. }
  1083. }
  1084. }
  1085. }
  1086. if ($per != 0) {
  1087. $heroAttck = round($heroAttck + $heroAttck * $per);
  1088. }
  1089. if ($parasVal != 0) {
  1090. $heroAttck += $parasVal;
  1091. }
  1092. if ($per_hp != 0) {
  1093. $heroHp = round($heroHp + $heroHp * $per_hp);
  1094. }
  1095. if ($parasVal_hp != 0) {
  1096. $heroHp += $parasVal_hp;
  1097. }
  1098. $dec_demage = $mo->dec_demage + $addDecDamage; # 英雄基础减伤 + 启灵减伤
  1099. $bigHit_Val = $mo->bigHit_Val / 100;
  1100. $bigHit_rate = $mo->bigHit_rate / 100;
  1101. $val = $heroAttck * ($heroHp - $dec_demage) * (1 + $bigHit_rate * ($bigHit_Val - 1));
  1102. return intval($val);
  1103. }
  1104. // </editor-fold>
  1105. }