FightProc.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 战斗模块
  5. * @author c'y'zhao
  6. */
  7. class FightProc {
  8. public const TowerGateId = 940011999;
  9. /**
  10. * 逻辑分发
  11. * 所有的Proc中必须有这样一个方法
  12. * @param Req $req
  13. */
  14. public static function procMain($req) {
  15. switch ($req->cmd) {
  16. case CmdCode::fight_settle: # 6801 主线战斗结算
  17. return FightProc::Settle();
  18. case CmdCode::fight_PassGateTsPrizeReceive: # 6802 章节宝箱的领取
  19. return FightProc::PassGateTsPrizeReceive();
  20. case CmdCode::fight_selectGate: # 6803 主线剧情关卡选择
  21. return FightProc::SelectGate();
  22. case CmdCode::fight_gateChallengeRewards: # 6804 挑战关卡: 领取奖励
  23. return FightProc::GateChallengeRewards();
  24. case CmdCode::fihgt_reliveCost: # 6805 战斗: 复活花费
  25. return FightProc::ReliveCost();
  26. case CmdCode::fight_plotSav: # 6806 主线剧情(已播放)回存
  27. return FightProc::PlotSav();
  28. case CmdCode::fight_sweep: # 6807 主线扫荡
  29. return FightProc::FightSweep();
  30. case CmdCode::fight_startFight: # 6808 主线剧情关卡开始挑战
  31. return self::StartFight();
  32. case CmdCode::fight_tower_RefreshSkills: # 6809 挑战关卡: 刷新初始技能
  33. return self::TowerRefreshSkills();
  34. case CmdCode::fight_tower_updatelocklist: # 6810 挑战关卡: 更新技能锁定列表
  35. return self::TowerUpdateLockskillList();
  36. case CmdCode::fight_rankInfo: # 6811 获取主线关卡排行榜信息
  37. return self::GetRankInfo();
  38. case CmdCode::fight_rank_uidEquipInfo: # 6812 获取主线关卡榜内玩家的装备信息
  39. return self::GetUidEquipInfo_Rank();
  40. case CmdCode::fight_rank_GetMainGateRankRewardInfo: # 6813 获取通关荣誉榜信息
  41. return self::GetmainGate_RankRewardInfo();
  42. case CmdCode::fight_rank_GetFightPowerRankRewardInfo: # 6814 获取战力荣誉榜信息
  43. return self::GetFightPower_RankRewardInfo();
  44. case CmdCode::fight_rank_ReceiveRankReward_MainGate: # 6815 领取通关荣誉榜奖励
  45. return self::ReceiveRankReward_MainGate();
  46. case CmdCode::fight_rank_ReceiveRankReward_FightPower: # 6816 领取战力荣誉榜奖励
  47. return self::ReceiveRankReward_FightPower();
  48. case CmdCode::fight_rank_IsExistRankReward: # 6817 是否存在未领取的荣誉榜奖励
  49. return self::IsExistRankReward();
  50. case CmdCode::fight_evolveUnlock: # 6818 启灵解锁
  51. return self::EvolveUnlock();
  52. case CmdCode::fight_MainTZPass: # 6819 主线挑战--通关
  53. return self::MainTZPass();
  54. case CmdCode::fight_MainTZGetReward: # 6820 主线挑战--领取奖励
  55. return self::MainTZGetReward();
  56. default:
  57. Err(ErrCode::cmd_err);
  58. }
  59. }
  60. /**
  61. * 6819 主线挑战 -- 通关
  62. */
  63. static function MainTZPass() {
  64. list($gateId, $index) = req()->paras; # 关卡id, 通关难度索引(1/2/3)
  65. my_Assert(ctx()->gates()->maxPassGateId >= $gateId, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
  66. // isEditor() && $gateInfo = new Ins_GateInfo();
  67. $gateInfo = ctx()->gates()->GateList->$gateId;
  68. my_Assert($gateInfo->tz_state + 1 >= $index, ErrCode::gate_GateNoUnlock); # 通关上一难度解锁当前难度
  69. $gateInfo->tz_state = $index;
  70. UserProc::updateUserInfo();
  71. return Resp::ok();
  72. }
  73. /**
  74. * 6820 主线挑战 -- 领取奖励
  75. */
  76. static function MainTZGetReward() {
  77. list($gateId, $index) = req()->paras; # 关卡id, 通关难度索引(1/2/3)
  78. my_Assert(ctx()->gates()->maxPassGateId >= $gateId, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
  79. // isEditor() && $gateInfo = new Ins_GateInfo();
  80. $gateInfo = ctx()->gates()->GateList->$gateId;
  81. my_Assert($gateInfo->tz_state >= $index, ErrCode::gate_GateNoUnlock); # 已解锁当前难度
  82. my_Assert(Bits::GetBitValue($gateInfo->tz_rewards, $index) == false, ErrCode::gate_GatePriceHasReceive);
  83. $gateInfo->tz_rewards = Bits::SetBitValue($gateInfo->tz_rewards, $index, true); # 更新领取记录
  84. UserProc::updateUserInfo();
  85. return Resp::ok();
  86. }
  87. /**
  88. * 6805 进化解锁
  89. * @return type
  90. */
  91. public static function EvolveUnlock() {
  92. list($type, $id) = req()->paras; //$id废弃 因为玩家可能不安顺序点
  93. if ($type == 1) {
  94. $nextId = ctx()->gates->evolveMaxId_left + 1;
  95. my_Assert($id == $nextId, ErrCode::err_const_no);
  96. $mo = GameConfig::evolve_getItem($nextId);
  97. my_Assert($mo != null, ErrCode::err_const_no);
  98. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  99. my_Assert(ctx()->baseInfo->gold >= $mo->needGold_unlock, ErrCode::notenough_gold_msg);
  100. ctx()->baseInfo->Consume_Gold($mo->needGold_unlock);
  101. ctx()->gates->evolveMaxId_left = $nextId;
  102. } else {
  103. $nextId = ctx()->gates->evolveMaxId_right + 1;
  104. my_Assert($id == $nextId, ErrCode::err_const_no);
  105. $dic = GameConfig::evolve();
  106. foreach ($dic as $key => $value) {
  107. if ($value->specificEvolveId == $nextId) {
  108. $mo = $value;
  109. }
  110. }
  111. my_Assert(ctx()->baseInfo->level >= $mo->level, ErrCode::evolve_canotUnlock_levelLimit);
  112. my_Assert($mo != null, ErrCode::err_const_no);
  113. if ($mo->specificEvolveCost != null) {
  114. $cost = explode(',', $mo->specificEvolveCost);
  115. $costId = $cost[0];
  116. $costNum = $cost[1];
  117. my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $costId) && ctx()->store->items->$costId >= $costNum, ErrCode::notenough_item);
  118. ctx()->store->removeItem($costId, $costNum);
  119. }
  120. ctx()->gates->evolveMaxId_right = $id;
  121. }
  122. UserProc::updateUserInfo();
  123. $ret = array(
  124. 'gold' => ctx()->baseInfo->gold,
  125. 'items' => ctx()->store->items,
  126. 'evolveMaxId_right' => ctx()->gates->evolveMaxId_right,
  127. 'evolveMaxId_left' => ctx()->gates->evolveMaxId_left,
  128. );
  129. return Resp::ok($ret);
  130. }
  131. /**
  132. * 6807 扫荡
  133. * @return type
  134. */
  135. public static function FightSweep() {
  136. //list($gateId) = req()->paras;
  137. $passGateId = ctx()->gates->maxPassGateId();
  138. my_Assert($passGateId != 0, ErrCode::gate_NoSweep);
  139. $mo = GameConfig::gate_getItem($passGateId);
  140. $gateName = $mo->gateName;
  141. $costTili = glc()->sweep_cost_tili;
  142. $curTili = ctx()->baseInfo->CurTili();
  143. my_Assert($curTili >= $costTili, ErrCode::notenough_tili);
  144. if (ctx()->privateState->honourCardShop_ts == 0) {
  145. $max = glc()->sweepMaxNum;
  146. my_Assert(ctx()->gates->fightSweepNum < $max, ErrCode::gate_SweepMaxNum_limit);
  147. }
  148. ctx()->gates->fightSweepNum += 1;
  149. ctx()->baseInfo->Consume_tili($costTili);
  150. $wavesArr = GameConfig::waves_getItemArray($passGateId);
  151. $count = count($wavesArr);
  152. $wavesMo = $wavesArr[$count - 1];
  153. $gold = $wavesMo->rewardGold;
  154. StoreProc::AddMultiItemInStore("1," . $gold);
  155. $oldLevel = ctx()->baseInfo->level;
  156. $exp = $wavesMo->rewardExp;
  157. StoreProc::AddMultiItemInStore("4," . $exp);
  158. $newLevel = ctx()->baseInfo->level;
  159. if ($wavesMo->rewardTuZhi != null) {
  160. $tuzhi = explode('-', $wavesMo->rewardTuZhi);
  161. $n = rand($tuzhi[0], $tuzhi[1]);
  162. $tuzhiArr = array();
  163. $item = GameConfig::item();
  164. foreach ($item as $id => $mo) {
  165. if ($mo->itemType == 100) {
  166. $tuzhiArr[] = $id;
  167. }
  168. }
  169. for ($i = 0; $i < $n; $i++) {
  170. $index = rand(0, count($tuzhiArr) - 1);
  171. $goodsStr = $tuzhiArr[$index] . ',' . 1;
  172. $prizeArr[] = $goodsStr;
  173. StoreProc::AddMultiItemInStore($goodsStr);
  174. }
  175. }
  176. if ($wavesMo->rewardGem != null) {
  177. $goodsStr = self::sweepRandReward($wavesMo->rewardGem);
  178. $str = explode(';', $goodsStr);
  179. $dic = GameConfig::gem();
  180. foreach ($str as $value) {
  181. $list = explode(',', $value);
  182. $posId = rand(1, 6);
  183. $qual = $list[0];
  184. foreach ($dic as $key => $gemMo) {
  185. if ($gemMo->qual == $qual && $gemMo->position == $posId) {
  186. $gemStr = $gemMo->typeId . ',' . $list[1];
  187. SystemProc::GetGem_GreaterOrangeQual_SweepMainGateIndex(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($passGateId), $gateName, $gemMo->typeId);
  188. //StoreProc::PutGemInStore($gemMo->typeId, $list[1]);
  189. StoreProc::AddMultiItemInStore($gemStr);
  190. break;
  191. }
  192. }
  193. }
  194. }
  195. UserProc::updateUserInfo();
  196. $ret = array(
  197. 'gold' => ctx()->baseInfo->gold,
  198. 'cash' => ctx()->baseInfo->cash,
  199. 'tili' => ctx()->baseInfo->tili,
  200. 'tili_ts' => ctx()->baseInfo->tili_ts,
  201. 'xp' => ctx()->baseInfo->xp,
  202. 'maxXp' => ctx()->baseInfo->maxXp,
  203. 'level' => ctx()->baseInfo->level,
  204. 'fightSweepNum' => ctx()->gates->fightSweepNum,
  205. //'prizeArr' => $prizeArr,
  206. 'store' => ctx()->store,
  207. 'task' => ctx()->task,
  208. 'reward' => StoreProc::$reward,
  209. 'reward_Gem' => StoreProc::$reward_Gem,
  210. 'oldLevel' => $oldLevel,
  211. 'newLevel' => $newLevel,
  212. );
  213. return Resp::ok($ret);
  214. }
  215. static function sweepRandReward($rewardStr) {
  216. $ctxArr = explode(';', $rewardStr);
  217. $numArr = explode('-', $ctxArr[0]);
  218. $num = rand($numArr[0], $numArr[1]);
  219. $rand = 0;
  220. $itemArr = explode(',', $ctxArr[1]);
  221. foreach ($itemArr as $value) {
  222. $arr = explode(':', $value);
  223. $itemId = $arr[0];
  224. $per = $arr[1];
  225. $rand += $per;
  226. }
  227. $res = "";
  228. for ($i = 0; $i < $num; $i++) {
  229. $start = 0;
  230. $end = 0;
  231. $randNum = rand(1, $rand);
  232. $id = 0;
  233. foreach ($itemArr as $str) {
  234. $arr = explode(':', $str);
  235. $itemId = $arr[0];
  236. $per = $arr[1];
  237. $end += $per;
  238. if ($randNum > $start && $randNum <= $end) {
  239. $id = $itemId;
  240. break;
  241. }
  242. $start = $end;
  243. }
  244. if ($id != 0) {
  245. $str = $id . ',1';
  246. if ($res == "") {
  247. $res = $str;
  248. } else {
  249. $res = $res . ';' . $str;
  250. }
  251. }
  252. }
  253. return $res;
  254. }
  255. /**
  256. * 6808 开始挑战 (主线关卡:扣除体力, 挑战关卡: 增加次数)
  257. */
  258. private static function StartFight() {
  259. list($gateId, $layerNum) = req()->paras;
  260. my_Assert($gateId > 0, ErrCode::paras_err);
  261. $mo = GameConfig::gate_getItem($gateId);
  262. my_Assert(null != $mo, ErrCode::err_const_no);
  263. if (Ints::Slice($gateId, 0, 1) == 9) { # 爬塔模式
  264. // list($layerNum) = req()->paras;
  265. if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) { # 起始层数校验
  266. Err(ErrCode::tower_layerNum);
  267. }
  268. if (ctx()->gates()->TowerGateInfo()->TodayChanNum < 1) { # 剩余次数校验
  269. Err(ErrCode::tower_timeNo);
  270. }
  271. ctx()->gates()->TowerGateInfo()->TodayChanNum--; # 增加次数
  272. } else { # 主线剧情
  273. my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
  274. }
  275. UserProc::updateUserInfo();
  276. return Resp::ok(array("tili" => ctx()->baseInfo->tili, "tili_ts" => ctx()->baseInfo->tili_ts));
  277. }
  278. public static function FightDailyClear() {
  279. //ctx()->gates->xunluo_quick_buyRecord = 0;
  280. ctx()->gates->fightSweepNum = 0;
  281. ctx()->gates()->TowerGateInfo()->RefreshSkillTimes = 0;
  282. ctx()->gates()->TowerGateInfo()->TodayChanNum = glc()->tower_daily_chanceNum;
  283. }
  284. /**
  285. * 6806 剧情回存
  286. * @return type
  287. */
  288. public static function PlotSav() {
  289. list($gateId) = req()->paras;
  290. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::err_const_no);
  291. ctx()->gates->GateList->$gateId->plotStart = 1;
  292. UserProc::updateUserInfo();
  293. $ret = array(
  294. 'ok' => 1,
  295. );
  296. return Resp::ok($ret);
  297. }
  298. // <editor-fold defaultstate="collapsed" desc="挑战模块">
  299. /**
  300. * 6810 挑战关卡: 更新锁定技能列表
  301. */
  302. public static function TowerUpdateLockskillList() {
  303. list($li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  304. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  305. $t->skill_zhudong = $li_zd;
  306. $t->skill_beidong = $li_bd;
  307. $t->skill_zhudong_lockState = $li_zds;
  308. $t->skill_beidong_lockState = $li_bds;
  309. UserProc::updateUserInfo();
  310. return Resp::ok();
  311. }
  312. /**
  313. * 6809 挑战关卡: 刷新初始技能(扣除免费次数/cost)
  314. */
  315. public static function TowerRefreshSkills() {
  316. list($isFree, $li_zd, $li_bd, $li_zds, $li_bds) = req()->paras; # 参数解析
  317. if ($isFree) {
  318. if (ctx()->gates()->TowerGateInfo()->RefreshSkillTimes > glc()->tower_daily_refreshChanceNum) {
  319. Err(ErrCode::tower_refreshNo); # 免费次数不足
  320. }
  321. } else {
  322. list($type, $num) = explode(':', glc()->tower_refreshCost); # 二级货币类型(1:金币,2:元宝):数量
  323. if ($type == 1) { # 金币
  324. my_Assert(ctx()->base()->Consume_Gold($num), ErrCode::notenough_gold_msg);
  325. } else if ($type == 2) { # 元宝
  326. my_Assert(ctx()->base()->Consume_Cash($num), ErrCode::notenough_cash_msg);
  327. } else {
  328. Err(ErrCode::err_const_no, "检查刷新扣费配置信息!");
  329. }
  330. }
  331. $t = ctx()->gates()->TowerGateInfo(); # 记忆技能刷新结果
  332. $t->RefreshSkillTimes++;
  333. $t->skill_zhudong = $li_zd;
  334. $t->skill_beidong = $li_bd;
  335. $t->skill_zhudong_lockState = $li_zds;
  336. $t->skill_beidong_lockState = $li_bds;
  337. UserProc::updateUserInfo();
  338. $ret = array(
  339. 'task' => ctx()->task,
  340. );
  341. return Resp::ok($ret);
  342. }
  343. /**
  344. * 6805 战斗: 复活花费
  345. * @return type
  346. * @version 2024年5月17日 重整利用为复活扣除消耗功能
  347. */
  348. public static function ReliveCost() {
  349. // 复活可以扣除复活币(暂无)或者元宝,(客户端看广告复活不需要跟服务器通讯)
  350. list($reliveNum) = req()->paras;
  351. $arr = explode(',', glc()->Relive_cost);
  352. my_Assert($reliveNum >= 0 && $reliveNum <= Count($arr), ErrCode::paras_err); # 参数范围>0
  353. $amt = $arr[$reliveNum];
  354. my_Assert(ctx()->base()->Consume_Cash($amt), ErrCode::notenought_yuanbao);
  355. UserProc::updateUserInfo();
  356. return Resp::ok();
  357. }
  358. /**
  359. * 6804 挑战关卡: 奖励领取
  360. * @return type
  361. */
  362. public static function GateChallengeRewards() {
  363. list($finalLayer, $killedMonster, $killedBoss) = req()->paras; # 战斗结束时的层数
  364. $lastLayer = ctx()->gates()->TowerGateInfo()->CurLayer;
  365. $arr = GameConfig::waves_getItemArray(self::TowerGateId);
  366. TaskProc::OnFightNumChallengeGate();
  367. TaskProc::OnKillCommonNumMonster($killedMonster);
  368. TaskProc::OnKillleaderNumMonster($killedBoss);
  369. if ($finalLayer > $lastLayer) {
  370. foreach ($arr as $layerId => $layerMo) {
  371. if ($layerMo->waveId >= $lastLayer && $layerMo->waveId < $finalLayer) {
  372. my_Assert($layerMo != null, ErrCode::err_const_no);
  373. StoreProc::AddMultiItemInStore($layerMo->rewards); # 发放奖励
  374. }
  375. }
  376. ctx()->gates()->TowerGateInfo()->CurLayer = $finalLayer;
  377. TaskProc::OnPassLayer_ChallengeGate($finalLayer - 1);
  378. UserProc::updateUserInfo();
  379. $ret = array(
  380. 'store' => ctx()->store,
  381. 'gold' => ctx()->base()->gold,
  382. 'cash' => ctx()->base()->cash,
  383. 'task' => ctx()->task,
  384. );
  385. return Resp::ok($ret);
  386. } else if ($finalLayer == $lastLayer) {
  387. $ret = array(
  388. 'store' => ctx()->store,
  389. 'gold' => ctx()->base()->gold,
  390. 'cash' => ctx()->base()->cash,
  391. 'task' => ctx()->task,
  392. );
  393. return Resp::ok($ret);
  394. }
  395. return Resp::err(ErrCode::tower_rewardNo); # 没有奖励
  396. }
  397. // </editor-fold>
  398. /**
  399. * 6803 关卡选择
  400. * @return type
  401. */
  402. public static function SelectGate() {
  403. list($gateId) = req()->paras;
  404. ctx()->gates->CurrentGateId = $gateId;
  405. UserProc::updateUserInfo();
  406. $ret = array(
  407. 'gates' => ctx()->gates,
  408. );
  409. return Resp::ok($ret);
  410. }
  411. /**
  412. * 6802 章节宝箱的领取
  413. * @return type
  414. */
  415. public static function PassGateTsPrizeReceive() {
  416. list($gateId, $index) = req()->paras;
  417. $gateMo = GameConfig::gate_getItem($gateId);
  418. my_Assert($gateMo != null, ErrCode::err_const_no);
  419. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  420. $gateInfo = ctx()->gates->GateList->$gateId;
  421. $tag = false;
  422. $prize = "";
  423. $mask = 0;
  424. switch ($index) {
  425. case 1:
  426. $ts = $gateMo->first_ts1 * 60;
  427. if ($gateInfo->MaxSeconds >= $ts) {
  428. $tag = true;
  429. }
  430. $mask = 1;
  431. $prize = $gateMo->first_reward1;
  432. break;
  433. case 2:
  434. $ts = $gateMo->first_ts2 * 60;
  435. if ($gateInfo->MaxSeconds >= $ts) {
  436. $tag = true;
  437. }
  438. $mask = 2;
  439. $prize = $gateMo->first_reward2;
  440. break;
  441. case 3:
  442. if ($gateInfo->pass > 0) {
  443. $tag = true;
  444. }
  445. $mask = 3;
  446. $prize = $gateMo->first_reward3;
  447. break;
  448. default:
  449. break;
  450. }
  451. if ($tag) {
  452. my_Assert(!in_array($mask, $gateInfo->FirstReward), ErrCode::gate_GatePriceHasReceive);
  453. $gateInfo->FirstReward[] = $mask;
  454. StoreProc::AddMultiItemInStore($prize);
  455. }
  456. ctx()->gates->GateList->$gateId = $gateInfo;
  457. UserProc::updateUserInfo();
  458. $ret = array(
  459. 'gates' => ctx()->gates,
  460. 'store' => ctx()->store,
  461. 'task' => ctx()->task,
  462. 'gold' => ctx()->baseInfo->gold,
  463. 'cash' => ctx()->baseInfo->cash,
  464. 'reward' => StoreProc::$reward,
  465. 'reward_Gem' => StoreProc::$reward_Gem,
  466. );
  467. return Resp::ok($ret);
  468. }
  469. /**
  470. * [6801]关卡战斗结算
  471. * @return type
  472. */
  473. public static function Settle() {
  474. list($resultType, $gateId, $gold, $curTs, $pickups,
  475. $finalLayer, $finalHpPercent, $killMonsterNum, $killBossNum) = req()->paras;
  476. # 客户端需要增加参数: killmonserNum,killBosssNum, finalHpPercent(最终血量百分比)
  477. $gateMo = GameConfig::gate_getItem($gateId);
  478. my_Assert($gateMo != null, ErrCode::err_const_no);
  479. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::gate_NoUserGateInfo);
  480. $gateInfo = ctx()->gates->GateList->$gateId;
  481. $ts = $gateInfo->MaxSeconds;
  482. if ($curTs >= $ts) {
  483. $gateInfo->MaxSeconds = $curTs;
  484. }
  485. self::funUnlock($resultType, $gateId); //备注:这个接口的位置不能动 里面有关卡第一次胜利解锁的功能提示校验
  486. if ($resultType) { # 胜利
  487. self::skillUnlock_gate($resultType, $gateId); //备注 这个接口位置不能动
  488. if (ctx()->gates->GateList->$gateId->pass == 0) {
  489. ctx()->gates->GateList->$gateId->pass = 1;
  490. TaskProc::Day7TaskReset($gateId); # 刷新七日任务
  491. $maxGateId = ctx()->gates->maxPassGateNumId();
  492. if ($maxGateId > 0) {
  493. self::Ranking_MainGateIndex($maxGateId);
  494. self::IsAchievedMainGate_PassReward($maxGateId);
  495. }
  496. }
  497. TaskProc::OnPassGate_X($gateId); # 刷新任务进度: 通关第X关
  498. if (Ins_GateInfo::GateTypeFromId($gateId) == Enum_GateType::MainStoryGate) {
  499. ctx()->gates()->UnlockNextPlotGate($gateId); # 解锁下一主线关卡
  500. // ctx()->gates()->UnlockMainChallengeGate($gateId); # 挑战关卡解锁逻辑. -gwang 2024年4月15日
  501. } else { # 不是主线关卡, 暂时没有其他逻辑
  502. }
  503. // StoreProc::AddMultiItemInStore($gateMo->reward_win); # 发放胜利奖励(2024.5.30 过期)
  504. } else {
  505. ctx()->gates->GateList->$gateId->fightNum_fail += 1;
  506. self::skillUnlock_fightNum($resultType); //这个接口位置不能动
  507. }
  508. // else { # 失败
  509. //// StoreProc::AddMultiItemInStore($gateMo->reward_fail); # 发放失败奖励(2024.5.30 过期)
  510. // }
  511. StoreProc::AddMultiItemInStore($pickups); # 战场拾取道具直接入背包
  512. //ctx()->base()->Add_Gold($gold); # 战场拾取的金币直接入背包
  513. //ctx()->base()->Add_Exp($exp);
  514. $waveMo = GameConfig::waveItem_getItem($gateId, $finalLayer);
  515. my_Assert(null != $waveMo, ErrCode::err_const_no);
  516. $oldLevel = ctx()->baseInfo->level;
  517. StoreProc::AddMultiItemInStore('4,' . $waveMo->rewardExp);
  518. //ctx()->base()->Add_Exp($waveMo->rewardExp); # 指挥官经验
  519. $newLevel = ctx()->baseInfo->level;
  520. if ($oldLevel != $newLevel) {
  521. ctx()->privateState->oldLevel = $oldLevel;
  522. ctx()->privateState->upLevel = $newLevel;
  523. }
  524. //ctx()->base()->Add_Gold($waveMo->rewardGold); # 金币奖励
  525. //$pickups .= ";1," . $gold + $waveMo->rewardGold;
  526. $str = "1," . $gold + $waveMo->rewardGold;
  527. StoreProc::AddMultiItemInStore($str);
  528. # 图纸奖励: 数量min-max, 部位随机
  529. if (strlen($waveMo->rewardTuZhi) > 0 && str_contains($waveMo->rewardTuZhi, '-')) {
  530. list($tz_min, $tz_max) = explode('-', $waveMo->rewardTuZhi); # 图纸数量
  531. $tz_n = rand($tz_min, $tz_max);
  532. # 图纸部位数据源 1001, 1002, 1003, 1004, 1005, 1006
  533. for ($i = 0; $i < $tz_n; $i++) {
  534. $id = 1000 + rand(1, 6);
  535. StoreProc::AddMultiItemInStore("$id,1"); # 获得图纸
  536. //$pickups .= ";$id,1";
  537. }
  538. }
  539. # 宝石奖励: 数量min-max;品质:权重,品质:权重...
  540. if (strlen($waveMo->rewardGem) > 0) {
  541. list($gs_num, $gs_props) = explode(';', $waveMo->rewardGem);
  542. list($gem_min, $gem_max) = explode('-', $gs_num); # 宝石数量
  543. $gem_n = rand($gem_min, $gem_max);
  544. $arr = explode(",", $gs_props);
  545. $pool = array();
  546. $n = 0;
  547. foreach ($arr as $str) {
  548. list($qual, $props) = explode(':', $str);
  549. $pool[] = array('q' => $qual, 'p' => $props);
  550. $n += $props;
  551. }
  552. for ($i = 0; $i < $gem_n; $i++) { # 随机n块宝石
  553. $r = rand(1, $n); # 投色子
  554. $l = 0;
  555. foreach ($pool as $item) {
  556. if ($r <= ($l + $item['p'])) {
  557. $gemId = $item['q'] * 100000 + rand(1, 6) * 1000;
  558. SystemProc::GetGem_GreaterOrangeQual_MainGate(req()->zoneid, ctx()->baseInfo->name, Ins_GateInfo::gateNum($gateId), $gateMo->gateName, $gemId); //广播
  559. //StoreProc::PutGemInStore($gemId); # 发放宝石并退出本次投色子
  560. //$pickups .= ";$gemId,1";
  561. StoreProc::AddMultiItemInStore("$gemId,1");
  562. break;
  563. }
  564. $l += $item['p']; # 累计到下一段
  565. }
  566. }
  567. }
  568. ctx()->gates->GateList->$gateId->fightNum += 1;
  569. TaskProc::OnFightNumMainGate();
  570. TaskProc::OnKillCommonNumMonster($killMonsterNum);
  571. TaskProc::OnKillleaderNumMonster($killBossNum);
  572. UserProc::updateUserInfo();
  573. $ret = array(
  574. 'gates' => ctx()->gates,
  575. 'store' => ctx()->store,
  576. 'task' => ctx()->task,
  577. 'baseInfo' => ctx()->base(),
  578. 'gold' => $gold + $waveMo->rewardGold,
  579. 'exp' => $waveMo->rewardExp,
  580. //'rewardStr' => $pickups
  581. 'reward' => StoreProc::$reward,
  582. 'reward_Gem' => StoreProc::$reward_Gem,
  583. 'oldLevel' => $oldLevel,
  584. 'newLevel' => $newLevel,
  585. 'funUnlockRecord' => ctx()->privateState->funUnlockRecord,
  586. 'skillUnlockRecord' => ctx()->privateState->skillUnlockRecord,
  587. );
  588. return Resp::ok($ret);
  589. }
  590. /**
  591. * 检测功能解锁的
  592. * @param type $resultType
  593. * @param type $gateId
  594. * @return type
  595. */
  596. static function funUnlock($resultType, $gateId) {
  597. $dic = GameConfig::fun_unlock();
  598. foreach ($dic as $id => $mo) {
  599. if ($mo->unlockTip == 1 && $mo->unlockGateId == $gateId) {
  600. $tag = false;
  601. //1:参与战斗结束即可 2战斗胜利 3某场战斗参加N次数才行
  602. switch ($mo->unlockType) {
  603. case 1:
  604. if (ctx()->gates->GateList->$gateId->fightNum == 0) {
  605. $tag = true;
  606. }
  607. break;
  608. case 2:
  609. if ($resultType == true && ctx()->gates->GateList->$gateId->pass == 0) {
  610. $tag = true;
  611. }
  612. break;
  613. default:
  614. break;
  615. }
  616. if ($tag) {
  617. ctx()->privateState->funUnlockRecord[] = $id;
  618. }
  619. }
  620. }
  621. }
  622. /**
  623. * 检测技能解锁的 1 关卡解锁,游玩到一定关卡解锁技能
  624. * @param type $resultType
  625. * @param type $gateId
  626. * @return type
  627. */
  628. static function skillUnlock_gate($resultType, $gateId) {
  629. $dic = GameConfig::skills();
  630. foreach ($dic as $id => $mo) {
  631. if ($mo->unlock_acc_id_new == null) {
  632. continue;
  633. }
  634. $strList = explode(':', $mo->unlock_acc_id_new);
  635. $unlockType = $strList[0];
  636. $unlockId = $strList[1];
  637. if ($unlockType == 1 && $unlockId == $gateId && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  638. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  639. }
  640. }
  641. }
  642. /**
  643. * 检测技能解锁的 2://皮肤解锁,获取到人物解锁后对应皮肤技能
  644. * @param type $resultType
  645. * @param type $gateId
  646. * @return type
  647. */
  648. static function skillUnlock_heroUnlock($heroId) {
  649. $dic = GameConfig::skills();
  650. foreach ($dic as $id => $mo) {
  651. if ($mo->unlock_acc_id_new == null) {
  652. continue;
  653. }
  654. $strList = explode(':', $mo->unlock_acc_id_new);
  655. $unlockType = $strList[0];
  656. $unlockId = $strList[1];
  657. if ($unlockType != 2) {
  658. continue;
  659. }
  660. $heroMo = GameConfig::hero_getItem($heroId);
  661. $heroTypeId = $heroMo->typeID;
  662. $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
  663. if ($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  664. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  665. }
  666. }
  667. }
  668. /**
  669. * 检测技能解锁的 3://玩家失败X次后解锁
  670. * @param type $resultType
  671. * @param type $gateId
  672. * @return type
  673. */
  674. static function skillUnlock_fightNum($resultType) {
  675. if (!$resultType) {
  676. return;
  677. }
  678. $GateList = ctx()->gates->GateList;
  679. $num = 0;
  680. foreach ($GateList as $gateId => $Ins_GateInfo) {
  681. $num += $Ins_GateInfo->fightNum_fail;
  682. }
  683. $dic = GameConfig::skills();
  684. foreach ($dic as $id => $mo) {
  685. if ($mo->unlock_acc_id_new == null) {
  686. continue;
  687. }
  688. $strList = explode(':', $mo->unlock_acc_id_new);
  689. $unlockType = $strList[0];
  690. $unlockId = $strList[1];
  691. if ($unlockType != 3) {
  692. continue;
  693. }
  694. if ($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
  695. ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
  696. }
  697. }
  698. }
  699. // <editor-fold defaultstate="collapsed" desc="排行榜">
  700. /**
  701. * 参与主线关卡排行榜
  702. * @param type $gateIndex
  703. */
  704. public static function Ranking_MainGateIndex($maxGateIndex) {
  705. $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
  706. $mem = gMem();
  707. $uid = req()->uid;
  708. $score = self::GetRankScoreUid($uid, 1);
  709. if ($maxGateIndex > $score) {
  710. $arr = array();
  711. $arr["$uid"] = self::createScore($maxGateIndex);
  712. $mem->zadd($memKey, $arr);
  713. }
  714. $length = $mem->zlen($memKey);
  715. if ($length > glc()->Rank_MainGateIndex_OnListRank) {
  716. $num = $length - glc()->Rank_MainGateIndex_OnListRank;
  717. $mem->zremrangebyrank($memKey, 0, $num - 1);
  718. }
  719. }
  720. public static function createScore($score) {
  721. if ($score > 0) {
  722. $newScore = $score . '.' . (9999999999 - now());
  723. return $newScore;
  724. }
  725. return 0;
  726. }
  727. /**
  728. * 战力榜
  729. * @param type $gateIndex
  730. */
  731. public static function Ranking_FightPower() {
  732. $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
  733. $mem = gMem();
  734. $uid = req()->uid;
  735. $score = self::GetRankScoreUid($uid, 2);
  736. $power = self::countUserFightPower();
  737. if ($power > $score) {
  738. $arr = array();
  739. $arr["$uid"] = self::createScore($power);
  740. $mem->zadd($memKey, $arr);
  741. self::IsAchievedFightPower_PassReward($power);
  742. }
  743. $length = $mem->zlen($memKey);
  744. if ($length > glc()->Rank_FightPower_OnListRank) {
  745. $num = $length - glc()->Rank_FightPower_OnListRank;
  746. $mem->zremrangebyrank($memKey, 0, $num - 1);
  747. }
  748. }
  749. public static function GetRankScoreUid($uid_rank, $type) {
  750. if ($type == 1) {
  751. $score = gMem()->zscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid_rank);
  752. } else {
  753. $score = gMem()->zscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid_rank);
  754. }
  755. if ($score == null) {
  756. $score = 0;
  757. }
  758. return intval($score);
  759. }
  760. /**
  761. * 6811 获取主线关卡排行榜信息
  762. * @return type
  763. */
  764. public static function GetRankInfo() {
  765. list($type) = req()->paras;
  766. $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
  767. $selfExtraInfo = 0;
  768. $isExistFinishReward = 0;
  769. $isExistFinishReward_other = 0;
  770. if ($type == 1) {
  771. $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  772. $selfExtraInfo = ctx()->gates->maxPassGateNumId();
  773. $isExistFinishReward = self::isExistNoDrawed_MainGate();
  774. $isExistFinishReward_other = self::isExistNoDrawed_FightPower();
  775. } else {
  776. $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  777. $selfExtraInfo = self::countUserFightPower();
  778. $isExistFinishReward = self::isExistNoDrawed_FightPower();
  779. $isExistFinishReward_other = self::isExistNoDrawed_MainGate();
  780. }
  781. if ($isExistFinishReward == 1) {
  782. $isExistFinishReward = true;
  783. } else {
  784. $isExistFinishReward = false;
  785. }
  786. if ($isExistFinishReward_other == 1) {
  787. $isExistFinishReward_other = true;
  788. } else {
  789. $isExistFinishReward_other = false;
  790. }
  791. $selfRank = null;
  792. $retArr = array();
  793. if (count($list) > 0) {
  794. foreach ($list as $uid => $score) {
  795. $rankInfo = self::initOtherUidRankInfo($uid, $score, $type);
  796. if ($rankInfo->uid == req()->uid) {
  797. $selfIsHasRank = 1;
  798. $selfRank = $rankInfo;
  799. }
  800. $retArr[] = $rankInfo;
  801. }
  802. }
  803. if ($selfRank == null) {
  804. $selfRank = self::initOtherUidRankInfo(req()->uid, $selfExtraInfo, $type);
  805. }
  806. UserProc::updateUserInfo();
  807. $ret = array(
  808. 'rankInfo' => $retArr,
  809. 'selfRank' => $selfRank,
  810. 'selfIsHasRank' => $selfIsHasRank,
  811. 'isExistFinishReward' => $isExistFinishReward,
  812. 'isExistFinishReward_other' => $isExistFinishReward_other,
  813. );
  814. return Resp::ok($ret);
  815. }
  816. /**
  817. * 初始化玩家rank
  818. * @param type $uid
  819. * @param type $score
  820. * @return \loyalsoft\Ins_rank
  821. */
  822. static function initOtherUidRankInfo($uid, $score, $type = null) {
  823. $ins_rank = new Ins_rank();
  824. if ($type == 1) {
  825. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  826. } else {
  827. $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  828. }
  829. if ($lv == null) {
  830. $lv = 0;
  831. }
  832. $ins_rank->rank = $lv + 1;
  833. $ins_rank->uid = $uid;
  834. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  835. $ins_rank->name = $userInfo->baseInfo->name;
  836. $ins_rank->headImg = $userInfo->baseInfo->headImg;
  837. //$ret = intval($score);
  838. // if(!$isToRank){
  839. // $ret = $score;
  840. // }
  841. $ins_rank->score = intval($score);
  842. return $ins_rank;
  843. }
  844. /**
  845. * 6812 获取排行榜内玩家的装备信息
  846. * @return type
  847. */
  848. public static function GetUidEquipInfo_Rank() {
  849. list($uid) = req()->paras;
  850. $userInfo = UserProc::getUserGame(req()->zoneid, $uid);
  851. $store = $userInfo->store;
  852. $heros = $userInfo->heros;
  853. UserProc::updateUserInfo();
  854. $ret = array(
  855. 'store' => $store,
  856. 'heros' => $heros,
  857. );
  858. return Resp::ok($ret);
  859. }
  860. /**
  861. * 通关奖励是否达成
  862. * @param type $maxGateIndex
  863. */
  864. public static function IsAchievedMainGate_PassReward($maxGateIndex) {
  865. $rewards = GameConfig::rank_passgatereward();
  866. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  867. foreach ($rewards as $passGateId => $mo) {
  868. if ($passGateId == $maxGateIndex && !gMem()->hexists($memKey, $maxGateIndex)) {
  869. $ins_rank = new Ins_rank();
  870. $ins_rank->uid = req()->uid;
  871. $ins_rank->name = ctx()->baseInfo->name;
  872. $ins_rank->headImg = ctx()->baseInfo->headImg;
  873. $ins_rank->score = $passGateId;
  874. gMem()->hset($memKey, $maxGateIndex, $ins_rank);
  875. break;
  876. }
  877. }
  878. }
  879. /*
  880. * 战力奖励是否达成
  881. */
  882. public static function IsAchievedFightPower_PassReward($power) {
  883. $rewards = GameConfig::rank_fightpowerreward();
  884. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  885. foreach ($rewards as $fightPower => $mo) {
  886. if ($power >= $fightPower && !gMem()->hexists($memKey, $fightPower)) {
  887. $ins_rank = new Ins_rank();
  888. $ins_rank->uid = req()->uid;
  889. $ins_rank->name = ctx()->baseInfo->name;
  890. $ins_rank->headImg = ctx()->baseInfo->headImg;
  891. $ins_rank->score = $fightPower;
  892. gMem()->hset($memKey, $fightPower, $ins_rank);
  893. }
  894. }
  895. }
  896. public static function isExistNoDrawed_MainGate() {
  897. $isExistFinishReward = 0;
  898. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  899. $dic = gMem()->hgetall($memKey);
  900. foreach ($dic as $gateId => $ins_rank) {
  901. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  902. $isExistFinishReward = 1;
  903. break;
  904. }
  905. }
  906. ctx()->privateState->redTip_RewardMainGateRank = $isExistFinishReward;
  907. return $isExistFinishReward;
  908. }
  909. public static function isExistNoDrawed_FightPower() {
  910. $isExistFinishReward = 0;
  911. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  912. $dic = gMem()->hgetall($memKey);
  913. foreach ($dic as $fightPower => $ins_rank) {
  914. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  915. $isExistFinishReward = 1;
  916. break;
  917. }
  918. }
  919. ctx()->privateState->redTip_RewardFightPowerRank = $isExistFinishReward;
  920. return $isExistFinishReward;
  921. }
  922. /**
  923. * 6813
  924. * @return type
  925. */
  926. public static function GetmainGate_RankRewardInfo() {
  927. //list($type) = req()->paras;
  928. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  929. $dic = gMem()->hgetall($memKey);
  930. if ($dic == null) {
  931. $dic = new \stdClass();
  932. }
  933. UserProc::updateUserInfo();
  934. $ret = array(
  935. 'rankReward' => $dic,
  936. );
  937. return Resp::ok($ret);
  938. }
  939. /**
  940. * 6814
  941. * @return type
  942. */
  943. public static function GetFightPower_RankRewardInfo() {
  944. //list($type) = req()->paras;
  945. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  946. $dic = gMem()->hgetall($memKey);
  947. if ($dic == null) {
  948. $dic = new \stdClass();
  949. }
  950. UserProc::updateUserInfo();
  951. $ret = array(
  952. 'rankReward' => $dic,
  953. );
  954. return Resp::ok($ret);
  955. }
  956. /**
  957. * 6815 领取通关荣誉榜奖励
  958. * @return type
  959. */
  960. public static function ReceiveRankReward_MainGate() {
  961. list($gateId) = req()->paras;
  962. my_Assert(!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate), ErrCode::rankReward_HasReceive);
  963. $mo = GameConfig::rank_passgatereward_getItem($gateId);
  964. my_Assert($mo != null, ErrCode::err_const_no);
  965. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  966. if (gMem()->hexists($memKey, $gateId)) {
  967. StoreProc::AddMultiItemInStore($mo->reward);
  968. ctx()->privateState->rankReward_drawed_MainGate[] = $gateId;
  969. }
  970. $tag = self::isExistNoDrawed_MainGate();
  971. UserProc::updateUserInfo();
  972. $ret = array('redTip' => $tag,);
  973. return Resp::ok($ret);
  974. }
  975. /**
  976. * 6816 领取战力荣誉榜奖励
  977. * @return type
  978. */
  979. public static function ReceiveRankReward_FightPower() {
  980. list($fightPower) = req()->paras;
  981. my_Assert(!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower), ErrCode::rankReward_HasReceive);
  982. $mo = GameConfig::rank_fightpowerreward_getItem($fightPower);
  983. my_Assert($mo != null, ErrCode::err_const_no);
  984. $memKey = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  985. if (gMem()->hexists($memKey, $fightPower)) {
  986. StoreProc::AddMultiItemInStore($mo->reward);
  987. ctx()->privateState->rankReward_drawed_fightPower[] = $fightPower;
  988. }
  989. $tag = self::isExistNoDrawed_FightPower();
  990. UserProc::updateUserInfo();
  991. $ret = array('redTip' => $tag,);
  992. return Resp::ok($ret);
  993. }
  994. /**
  995. * 6817
  996. */
  997. public static function IsExistRankReward() {
  998. //list($type) = req()->paras;
  999. $type = 0;
  1000. $isExistFinishReward = false;
  1001. $memKey = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1002. $dic = gMem()->hgetall($memKey);
  1003. foreach ($dic as $gateId => $ins_rank) {
  1004. if (!in_array($gateId, ctx()->privateState->rankReward_drawed_MainGate)) {
  1005. $isExistFinishReward = true;
  1006. $type = 1;
  1007. break;
  1008. }
  1009. }
  1010. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1011. $dic2 = gMem()->hgetall($memKey2);
  1012. foreach ($dic2 as $fightPower => $ins_rank) {
  1013. if (!in_array($fightPower, ctx()->privateState->rankReward_drawed_fightPower)) {
  1014. $isExistFinishReward = true;
  1015. $type = 2;
  1016. break;
  1017. }
  1018. }
  1019. UserProc::updateUserInfo();
  1020. $ret = array(
  1021. 'isExistFinishReward' => $isExistFinishReward,
  1022. 'type' => $type,
  1023. );
  1024. return Resp::ok($ret);
  1025. }
  1026. /*
  1027. * 删除排行榜内注销账号的玩家
  1028. */
  1029. public static function DeleteRankInvalidUser($uid2) {
  1030. $dic1 = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
  1031. foreach ($dic1 as $uid => $score) {
  1032. if ($uid == $uid2) {
  1033. gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
  1034. break;
  1035. }
  1036. }
  1037. $dic2 = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
  1038. foreach ($dic2 as $uid => $score) {
  1039. if ($uid == $uid2) {
  1040. gMem()->zrem(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
  1041. break;
  1042. }
  1043. }
  1044. }
  1045. /*
  1046. * 排行玩家头像变动
  1047. */
  1048. public static function UpdateRankUserHeadImg($uid, $headImg) {
  1049. $memKey1 = MemKey_GameRun::RankReward_MainGateIndex_Zone_hash(req()->zoneid);
  1050. $dic = gMem()->hgetall($memKey1);
  1051. foreach ($dic as $gateId => $ins_rank) {
  1052. if ($ins_rank->uid == $uid) {
  1053. $ins_rank->headImg = $headImg;
  1054. gMem()->hset($memKey1, $gateId, $ins_rank);
  1055. }
  1056. }
  1057. $memKey2 = MemKey_GameRun::RankReward_FightPower_Zone_hash(req()->zoneid);
  1058. $dic2 = gMem()->hgetall($memKey2);
  1059. foreach ($dic2 as $fightPower => $ins_rank) {
  1060. if ($ins_rank->uid == $uid) {
  1061. $ins_rank->headImg = $headImg;
  1062. gMem()->hset($memKey2, $fightPower, $ins_rank);
  1063. }
  1064. }
  1065. }
  1066. /*
  1067. * 统计战力 战斗力=攻击x(生命-伤害减免值)x(1+暴击率/100x(暴击伤害倍率-1))
  1068. */
  1069. public static function countUserFightPower() {
  1070. $CurrentHeroId = ctx()->heros->CurrentHeroId;
  1071. //$hero = ctx()->heros->Dic->$CurrentHeroId;
  1072. list($addHp, $addAtk, $addDecDamage, $addEatFood) = ctx()->gates()->GetEnvovleBuffs(); // 启灵加成
  1073. $mo = GameConfig::hero_getItem($CurrentHeroId);
  1074. my_Assert($mo != null, ErrCode::err_const_no);
  1075. $heroBashAttack = $mo->attack;
  1076. $heroBashHp = $mo->hp;
  1077. $equipDic = ctx()->store->equip;
  1078. $attck = 0;
  1079. $hp = 0;
  1080. foreach ($equipDic as $index => $ins_equip) {
  1081. $Ins_Equip = new Ins_Equip($ins_equip);
  1082. if ($Ins_Equip->mo()->upgradeType == 1) {//攻击力
  1083. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1084. } elseif ($Ins_Equip->mo()->upgradeType == 2) {
  1085. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1086. } else {
  1087. $attck += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->attckNum;
  1088. $hp += GameConfig::equip_levelupgrade_getItem($ins_equip->level)->hpNum;
  1089. }
  1090. }
  1091. $heroAttck = $heroBashAttack + $attck + $addAtk; # 英雄基础攻击力+装备宝石词条攻击力+启灵攻击力
  1092. $heroHp = $heroBashHp + $hp + $addHp; # 英雄基础hp + 装备宝石词条hp + 启灵hp
  1093. $pag = ctx()->store->equipPag;
  1094. $gemDic = ctx()->store->gemEquip->$pag; //Dictionary<E_EquipPosition, Dictionary<int, Ins_Gem>>
  1095. $per = 0;
  1096. $parasVal = 0;
  1097. $per_hp = 0;
  1098. $parasVal_hp = 0;
  1099. foreach ($equipDic as $index => $ins_equip) {
  1100. if (StlUtil::dictHasProperty($gemDic, $index)) {
  1101. $dic = $gemDic->$index;
  1102. foreach ($dic as $k => $gem) {
  1103. $ins_Gem = new Ins_Gem($gem);
  1104. if ($ins_Gem->predicateMo()->actionType == "mulDamage") {
  1105. $per += $ins_Gem->predicateMo()->actionParam1;
  1106. } elseif ($ins_Gem->predicateMo()->actionType == "addDamage") {
  1107. $parasVal += $ins_Gem->predicateMo()->actionParam1;
  1108. } elseif ($ins_Gem->predicateMo()->actionType == "mulHp") {
  1109. $per_hp += $ins_Gem->predicateMo()->actionParam1;
  1110. } elseif ($ins_Gem->predicateMo()->actionType == "addHp") {
  1111. $parasVal_hp += $ins_Gem->predicateMo()->actionParam1;
  1112. }
  1113. }
  1114. }
  1115. }
  1116. if ($per != 0) {
  1117. $heroAttck = round($heroAttck + $heroAttck * $per);
  1118. }
  1119. if ($parasVal != 0) {
  1120. $heroAttck += $parasVal;
  1121. }
  1122. if ($per_hp != 0) {
  1123. $heroHp = round($heroHp + $heroHp * $per_hp);
  1124. }
  1125. if ($parasVal_hp != 0) {
  1126. $heroHp += $parasVal_hp;
  1127. }
  1128. $dec_demage = $mo->dec_demage + $addDecDamage; # 英雄基础减伤 + 启灵减伤
  1129. $bigHit_Val = $mo->bigHit_Val / 100;
  1130. $bigHit_rate = $mo->bigHit_rate / 100;
  1131. $val = $heroAttck * ($heroHp - $dec_demage) * (1 + $bigHit_rate * ($bigHit_Val - 1));
  1132. return intval($val);
  1133. }
  1134. // </editor-fold>
  1135. }