FightProc.php 73 KB

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