FightProc.php 73 KB

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