FightProc.php 70 KB

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