FightProc.php 65 KB

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