FightProc.php 66 KB

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