FightProc.php 68 KB

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