FightProc.php 50 KB

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