SweepGatesProc.php 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. <?php
  2. //
  3. //namespace loyalsoft;
  4. //
  5. ///**
  6. // * 战斗 - 关卡
  7. // * @author gwang
  8. // */
  9. //class SweepGatesProc {
  10. //
  11. // /**
  12. // * 提取某个对象的某个字段(利用后面2个参数组合为字段名)
  13. // * @param type $obj
  14. // * @param type $name
  15. // * @param type $index
  16. // * @return type
  17. // */
  18. // private static function getProperty_n($obj, $name, $index) {
  19. // if (is_object($obj)) {
  20. // $ke = "$name$index";
  21. // if (property_exists($obj, $ke)) {
  22. // return $obj->$ke;
  23. // }
  24. // }
  25. // return null;
  26. // }
  27. //
  28. // /**
  29. // * [6800] 关卡战斗 - 预计算掉落
  30. // */
  31. // public static function Arenas_preFight() {
  32. // Err(ErrCode::err_method_obsoleted, "reward字段已于2022.1.11被删除,代码需维护!");
  33. // list($gateId, $difficulty) = req()->paras; # 提取参数
  34. // my_Assert($gateId > 0, "关卡id非法");
  35. // $isFirst = self::isFirstChallenge($gateId, $difficulty); # 是否首次通关
  36. // $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据
  37. // $i = $difficulty + 1; # 按三个难度取不同的值.
  38. //// $tili = self::getProperty_n($smGate, "tili", $i); # 体力暂时未用上
  39. // $rwdstr = self::getProperty_n($smGate, "reward", $i);
  40. // $firstPassRewardStr = self::getProperty_n($smGate, 'first_reward', $i);
  41. // if ($isFirst) { # 是否首次通关切换奖励内容
  42. // $rwdstr = $firstPassRewardStr;
  43. // }
  44. // $rsarr = explode(';', $rwdstr);
  45. // my_Assert(count($rsarr) > 0, "关卡奖励数据异常");
  46. // $dic = array();
  47. // foreach ($rsarr as $rs) {
  48. // $rarr = explode(',', $rs);
  49. // $id = intval($rarr[0]);
  50. // $num = intval($rarr[1]);
  51. // $percent = intval(rtrim($rarr[2], '%'));
  52. // if (CommUtil::randomPercent($percent)) { # 投骰子 决定是否本次掉落
  53. // $dic[] = array($id => $num); # 掉落
  54. // }
  55. // }
  56. // $arr = array(); # 拼接返回字符串
  57. // foreach ($dic as $item) {
  58. // foreach ($item as $k => $v) {
  59. // $arr[] = sprintf("%s,%s", $k, $v);
  60. // }
  61. // }
  62. // $_rewards = implode(";", $arr); # 最终奖励字符串
  63. // $redis_key = MemKey_User::temp_arenas_pre_reward_md5_str(req()->zoneid, req()->uid);
  64. // $md5 = md5($gateId . $difficulty . $_rewards);
  65. // gMem()->set($redis_key, $md5, 86400); # 有效期一天,有新的就覆盖
  66. // return Resp::ok(array("r" => $_rewards)); # 返回奖励字符串
  67. //// 生成奖励串, 写入redis一个md5(过期时间1day)
  68. //// 奖励串返回客户端
  69. //// 客户端根据奖励串展示奖励
  70. //// 最后再将奖励串通过挑战接口返回给服务端,
  71. //// 服务端计算奖励传的md5并与redis中的md5做对比.(这里最好采用字段排序后的字符串或者啥的,避免中间因json序列化/反序列化时改变字符串)
  72. // }
  73. //
  74. // /**
  75. // * [6806] 领取章节星数奖励
  76. // */
  77. // public static function DrawChapterStarsReward() {
  78. // list($chapterId, $hard, $stars) = req()->paras; # 参数: 章节id, 难度, 分数
  79. // $hard = $hard + 1;
  80. // $userGates = ctx()->gates();
  81. // if (!property_exists($userGates->chapterStarsRwd, $chapterId)) { # 防御第一次读取本章节数据
  82. // $userGates->chapterStarsRwd->$chapterId = ObjectInit();
  83. // }
  84. // $chapterInfo = $userGates->chapterStarsRwd->$chapterId; # 本章节数据
  85. // if (!property_exists($chapterInfo, $hard)) { # 防御当前难度数据未创建
  86. // $chapterInfo->$hard = array();
  87. // }
  88. // $starsArr = $chapterInfo->$hard; # 当前章节,当前难度的领取记录
  89. // my_Assert(!in_array($stars, $starsArr), ErrCode::err_arenas_hasgetstarreward); # 奖励已领取
  90. // $rwdCfgArr = GameConfig::gate_starreward_getItem($chapterId, $hard); # 奖励配置数组
  91. // $starCfg = StlUtil::arrayFind($rwdCfgArr, function ($v, $k)use ($stars) { # 在数组中查找到对应星数的奖励
  92. // return ($v->star == $stars);
  93. // });
  94. // my_Assert(null != $starCfg, ErrCode::err_arenas_starreward_const_no); # 找不到指定星数的配置数据
  95. // $sumOfStars = 0;
  96. // $userGateL = null;
  97. // switch ($hard) { # 取不同难度数据记录
  98. // case 1:
  99. // $userGateL = new Ins_UserGatesModel($userGates->normal);
  100. // break;
  101. // case 2:
  102. // $userGateL = new Ins_UserGatesModel($userGates->hard);
  103. // break;
  104. // case 3:
  105. // $userGateL = new Ins_UserGatesModel($userGates->elite);
  106. // break;
  107. // default:
  108. // break;
  109. // }
  110. // my_Assert(null != $userGateL, ErrCode::err_innerfault); # 玩家数据有问题
  111. // array_walk($userGateL->gates, function ($v, $k)use (&$sumOfStars) { # 累加星数
  112. // $sinfo = new GateStar($v->star);
  113. // $sumOfStars += $sinfo->Stars();
  114. // });
  115. // my_Assert($stars <= $sumOfStars, ErrCode::err_arenas_starreward_starNotEnough); # 星数未达标
  116. // StoreProc::AddMultiItemInStore($starCfg->reward); # 发放奖励
  117. // $starsArr[] = $stars; # 领奖记录
  118. // $userGates->chapterStarsRwd->$chapterId->$hard = $starsArr; # 回写数据
  119. //
  120. // UserProc::updateUserInfo();
  121. // return Resp::ok(array("store" => ctx()->store(),
  122. // 'gold' => ctx()->base()->gold,
  123. // 'cash' => ctx()->base()->cash
  124. // )); # 返回值
  125. // }
  126. //
  127. // /**
  128. // * [6801] 关卡挑战1次
  129. // */
  130. // public static function Arenas_Fight() {
  131. // $gateId = req()->paras[0];
  132. // list($gateId, $difficulty, $star, $TeamObj) = req()->paras; # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍, 奖励字符串
  133. // my_Assert($gateId > 0, ErrCode::err_arenasgate_indexillegal); # 关卡id非法
  134. //// $md5 = gMem()->get(MemKey_User::temp_arenas_pre_reward_md5_str($req->zoneid, $req->uid));
  135. //// $_md5 = md5($gateId . $difficulty . $rewardStr);
  136. //// my_Assert($md5 == $_md5, ErrCode::err_arenas_rewardIllegal); # 奖励不匹配
  137. //
  138. // $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据
  139. // switch ($smGate->battleType) { #(0普通 怪物全部创建 1Boss站 2引导剧情 3竞技场 4非战斗场景)
  140. // case 0: # 普通关卡
  141. // case 1: # 含有boss的关卡(结算时按击杀boss)
  142. // return self::_NormalGate();
  143. // case 2: # 剧情引导类关卡
  144. // break;
  145. // case 3: # pvp
  146. // break;
  147. // case 4: # 大厅/主城/召唤之类的
  148. // break;
  149. // case 5: # 材料副本
  150. // //副本战斗成功扣体力否则不扣除体力 -2022-11-14
  151. // ActiveProc::ChangeTili(-$smGate->tili1);
  152. // TaskProc::OnPassGateN($gateId, $difficulty + 1);
  153. // $level = substr($gateId, strlen($gateId) - 2);
  154. // TaskProc::OnPassMaterialCarbonN($gateId, $level); # 材料副本
  155. // self::_LogMaterialChallenge($gateId); # 增加记录逻辑
  156. // return self::PassGateSettlement();
  157. // case 6: # 无尽塔
  158. // TaskProc::OnPassGateN($gateId, $difficulty + 1);
  159. // break;
  160. // case 7: # 世界boss
  161. // TaskProc::OnPassWorldBoss($gateId);
  162. // break;
  163. // case 8: # 守护战
  164. // TaskProc::OnPassGateN($gateId, $difficulty + 1);
  165. // return self::PassGateSettlement();
  166. // default:
  167. // break;
  168. // }
  169. //
  170. //// $map = new Info_Map();
  171. //// $map->addBattleRecord($gateId);
  172. // //$map->addBattleNumRecord($gateId, $ret);
  173. // $user = ctx();
  174. // $result = array(
  175. // 'store' => $user->store,
  176. // 'heros' => $user->heros,
  177. // 'gates' => $user->gates,
  178. // 'tili' => $user->base()->tili,
  179. // 'time' => $user->privateState->TiliTime,
  180. // 'gold' => $user->base()->gold,
  181. // 'resPoint' => $user->base()->resPoint,
  182. // 'cash' => $user->base()->cash,
  183. // 'exp' => 0,
  184. //// 'rewardstr' => implode(';', $rewardArr),
  185. // 'priv' => $user->privateState,
  186. // 'isFirst' => false,
  187. // 'prize'=>"",
  188. // );
  189. // UserProc::updateUserInfo();
  190. // return Resp::ok($result);
  191. // }
  192. //
  193. // private static function _LogMaterialChallenge($gateId) {
  194. // $priv = ctx()->privateState;
  195. // my_default_Obj($priv->materialDailyChallengeRecord); # 防御代码
  196. // if (!CommUtil::isPropertyExists($priv->materialDailyChallengeRecord, $gateId)) {
  197. // $priv->materialDailyChallengeRecord->$gateId = 0;
  198. // }
  199. // $priv->materialDailyChallengeRecord->$gateId++;
  200. // ctx()->privateState = $priv;
  201. //// var_dump($priv);
  202. // }
  203. //
  204. // /**
  205. // * 通关普通关卡
  206. // */
  207. // private static function _NormalGate() {
  208. // list($gateId, $difficulty, $star, $TeamObj) = req()->paras; # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍, 奖励字符串
  209. // $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据
  210. // $isFirst = false; # 是否首次通关
  211. // self::recordFight($gateId, $difficulty, $star, $isFirst); # 更新挑战记录
  212. // $i = $difficulty + 1; # 按三个难度取不同的值.
  213. //// $gold = self::getProperty_n($smGate, "gold", $i);
  214. // $exp = self::getProperty_n($smGate, "exp", $i);
  215. // $firstExp = self::getProperty_n($smGate, "first_exp", $i);
  216. // $firstHero = self::getProperty_n($smGate, "first_hero", $i);
  217. // $heroExp = self::getProperty_n($smGate, "heroExp", $i);
  218. // if ($isFirst) { # 是否首次通关切换奖励内容
  219. // $exp = $firstExp;
  220. // if ($firstHero > 0) { # 首次通关解锁英雄
  221. // HeroProc::AddHeroWithStar($firstHero, 0); # 添加英雄
  222. // }
  223. // }
  224. //
  225. //// $rewardArr = self::SetRewards($req, $rewardStr); # 发通关奖励
  226. //// Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold); # 发金币
  227. //// Data_UserGame::Add_Exp(ctx()->baseInfo, $exp); # 给玩家(指挥官)增加经验
  228. // ctx()->base()->Add_Exp($exp); # 给玩家(指挥官)增加经验
  229. // foreach ($TeamObj as $heroUID) {
  230. // if ($heroUID > 0) {
  231. // echoLine("$heroUID");
  232. // HeroProc::HeroAddEXP($heroUID, $heroExp); # 增加英雄经验
  233. // }
  234. // }
  235. // UserProc::updateUserInfo(); # 回写玩家数据.
  236. //
  237. // TaskProc::OnPassGateN($gateId, $difficulty + 1);
  238. //
  239. // StatisticsProc::unlockGate($gateId); #统计通关最新关卡
  240. // $user = ctx();
  241. // $result = array(
  242. // 'store' => $user->store,
  243. // 'heros' => $user->heros,
  244. // 'gates' => $user->gates,
  245. // 'tili' => $user->base()->tili,
  246. // 'time' => $user->privateState->TiliTime,
  247. // 'gold' => $user->base()->gold,
  248. // 'resPoint' => $user->base()->resPoint,
  249. // 'cash' => $user->base()->cash,
  250. // 'exp' => $exp,
  251. //// 'rewardstr' => implode(';', $rewardArr),
  252. // 'isFirst' => $isFirst,
  253. // 'prize'=>"",
  254. // );
  255. // return Resp::ok($result);
  256. // }
  257. //
  258. // private static function PassGateSettlement() {
  259. // list($gateId, $difficulty, $star, $TeamObj) = req()->paras; # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍, 奖励字符串
  260. // $smGate = GameConfig::gate_getItem($gateId); # 关卡配置数据
  261. // $isFirst = false;
  262. // self::recordFight($gateId, $difficulty, $star, $isFirst); # 更新挑战记录
  263. // $i = $difficulty + 1; # 按三个难度取不同的值.
  264. // $exp = self::getProperty_n($smGate, "exp", $i);
  265. // ctx()->base()->Add_Exp($exp); # 给玩家(指挥官)增加经验
  266. //
  267. // $prize = "";
  268. // if($smGate->battleType == 8){//守护战
  269. // $mo = GameConfig::duplicate_defense_getItem($smGate->duplicateDataId);
  270. // if($mo != null){
  271. // $p = $mo->rewardList;
  272. // $arr = explode(',', $p);
  273. // $s = "";
  274. // foreach ($arr as $val) {
  275. // $aa = explode('_', $val);
  276. // $s = $aa[0].','.$aa[1];
  277. // if($prize == ""){
  278. // $prize = $s;
  279. // } else {
  280. // $prize = $prize.';'.$s;
  281. // }
  282. // }
  283. //
  284. // }
  285. //
  286. // StoreProc::AddMultiItemInStore($prize);
  287. // }
  288. //
  289. // UserProc::updateUserInfo(); # 回写玩家数据.
  290. //
  291. // $user = ctx();
  292. // $result = array(
  293. // 'store' => $user->store,
  294. // 'heros' => $user->heros,
  295. // 'gates' => $user->gates,
  296. // 'tili' => $user->base()->tili,
  297. // 'time' => $user->privateState->TiliTime,
  298. // 'gold' => $user->base()->gold,
  299. // 'resPoint' => $user->base()->resPoint,
  300. // 'cash' => $user->base()->cash,
  301. // 'exp' => $exp,
  302. //// 'rewardstr' => implode(';', $rewardArr),
  303. // 'isFirst' => $isFirst,
  304. // 'prize'=>$prize,
  305. // );
  306. // return Resp::ok($result);
  307. // }
  308. //
  309. // /**
  310. // * 发放奖励串
  311. // * @param Req $req
  312. // * @param type $rewardStr
  313. // */
  314. // public static function SetRewards($rewardStr) {
  315. // $getedArr = array(); # 统计所获奖励物品
  316. // $rewardsArr = explode(";", $rewardStr);
  317. // foreach ($rewardsArr as $r) { #
  318. // if (strlen($r) > 0) {
  319. //// $percentStr = explode(',', $r)[2];
  320. //// $percent = intval(trim($percentStr, "%")); # 剔除%
  321. //// if (CommUtil::randomPercent($percent)) {
  322. // $err = StoreProc::AddMultiItemInStore($r); # 发放奖励物品
  323. // my_Assert($err == ErrCode::ok, $err); # 出错了
  324. // $getedArr[] = $r; # 剔除最后一段概率字符串
  325. //// }
  326. // }
  327. // }
  328. // return $getedArr;
  329. // }
  330. //
  331. // /**
  332. // * 更新战斗记录
  333. // * @param type $gateId
  334. // * @param type $difficulty
  335. // * @param type $star
  336. // */
  337. // private static function isFirstChallenge($gateId, $difficulty) {
  338. // $userGates = ctx()->gates;
  339. // if ($difficulty == 0) { # 按照难度查找
  340. // $diffCult = $userGates->normal;
  341. // } else if ($difficulty == 1) {
  342. // $diffCult = $userGates->hard;
  343. // } else if ($difficulty == 2) {
  344. // $diffCult = $userGates->elite;
  345. // } else {
  346. // Err(ErrCode::err_arenas_difficulty); # 找不到难度类型
  347. // }
  348. //
  349. // $typeId = substr($diffCult->highest, 0, 3); # 防御: 分类头不对
  350. // if ($typeId != '503') {
  351. // $diffCult->highest = 503000; # 设置为关卡第一关
  352. // }
  353. // if ($gateId > $diffCult->highest + 1) { # 不能跳关
  354. // Err(ErrCode::err_arenasgate_indexillegal);
  355. // }
  356. //
  357. // $uGate = new Ins_UGate(); # 当前关卡的记录数据
  358. // if (isset($diffCult->gates->$gateId)) {
  359. // $uGate = $diffCult->gates->$gateId;
  360. // }
  361. //
  362. // return !$uGate->cleared;
  363. // }
  364. //
  365. // /**
  366. // * 更新战斗记录
  367. // * @param type $gateId
  368. // * @param type $difficulty
  369. // * @param type $star
  370. // */
  371. // private static function recordFight($gateId, $difficulty, $star, &$isFirst = false) {
  372. // $userGates = ctx()->gates;
  373. // if ($difficulty == 0) { # 按照难度查找
  374. // $diffCult = $userGates->normal;
  375. // } else if ($difficulty == 1) {
  376. // $diffCult = $userGates->hard;
  377. // } else if ($difficulty == 2) {
  378. // $diffCult = $userGates->elite;
  379. // } else {
  380. // Err(ErrCode::err_arenas_difficulty); # 找不到难度类型
  381. // }
  382. //
  383. // $typeId = substr($diffCult->highest, 0, 3); # 防御: 分类头不对
  384. // if ($typeId != '503') {
  385. // if ($diffCult->highest < 503000) {
  386. // $diffCult->highest = 503000; # 设置为关卡第一关
  387. // }
  388. // }
  389. //
  390. //// if ($gateId > $diffCult->highest + 1) { # 不能跳关
  391. //// Err(ErrCode::err_arenasgate_indexillegal);
  392. //// }
  393. //
  394. // if ($gateId == $diffCult->highest + 1 && $star > 0) { # 星级大于等于0,才可以推关
  395. // $diffCult->highest += 1; # 更新最高记录
  396. // RankProc::recordNewPassGateInfo(req()->uid, $gateId); # 更新通关记录
  397. // }
  398. // $diffCult->latest = $gateId; # 记录上次挑战关卡id
  399. //
  400. // $uGate = new Ins_UGate(); # 当前关卡的记录数据
  401. // if (isset($diffCult->gates->$gateId)) {
  402. // $uGate = $diffCult->gates->$gateId;
  403. // }
  404. // $uGate->challengeTimes++; # 当前关卡挑战次数
  405. // $uGate->star |= $star; # 当前关卡得分评星
  406. // if (!$uGate->cleared) {
  407. // $uGate->cleared = 1; # 当前关卡是否已通关
  408. // $isFirst = true;
  409. // }
  410. // $diffCult->gates->$gateId = $uGate; # 回写关卡记录
  411. //
  412. // $userGates->TotalNum++; # 总战斗次数+1
  413. // $userGates->Times++;
  414. // ctx()->gates = $userGates; # 回写数据
  415. // }
  416. //
  417. // /**
  418. // * 清理每个难度副本的每日战斗次数
  419. // */
  420. // public static function ClearGateTimes() {
  421. // ctx()->gates->Times = 0;
  422. // }
  423. //
  424. ////
  425. //// <editor-fold defaultstate="collapsed" desc=" 扫荡 ">
  426. //
  427. // /**
  428. // * [6802]新扫荡
  429. // */
  430. // public static function Arenas_NewSweepFight() {
  431. // Err(ErrCode::err_method_obsoleted, "reward字段已于2022.1.11被删除,代码需维护!");
  432. // Err(ErrCode::err_method_obsoleted); # 没开扫荡功能
  433. // list($gateId, $difficulty, $costItemId) = req()->paras; # 关卡id, 难度 difficulty, 扫荡券id
  434. //
  435. // $user = ctx();
  436. // $smGate = GameConfig::gate_getItem($gateId);
  437. // my_default_Obj($user->gates->newGateRecord); # 防御未初始化的变量
  438. // $gatesRecord = $user->gates->newGateRecord;
  439. // my_default_Obj($gatesRecord->record); # 防御未初始化的变量
  440. //
  441. // $i = $difficulty + 1; // 按三个难度取不同的值.
  442. // $tili = self::getProperty_n($smGate, "tili", $i);
  443. // $reward = self::getProperty_n($smGate, "reward", $i);
  444. // $gold = self::getProperty_n($smGate, "gold", $i);
  445. // $exp = self::getProperty_n($smGate, "exp", $i);
  446. // $err = StoreProc::removeItemFromStore($user->store, $costItemId, 1);
  447. // my_Assert(ErrCode::ok == $err, $err); # 扣除失败
  448. // $canfighterr = SweepGatesProc::CanFight($gateId, $difficulty); # 补充战斗记录
  449. // if ($canfighterr) {#不能符合战斗要求
  450. // return $canfighterr;
  451. // }
  452. // $user->gates->newGateRecord = $gatesRecord; # 回写数据
  453. // ActiveProc::ChangeTili(- $tili); # 扣减体力
  454. // $user->gates->TotalNum++; # 更新战斗次数统计
  455. // $user->gates->Times++;
  456. //
  457. // $rewardsArr = explode(";", $reward);
  458. // $rwds = array();
  459. // foreach ($rewardsArr as $r) { // 按照概率规则发放奖品
  460. // $arr = explode(',', $r);
  461. // $itemid = intval($arr[0]);
  462. // $num = intval($arr[1]);
  463. // $probability = intval($arr[2]);
  464. // if (CommUtil::randomPercent($probability)) { # 投色子
  465. // $err = StoreProc::AddMultiItemInStore("$itemid,$num");
  466. // my_Assert(ErrCode::ok == $err, $err);
  467. // $rwds[] = "$itemid,$num";
  468. // }
  469. // }
  470. // $user->base()->Add_Gold($gold); # 发放金币奖励
  471. // my_Assert(ErrCode::ok == $err, $err); # 失败
  472. //// Data_UserGame::Add_Exp($user->baseInfo, $exp); # 发放经验奖励
  473. // $user->base()->Add_Exp($exp); # 发放经验奖励
  474. // UserProc::updateUserInfo(); # 在获取战利品哪里已经update了.
  475. // $result = array(
  476. // 'store' => $user->store,
  477. // 'heros' => $user->heros,
  478. // 'gates' => $user->gates,
  479. // 'tili' => $user->base()->tili,
  480. // 'time' => $user->privateState->TiliTime,
  481. // 'gold' => $gold,
  482. // 'exp' => $exp,
  483. // 'rewardstr' => implode(';', $rwds)
  484. // );
  485. // return Resp::ok($result);
  486. // }
  487. //
  488. // /**
  489. // * 是否可以战斗
  490. // * @param $gateId
  491. // * @param $difficulty
  492. // * @return type
  493. // */
  494. // static function CanFight($gateId, $difficulty) {
  495. // $gatesRecord = ctx()->gates->newGateRecord;
  496. // $smGate = GameConfig::gate_getItem($gateId);
  497. // if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) {
  498. // $gatesRecord->record->$gateId = ObjectInit();
  499. // }
  500. //// if ($difficulty > 2) {
  501. //// return Resp::err(ErrCode::err_arenasgate_indexillegal);
  502. //// }
  503. // if ($difficulty == 0) {
  504. // if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "normal")) {
  505. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  506. // }
  507. //
  508. // if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "normalToday")) {
  509. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  510. // }
  511. // if ($smGate->cishu1 - $gatesRecord->record->$gateId->normalToday < 1) {
  512. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  513. // }
  514. // $gatesRecord->record->$gateId->normalToday += 1;
  515. // } else if ($difficulty == 1) {
  516. //
  517. // if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "hard")) {
  518. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  519. // }
  520. // if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "hardToday")) {
  521. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  522. // }
  523. //
  524. // if ($smGate->cishu2 - $gatesRecord->record->$gateId->hardToday < 1) {
  525. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  526. // }
  527. // $gatesRecord->record->$gateId->hardToday += 1;
  528. // } else if ($difficulty == 2) {
  529. // if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "elite")) {
  530. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  531. // }
  532. //
  533. // if (!CommUtil::isPropertyExists($gatesRecord->record->$gateId, "eliteToday")) {
  534. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  535. // }
  536. // if ($smGate->cishu3 - $gatesRecord->record->$gateId->eliteToday < 1) {
  537. // return Resp::err(ErrCode::err_arenas_normalgate_numno);
  538. // }
  539. // $gatesRecord->record->$gateId->eliteToday += 1;
  540. // }
  541. // return null; // false
  542. // }
  543. //
  544. //// </editor-fold>
  545. ////
  546. //// <editor-fold defaultstate="collapsed" desc=" 好友租借 ">
  547. //// /**
  548. //// * [6805] 查询租借好友记录
  549. //// * @param Req $req
  550. //// */
  551. //// public static function GetBorrowedFriends($req) {
  552. ////// 查询好友借用记录中的数据
  553. //// $rentedfriends = $req->userInfo->game->privateState->rentedFriends;
  554. //// if (!$rentedfriends || !is_array($rentedfriends)) {
  555. //// $rentedfriends = ArrayInit();
  556. //// }
  557. //// return Resp::ok(array('ret' => $rentedfriends));
  558. //// }
  559. ////
  560. //// /**
  561. //// * 清理战斗租借好友记录
  562. //// *
  563. //// */
  564. //// public static function ClearFightRentRecord($req) {
  565. //// $req->userInfo->game->privateState->rentedFriends = ArrayInit();
  566. //// }
  567. ////
  568. //// /**
  569. //// * [6806] 扣除借用好友费用
  570. //// * @param Req $req
  571. //// */
  572. //// public static function ConsumeBorrowFriend($req) {
  573. ////// 提取参数:好友id
  574. //// $friend_uid = $req->paras[0];
  575. ////// 验证好友关系
  576. //// if (!FriendProc::isFriendship($req->zoneid, $req->uid, $friend_uid)) {
  577. //// return Resp::err(ErrCode::friend_no_err);
  578. //// }
  579. ////// 验证尚未租借过
  580. //// $rentedfriends = $req->userInfo->game->privateState->rentedFriends;
  581. //// if (!$rentedfriends || !is_array($rentedfriends)) {
  582. //// $rentedfriends = ArrayInit();
  583. //// }
  584. //// if (in_array($friend_uid, $rentedfriends)) {
  585. //// return Resp::err(array('err' => -1, 'msg' => 'has rented this player today!'));
  586. //// }
  587. ////// 验证好友出借英雄
  588. //// $friend_info = UserProc::getUserInfo(gMem(), $req->zoneid, $friend_uid);
  589. //// if (!$friend_info) {
  590. //// return Resp::err(ErrCode::user_no_err, '找不到好友的游戏数据!');
  591. //// }
  592. ////// todo:啦啦啦... 先不写了,管它用的是哪个英雄呢
  593. //////
  594. ////// 扣除费用,失败->金币不足
  595. //// $arr = explode(',', glc()->User_Friends_HireFriendForBattle_Cost);
  596. //// if (count($arr) < 2) {
  597. //// return Resp::err(ErrCode::err_const_no);
  598. //// }
  599. //// $itemid = $arr[0]; # 道具id
  600. //// $amt = $arr[1]; # 数量
  601. //// if ($itemid == META_GOLD_ITEMID) {
  602. //// $user = $req->userInfo->game;
  603. //// if ($user->gold < $amt) {
  604. //// return Resp::err(array('err' => -2, 'msg' => 'gold not enough!'));
  605. //// }
  606. //// UserGameModel::Consume_Gold($user, $amt);
  607. ////// todo: 给好友发送金币 邮件
  608. //// EmailProc::SendHireCoinFromFight($req->zoneid, $friend_uid, #
  609. //// $req->userInfo->game->name, $req->uid, $amt); # 好友收益需要扣除系统税率.
  610. //// } else {
  611. //// return Resp::err(ErrCode::err_const_no);
  612. //// }
  613. ////// 添加借用记录
  614. //// $rentedfriends[] = $friend_uid;
  615. //// $req->userInfo->game->privateState->rentedFriends = $rentedfriends;
  616. ////// 回写数据
  617. //// UserProc::updateUserInfo($req); // 玩家数据
  618. ////// UserProc::setUserInfo(global_mem(), $friend_info); // 好友数据
  619. ////// 返回
  620. //// return Resp::ok(array('err' => 0, 'curgold' => $user->gold));
  621. //// }
  622. //// </editor-fold>
  623. ////
  624. //// <editor-fold defaultstate="collapsed" desc="黄金挑战">
  625. //// /**
  626. //// * [6804] 扣除买buffer的费用
  627. //// * @param type $req
  628. //// * @return type
  629. //// */
  630. //// public static function ConsumeBufferGold($req) {
  631. //// $user = $req->userInfo->game; # user引用
  632. //// $money = $req->paras[0]; //需要的手工费
  633. ////// echo var_dump($money);
  634. //// $bDeal = UserGameModel::Consume_Gold($user, $money);
  635. //// if ($bDeal) {
  636. //// $result = array(
  637. //// 'resp' => "succeed!"
  638. //// );
  639. ////// 更新数据库数据
  640. ////
  641. //// $resp = Resp::ok($result);
  642. //// } else {
  643. ////
  644. ////// $user->gold=0;
  645. //// $result = array(
  646. //// 'resp' => "succeed!"
  647. //// );
  648. ////// 更新数据库数据
  649. ////
  650. //// $resp = Resp::ok($result);
  651. //// }
  652. //// UserProc::updateUserInfo($req);
  653. //// return $resp;
  654. //// }
  655. //// /**
  656. //// * [6807] 挑战黄金 无穷无尽战斗模式
  657. //// * @param type $req
  658. //// */
  659. //// public static function ChallengeEndlessFightMode_Gold($req) {
  660. //// $gateForeverId = $req->paras[0];
  661. //// $difficuty = $req->paras[1];
  662. //// $bociCount = $req->paras[2];
  663. //////判断是否已经达到挑战的次数上限
  664. //// $gates = $req->userInfo->game->gates;
  665. ////
  666. //// if (!CommUtil::isPropertyExists($gates, "forever_Gold_FightTimes")) {
  667. //// $gates->forever_Gold_FightTimes = 0;
  668. //// }
  669. ////
  670. //// if ($gates->forever_Gold_FightTimes >= glc()->Battle_Forever_MaxCountEveryDay) {
  671. //// return Resp::err(ErrCode::err_gateForever_countIsFull, '挑战次数已经用尽!');
  672. //// }
  673. //////1.取出无尽模式的关卡常量数据
  674. //// $gateForeverConst = GameConfig::gateforever_getItem($gateForeverId); // ConstProc::getGold_GateForeverGoldConst($gateForeverId);
  675. //// $gateBattleBociConst = GameConfig::gatecombat_getItem($gateForeverId);
  676. //// if (!$gateForeverConst) {
  677. //// return Resp::err(ErrCode::err_gateForever_const_no);
  678. //// }
  679. //////判断次数是否合法
  680. //// $bociArr = explode(",", $gateBattleBociConst->level);
  681. //// if ($bociCount > count($bociArr)) {
  682. //// return Resp::err(ErrCode::err_gateForever_countillegal);
  683. //// }
  684. //////2.取出模式下的奖励数据
  685. //// $rewardStr = $gateForeverConst->reward1;
  686. ////
  687. //// $arr_reward = explode(";", $rewardStr);
  688. //// foreach ($arr_reward as $value) {
  689. //// if (strlen($value) > 0) {
  690. ////
  691. //// $arr_RealReward = explode(",", $value);
  692. //// $itemId = $arr_RealReward[0];
  693. //// $itemNum = $arr_RealReward[1];
  694. ////
  695. //// $str1 = substr($itemId, 0, 3);
  696. //////3.根据挑战的波次数据,重复累计获得奖励
  697. //// for ($i = 0; $i < $bociCount; $i++) {
  698. ////
  699. //// switch ($str1) {
  700. ///////怪物卡或者英雄卡牌获取
  701. //// case "101":
  702. //// case "201":
  703. ////// HeroProc::AddHeroTFromStore($req, $itemId);
  704. //// break;
  705. ///////装备物品的获取.
  706. //// case "301":
  707. //// case "302":
  708. //// case "303":
  709. //// StoreProc::PutEquipInStore($itemId, $req);
  710. //// break;
  711. ///////宝石的获取
  712. //// case "304":
  713. //// StoreProc:: PutOverlyingItemInStore($itemId, $itemNum, $req);
  714. //// break;
  715. //////金币的获取
  716. //// case "399":
  717. //// if ($itemId == "399002") {
  718. //// UserGameModel::Add_Gold($req->mem, $req->userInfo->game, $itemNum);
  719. //// }
  720. //// break;
  721. //// default:
  722. //// break;
  723. //// }
  724. //// }
  725. //// }
  726. //// }
  727. //////4、存储玩家的挑战次数
  728. //// $gates->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes + 1;
  729. ////// 回写数据
  730. //// UserProc::updateUserInfo($req);
  731. //// $result = ObjectInit();
  732. //// $result->result = "succeed";
  733. //// $result->forever_Gold_FightTimes = $gates->forever_Gold_FightTimes;
  734. //// $resp = Resp::ok($result);
  735. //// return $resp;
  736. //// }
  737. //// /**
  738. //// * 清理挑战无尽模式的 次数记录
  739. //// *
  740. //// */
  741. //// public static function ClearGateForeverGold_FightCountEveryDay($req) {
  742. //// $req->userInfo->game->gates->forever_Gold_FightTimes = 0;
  743. //// }
  744. //// </editor-fold>
  745. ////
  746. //// <editor-fold defaultstate="collapsed" desc=" 副本 ">
  747. ////
  748. //// /**
  749. //// * [6801] 开启副本
  750. //// * @param Req $req
  751. //// * @deprecated since version 0
  752. //// */
  753. //// public static function OpenTheCarbon($req) {
  754. //// $gates = $req->userInfo->game->gates;
  755. //// $openedcarbons = $gates->carbons->openedCarbons;
  756. ////# 提取参数
  757. //// $carbonId = $req->paras[0]; # 副本ID
  758. //// $difficulty = $req->paras[1]; # 难度等级 1,2,3
  759. //// $key = "$carbonId-$difficulty"; # 键值
  760. //// if (!($gates && $openedcarbons)) {
  761. //// return Resp::err(ErrCode::err_innerfault);
  762. //// }
  763. //// if ($difficulty > 3 || $difficulty < 1) {
  764. //// return Resp::err(ErrCode::carbon_wrongdifficult);
  765. //// }
  766. ////
  767. //// if (CommUtil::isPropertyExists($openedcarbons, $key)) {
  768. //// $carbon = $openedcarbons->$key;
  769. //// } else {
  770. //// $carbon = new CarbonModel();
  771. //// }
  772. //// if ($carbon->closeTs > now()) {
  773. //// return Resp::err(ErrCode::carbon_opened);
  774. //// }
  775. //// $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 常量
  776. ////# 扣除开启消耗的道具
  777. //// $keyid = "keyId$difficulty";
  778. //// $keynum = "keyNum$difficulty";
  779. //// $costItemId = $carbonModel->$keyid;
  780. //// $costItemNum = $carbonModel->$keynum;
  781. ////
  782. //// $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, $costItemNum);
  783. //// if ($err) { # 扣除失败
  784. //// return Resp::err($err);
  785. //// }
  786. //// $carbon->closeTs = now() + $carbonModel->duration; # 关闭倒计时
  787. //// $carbon->curIndex = 0; # 索引重置为0
  788. //// $openedcarbons->$key = $carbon;
  789. //// $req->userInfo->game->gates->carbons->openedCarbons = $openedcarbons;
  790. //// UserProc::updateUserInfo($req);
  791. //// return Resp::ok(array('err' => 0, 'carbons' => $openedcarbons));
  792. //// }
  793. //// /**
  794. //// * 挑战副本关卡
  795. //// * @param Req $req
  796. //// * @deprecated since version number
  797. //// */
  798. //// public static function ChallengeCarbon($req) {
  799. //// $gates = $req->userInfo->game->gates;
  800. //// $carbons = $gates->carbons->openedCarbons;
  801. ////# 提取参数
  802. //// $carbonId = $req->paras[0]; # 副本ID
  803. //// $difficulty = $req->paras[1]; # 难度等级 1,2,3
  804. //// $gateindex = $req->paras[2]; # 关卡索引 0,1,2,...
  805. //// $star = $req->paras[3]; # 战斗评价(几星)
  806. //// $TeamObj = $req->paras[4]; # 队伍信息
  807. ////// $bossId = $req->paras[5]; # 本关消灭的bossid (<=0代表本关卡未出现boss)
  808. //// if ($difficulty > 3 || $difficulty < 1) {
  809. //// return Resp::err(ErrCode::carbon_wrongdifficult);
  810. //// }
  811. //// $key = "$carbonId-$difficulty"; # 键值
  812. ////# 0 当前副本处于开启状态
  813. ////# 1 当前关卡索引,不能跳着打,
  814. ////# 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励
  815. ////# 3 决定掉落物品, 发给客户端
  816. ////# 4 发放对应的经验之类的东西
  817. ////# 5 检查是否最后一个关卡, 是, 关闭副本
  818. ////# 6 回存数据,返回
  819. ////
  820. //// isEditor() && $carbon = new CarbonModel;
  821. //// if (CommUtil::isPropertyExists($carbons, $key)) {
  822. //// $carbon = $carbons->$key;
  823. //// } else {
  824. //// $carbon = null;
  825. //// }
  826. //// if (!$carbon || $carbon->closeTs < now()) {
  827. //// return Resp::err(ErrCode::carbon_closed);
  828. //// }
  829. ////
  830. //// $carbonModel = GameConfig::gate_carbon_getItem($carbonId); # 副本常量数据
  831. //// $gateIds = explode(',', $carbonModel->gateids);
  832. //// if ($gateindex < 0 || $gateindex >= count($gateIds)) {
  833. //// return Resp::err(ErrCode::carbon_gateIndex);
  834. //// }
  835. //// if ($carbon->curIndex == $gateindex || $gateindex == 0) {
  836. //// $carbon->curIndex += 1; # 更新进度
  837. //// } else { # 不能跳关
  838. //// return Resp::err(ErrCode::carbon_gateIndex);
  839. //// }
  840. ////
  841. //// $gateId = $gateIds[$gateindex]; # 通过索引获得关卡ID
  842. //// $tl = "tili$difficulty"; # 体力难度
  843. //// $rwd = "reward$difficulty"; # 奖励难度
  844. //// $arr = array("normal", 'hard', 'elite'); # 难度名称
  845. //// $gt = $arr[$difficulty - 1]; # 关卡分类
  846. //// $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据
  847. //// $tili = $gateModel->$tl; # 扣除体力
  848. //// $reward = $gateModel->$rwd; # 获得奖励
  849. ////#
  850. ////# 打副本呢也要扣除体力
  851. //// ActiveProc::ChangeTili(-$tili, $req);
  852. ////# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109
  853. //// UserGameModel::Add_Exp($req, $tili);
  854. ////# 增加英雄经验(也是依据扣除的体力数)
  855. //// foreach ($TeamObj as $heroUID) {
  856. //// HeroProc::HeroAddEXP($heroUID, $tili, $req);
  857. //// }
  858. ////// $carbon->stars; 暂不记录了
  859. ////# 掉落战利品->获取
  860. //// $err = StoreProc::AddMultiItemInStore($req, $reward);
  861. //// if ($err) {
  862. //// return Resp::err($err);
  863. //// }
  864. //// if (count($gateIds) == $gateindex + 1) { # 最后一个关卡
  865. //// unset($carbons->$key); # 关闭掉关卡,或者是直接删掉
  866. //// } else {
  867. //// $carbons->$key = $carbon; # 回存数据
  868. //// }
  869. //// $req->userInfo->game->gates->carbons->openedCarbons = $carbons;
  870. //// UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
  871. //// # Ps.备注,奖品是固定的,所以不必返回
  872. //// $result = array(
  873. //// 'store' => $req->userInfo->game->store,
  874. //// 'heros' => $req->userInfo->game->heros,
  875. //// 'gates' => $req->userInfo->game->gates,
  876. //// 'tili' => $req->userInfo->game->tili,
  877. //// 'time' => $req->userInfo->game->privateState->TiliTime
  878. //// );
  879. //// return Resp::ok($result);
  880. //// }
  881. //// /**
  882. //// * [6809]新版本的挑战 副本胜利
  883. //// * @param Req $req
  884. //// * @deprecated since version 0
  885. //// */
  886. //// public static function NewChallengeCarbon($req) {
  887. //// $gates = $req->userInfo->game->gates;
  888. //// $carbons = $gates->carbons->openedCarbons;
  889. ////# 提取参数
  890. //// $carbonId = $req->paras[0]; # 副本ID
  891. //// $gateId = $req->paras[1]; # 关卡ID
  892. //// $difficulty = $req->paras[2]; # 难度等级 1,2,3
  893. ////
  894. //// $star = $req->paras[3]; # 战斗评价(几星)
  895. //// $TeamObj = $req->paras[4]; # 队伍信息
  896. ////
  897. //// if ($difficulty > 3 || $difficulty < 1) {
  898. //// return Resp::err(ErrCode::carbon_wrongdifficult);
  899. //// }
  900. //// $key = "$carbonId-$difficulty"; # 键值
  901. //// # 0 当前副本处于开启状态
  902. //// # 1 战斗胜利之后,副本直接关闭
  903. //// # 2 记录下战斗评价(几星), 也许以后用得着,比如最后通关后,给个啥奖励
  904. //// # 3 决定掉落物品, 发给客户端
  905. //// # 4 发放对应的经验之类的东西
  906. //// # 5 检查是否最后一个关卡, 是, 关闭副本
  907. //// # 6 回存数据,返回
  908. ////
  909. //// isEditor() && $carbon = new CarbonModel;
  910. //// if (CommUtil::isPropertyExists($carbons, $key)) {
  911. //// $carbon = $carbons->$key;
  912. //// } else {
  913. //// $carbon = null;
  914. //// }
  915. //// if (!$carbon || $carbon->closeTs < now()) {
  916. //// return Resp::err(ErrCode::carbon_closed);
  917. //// }
  918. //// unset($carbons->$key);
  919. //// $tl = "tili$difficulty"; # 体力难度
  920. //// $rwd = "reward$difficulty"; # 奖励难度
  921. ////
  922. //// $gateModel = GameConfig::gate_carbon_content_getItem($gateId); # 副本关卡常量数据
  923. //// $tili = $gateModel->$tl; # 扣除体力
  924. //// $reward = $gateModel->$rwd; # 获得奖励
  925. //// #
  926. //// # 打副本呢也要扣除体力
  927. //// ActiveProc::ChangeTili(-$tili, $req);
  928. ////
  929. //// // 按照概率规则发放奖品
  930. //// $rewardsArr = explode(";", $reward);
  931. //// $rwds = array();
  932. //// foreach ($rewardsArr as $r) {
  933. //// $arr = explode(',', $r);
  934. //// $itemid = intval($arr[0]);
  935. //// $num = intval($arr[1]);
  936. //// $probability = floatval($arr[2]); # 掉落概率精度精确到±0.01%
  937. //// if (CommUtil::randomPercent($probability)) { # 投色子
  938. //// $err = StoreProc::AddMultiItemInStore($req, "$itemid,$num");
  939. //// if ($err) {
  940. //// return Resp::err($err);
  941. //// }
  942. //// $rwds[] = "$itemid,$num";
  943. //// }
  944. //// }
  945. ////
  946. //// if ($err) {
  947. //// return Resp::err($err);
  948. //// }
  949. ////
  950. //// $req->userInfo->game->gates->carbons->openedCarbons = $carbons;
  951. //// UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
  952. //// # Ps.备注,奖品是固定的,所以不必返回
  953. //// SystemProc::Carbon_Win($req->zoneid, $req->userInfo->game, $carbonId, $difficulty); # 插入通过副本消息
  954. //// $result = array(
  955. //// 'store' => $req->userInfo->game->store,
  956. //// 'heros' => $req->userInfo->game->heros,
  957. //// 'gates' => $req->userInfo->game->gates,
  958. //// 'tili' => $req->userInfo->game->tili,
  959. //// 'time' => $req->userInfo->game->privateState->TiliTime,
  960. //// 'gold' => 0,
  961. //// 'exp' => 0,
  962. //// 'rewardstr' => implode(';', $rwds)
  963. //// );
  964. //// return Resp::ok($result);
  965. //// }
  966. //// /**
  967. //// * [6816] 挑战剧情关卡
  968. //// * @param type $req
  969. //// * @deprecated since version 0
  970. //// */
  971. //// public static function ChallengeStoryGate($req) {
  972. //// $gates = $req->userInfo->game->gates;
  973. ////# 提取参数
  974. //// $storyId = $req->paras[0]; # 剧情ID
  975. //// $difficulty = $req->paras[1]; # 难度等级 1,2,3
  976. //// $star = $req->paras[2]; # 战斗评价(几星)
  977. //// $TeamObj = $req->paras[3]; # 队伍信息
  978. //// $bossId = $req->paras[4]; # 本关消灭的bossid (<=0代表本关卡未出现boss)
  979. //////
  980. ////#1. 判断是否有记录过剧情的战斗信息
  981. //// if (!CommUtil::isPropertyExists($gates, "story")) {
  982. //// $gates->story = ObjectInit();
  983. //// $gates->story->lastFinishedStoryGateId = 0;
  984. //// $gates->story->allFinishedStoryGateIdList = ArrayInit();
  985. //// }
  986. //// $storrRecord = $gates->story;
  987. ////#2.取出模式下的奖励数据
  988. //// $memStoryModel = GameConfig::gatestory_getItem($storyId);
  989. //// $tili = 0;
  990. //// $rewardStr = $memStoryModel->storyGateReward;
  991. ////
  992. ////#3 同步下剧情的推进进度数据
  993. //// if ($storrRecord->lastFinishedStoryGateId == $storyId || in_array($storyId, $storrRecord->allFinishedStoryGateIdList)) {
  994. //// return Resp::err(ErrCode::story_repeatfight); #剧情关卡不能重复战斗 只能打一次
  995. //// } else {
  996. //// $storrRecord->lastFinishedStoryGateId = $storyId;
  997. //// $storrRecord->allFinishedStoryGateIdList[] = $storyId;
  998. //// }
  999. ////#
  1000. ////# 4 万一打剧情也扣除体力呢
  1001. //// if ($tili > 0) {
  1002. //// ActiveProc::ChangeTili(-$tili, $req);
  1003. ////# 扣除多少体力就给账号增加多少经验 -by 李宁, reconfirmed by wg 20170519144109
  1004. //// UserGameModel::Add_Exp($req, $tili);
  1005. ////# 增加英雄经验(也是依据扣除的体力数)
  1006. //// foreach ($TeamObj as $heroUID) {
  1007. //// HeroProc::HeroAddEXP($heroUID, $tili, $req);
  1008. //// }
  1009. //// }# 5 玩家获得 剧情的战斗奖励
  1010. //// $err = StoreProc::AddMultiItemInStore($req, $rewardStr);
  1011. //// if ($err) {
  1012. //// return Resp::err($err);
  1013. //// }# 6 回存玩家的战斗记录
  1014. //// $req->userInfo->game->gates->story = $storrRecord;
  1015. //// UserProc::updateUserInfo($req); //在获取战利品哪里已经update了.
  1016. //// # Ps.备注,奖品是固定的,所以不必返回
  1017. //// $result = array(
  1018. //// 'store' => $req->userInfo->game->store,
  1019. //// 'heros' => $req->userInfo->game->heros,
  1020. //// 'gates' => $req->userInfo->game->gates,
  1021. //// 'tili' => $req->userInfo->game->tili,
  1022. //// 'time' => $req->userInfo->game->privateState->TiliTime
  1023. //// );
  1024. //// return Resp::ok($result);
  1025. //// }
  1026. ////
  1027. //// </editor-fold>
  1028. ////
  1029. //}
  1030. //
  1031. ///**
  1032. // * 任务/挑战目标达成记录(三星评价)
  1033. // * @author gwang
  1034. // */
  1035. //class GateStar {
  1036. //
  1037. // /**
  1038. // * 根据后台记录的数值构造(反向提供给前端显示层)
  1039. // * @param int $i
  1040. // */
  1041. // public function __construct($i) {
  1042. // $this->S1 = ($i & 1) > 0;
  1043. // $this->S2 = ($i & 2) > 0;
  1044. // $this->S3 = ($i & 4) > 0;
  1045. // }
  1046. //
  1047. // /**
  1048. // * @var bool 第一个目标达成
  1049. // */
  1050. // public $S1;
  1051. //
  1052. // /**
  1053. // * @var bool 第二个目标达成
  1054. // */
  1055. // public $S2;
  1056. //
  1057. // /**
  1058. // * @var bool 第三个目标达成
  1059. // */
  1060. // public $S3;
  1061. //
  1062. // /**
  1063. // * 统计总星数
  1064. // * @return int
  1065. // */
  1066. // public function Stars() {
  1067. // return ($this->S3 ? 1 : 0) + ($this->S2 ? 1 : 0) + ($this->S1 ? 1 : 0);
  1068. // }
  1069. //
  1070. //}