FightProc.php 50 KB

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