FightProc.php 49 KB

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