FightProc.php 57 KB

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