FightProc.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace loyalsoft;
  8. /**
  9. * Description of FightProc
  10. *
  11. * @author c'y'zhao
  12. */
  13. class FightProc {
  14. /**
  15. * 逻辑分发
  16. * 所有的Proc中必须有这样一个方法
  17. * @param Req $req
  18. */
  19. public static function procMain($req) {
  20. switch ($req->cmd) {
  21. case CmdCode::cmd_fight_settle: # 6801 战斗结算
  22. return FightProc::Settle();
  23. case CmdCode::cmd_fight_PassGateTsPrizeReceive: # 6802 章节宝箱的领取
  24. return FightProc::PassGateTsPrizeReceive();
  25. case CmdCode::cmd_fight_selectGate: # 6803 关卡选择
  26. return FightProc::SelectGate();
  27. case CmdCode::cmd_fight_gateChallengePriceReviced: # 6804
  28. return FightProc::GateChallengePriceReviced();
  29. case CmdCode::cmd_fight_evolveUnlock: # 6805进化解锁
  30. return FightProc::EvolveUnlock();
  31. case CmdCode::cmd_fight_plotSav: # 6806 剧情回存
  32. return FightProc::PlotSav();
  33. default:
  34. Err(ErrCode::cmd_err);
  35. }
  36. }
  37. /**
  38. * 剧情回存
  39. * @return type
  40. */
  41. public static function PlotSav() {
  42. list($gateId) = req()->paras;
  43. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList,$gateId), ErrCode::err_const_no);
  44. ctx()->gates->GateList->$gateId->plotStart = 1;
  45. UserProc::updateUserInfo();
  46. $ret = array(
  47. 'ok' => 1,
  48. );
  49. return Resp::ok($ret);
  50. }
  51. /**
  52. * EvolveUnlock
  53. * @return type
  54. */
  55. public static function EvolveUnlock() {
  56. list($type,$id) = req()->paras;
  57. if($type == 1){
  58. $mo = GameConfig::evolve_getItem($id);
  59. my_Assert($mo!=null, ErrCode::err_const_no);
  60. my_Assert(ctx()->baseInfo->gold>=$mo->needGold_unlock, ErrCode::notenough_gold_msg);
  61. ctx()->baseInfo->Consume_Gold($mo->needGold_unlock);
  62. } else {
  63. $mo =GameConfig::evolveSpecific_getItem($id);
  64. my_Assert($mo!=null, ErrCode::err_const_no);
  65. if($mo->specificEvolveCost != null){
  66. $cost = explode(',', $mo->specificEvolveCost);
  67. $costId = $cost[0];
  68. $costNum = $cost[1];
  69. my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $costId) && ctx()->store->items->$costId >= $costNum , ErrCode::notenough_item);
  70. }
  71. // my_Assert(ctx()->baseInfo->gold>=$mo->needGold_unlock, ErrCode::notenough_gold_msg);
  72. }
  73. ctx()->gates->evolveUnlockRecord[] = $id;
  74. UserProc::updateUserInfo();
  75. $ret = array(
  76. 'store' => ctx()->store,
  77. 'gates' => ctx()->gates,
  78. );
  79. return Resp::ok($ret);
  80. }
  81. /**
  82. * 挑战奖励领取
  83. * @return type
  84. */
  85. public static function GateChallengePriceReviced() {
  86. list($zhangjieId, $gateId) = req()->paras;
  87. $mo = GameConfig::gate_challenge_getItem($zhangjieId);
  88. my_Assert($mo!=null, ErrCode::err_const_no);
  89. // $list = explode(',', $mo->gates);
  90. // my_Assert(in_array($gateId,$list), ErrCode::err_const_no);
  91. $gateMo = GameConfig::gate_getItem($gateId);
  92. my_Assert($gateMo!=null, ErrCode::err_const_no);
  93. if(!StlUtil::dictHasProperty(ctx()->gates->GatesChallengeRecord, $zhangjieId)){
  94. ctx()->gates->GatesChallengeRecord->$zhangjieId = array();
  95. }
  96. my_Assert(!in_array($gateId,ctx()->gates->GatesChallengeRecord->$zhangjieId), ErrCode::user_Gate_GatePriceHasReceive);
  97. ctx()->gates->GatesChallengeRecord->$zhangjieId[] = $gateId;
  98. StoreProc::AddMultiItemInStore($gateMo->reward_win);
  99. ctx()->gates->CurrentGateId = $gateId;
  100. UserProc::updateUserInfo();
  101. $ret = array(
  102. 'store' => ctx()->store,
  103. 'gates' => ctx()->gates,
  104. );
  105. return Resp::ok($ret);
  106. }
  107. /**
  108. * 关卡选择
  109. * @return type
  110. */
  111. public static function SelectGate() {
  112. list($gateId) = req()->paras;
  113. ctx()->gates->CurrentGateId = $gateId;
  114. UserProc::updateUserInfo();
  115. $ret = array(
  116. 'gates' => ctx()->gates,
  117. );
  118. return Resp::ok($ret);
  119. }
  120. /**
  121. * 关卡战斗结算
  122. * @return type
  123. */
  124. public static function Settle() {
  125. list($resultType, $gateId,$gold,$curTs) = req()->paras;
  126. $gateMo = GameConfig::gate_getItem($gateId);
  127. my_Assert($gateMo!=null, ErrCode::err_const_no);
  128. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo);
  129. $gateInfo = ctx()->gates->GateList->$gateId;
  130. $ts = $gateInfo->MaxSeconds;
  131. if($curTs >= $ts){
  132. $gateInfo->MaxSeconds = $curTs;
  133. }
  134. if($resultType){
  135. if(ctx()->gates->GateList->$gateId->pass == 0){
  136. ctx()->gates->GateList->$gateId->pass = 1;
  137. }
  138. StoreProc::AddMultiItemInStore($gateMo->reward_win);
  139. $newGateId = $gateId+1;
  140. if(!StlUtil::dictHasProperty(ctx()->gates->GateList, $newGateId)){
  141. ctx()->gates->CurrentGateId = $newGateId;
  142. ctx()->gates->UnlockedGatesMaxId = $newGateId;
  143. $gate = new Ins_GateInfo();
  144. $gate->GateId = $newGateId;
  145. ctx()->gates->GateList->$newGateId = $gate;
  146. }
  147. } else {
  148. StoreProc::AddMultiItemInStore($gateMo->reward_fail);
  149. }
  150. ctx()->baseInfo->Add_Gold($gold);
  151. //ctx()->baseInfo->Add_Exp($exp);
  152. UserProc::updateUserInfo();
  153. $ret = array(
  154. 'gates' => ctx()->gates,
  155. 'store' => ctx()->store,
  156. );
  157. return Resp::ok($ret);
  158. }
  159. /**
  160. * 章节宝箱的领取
  161. * @return type
  162. */
  163. public static function PassGateTsPrizeReceive() {
  164. list($gateId,$index) = req()->paras;
  165. $gateMo = GameConfig::gate_getItem($gateId);
  166. my_Assert($gateMo!=null, ErrCode::err_const_no);
  167. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo);
  168. $gateInfo = ctx()->gates->GateList->$gateId;
  169. $tag = false;
  170. $prize = "";
  171. $mask =0;
  172. switch ($index) {
  173. case 1:
  174. $ts = $gateMo->first_ts1 *60;
  175. if($ts >= $gateInfo->MaxSeconds){
  176. $tag = true;
  177. }
  178. $mask=1;
  179. $prize = $gateMo->first_reward1;
  180. break;
  181. case 2:
  182. $ts = $gateMo->first_ts2*60;
  183. if($ts >= $gateInfo->MaxSeconds){
  184. $tag = true;
  185. }
  186. $mask = 2;
  187. $prize = $gateMo->first_reward2;
  188. break;
  189. case 3:
  190. if($gateInfo->pass > 0){
  191. $tag = true;
  192. }
  193. $mask =3;
  194. $prize = $gateMo->first_reward3;
  195. break;
  196. default:
  197. break;
  198. }
  199. if($tag){
  200. StoreProc::AddMultiItemInStore($prize);
  201. $gateInfo->FirstReward = $mask;
  202. }
  203. ctx()->gates->GateList->$gateId=$gateInfo;
  204. UserProc::updateUserInfo();
  205. $ret = array(
  206. 'gates' => ctx()->gates,
  207. 'store' => ctx()->store,
  208. );
  209. return Resp::ok($ret);
  210. }
  211. }