FightProc.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. default:
  30. Err(ErrCode::cmd_err);
  31. }
  32. }
  33. /**
  34. * 挑战奖励领取
  35. * @return type
  36. */
  37. public static function GateChallengePriceReviced() {
  38. list($zhangjieId, $gateId) = req()->paras;
  39. $mo = GameConfig::gate_challenge_getItem($zhangjieId);
  40. my_Assert($mo!=null, ErrCode::err_const_no);
  41. // $list = explode(',', $mo->gates);
  42. // my_Assert(in_array($gateId,$list), ErrCode::err_const_no);
  43. $gateMo = GameConfig::gate_getItem($gateId);
  44. my_Assert($gateMo!=null, ErrCode::err_const_no);
  45. if(!StlUtil::dictHasProperty(ctx()->gates->GatesChallengeRecord, $zhangjieId)){
  46. ctx()->gates->GatesChallengeRecord->$zhangjieId = array();
  47. }
  48. my_Assert(!in_array($gateId,ctx()->gates->GatesChallengeRecord->$zhangjieId), ErrCode::user_Gate_GatePriceHasReceive);
  49. ctx()->gates->GatesChallengeRecord->$zhangjieId[] = $gateId;
  50. StoreProc::AddMultiItemInStore($gateMo->reward_win);
  51. ctx()->gates->CurrentGateId = $gateId;
  52. UserProc::updateUserInfo();
  53. $ret = array(
  54. 'store' => ctx()->store,
  55. 'gates' => ctx()->gates,
  56. );
  57. return Resp::ok($ret);
  58. }
  59. /**
  60. * 关卡选择
  61. * @return type
  62. */
  63. public static function SelectGate() {
  64. list($gateId) = req()->paras;
  65. ctx()->gates->CurrentGateId = $gateId;
  66. UserProc::updateUserInfo();
  67. $ret = array(
  68. 'gates' => ctx()->gates,
  69. );
  70. return Resp::ok($ret);
  71. }
  72. /**
  73. * 关卡战斗结算
  74. * @return type
  75. */
  76. public static function Settle() {
  77. list($resultType, $gateId,$gold,$exp,$curTs) = req()->paras;
  78. $gateMo = GameConfig::gate_getItem($gateId);
  79. my_Assert($gateMo!=null, ErrCode::err_const_no);
  80. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo);
  81. $gateInfo = ctx()->gates->GateList->$gateId;
  82. $ts = $gateInfo->MaxSeconds;
  83. if($curTs >= $ts){
  84. $gateInfo->MaxSeconds = $curTs;
  85. }
  86. if($resultType){
  87. if(ctx()->gates->GateList->$gateId->pass == 0){
  88. ctx()->gates->GateList->$gateId->pass = 1;
  89. }
  90. StoreProc::AddMultiItemInStore($gateMo->reward_win);
  91. $newGateId = $gateId+1;
  92. if(!StlUtil::dictHasProperty(ctx()->gates->GateList, $newGateId)){
  93. ctx()->gates->CurrentGateId = $newGateId;
  94. ctx()->gates->UnlockedGatesMaxId = $newGateId;
  95. $gate = new Ins_GateInfo();
  96. $gate->GateId = $newGateId;
  97. ctx()->gates->GateList->$newGateId = $gate;
  98. }
  99. } else {
  100. StoreProc::AddMultiItemInStore($gateMo->reward_fail);
  101. }
  102. ctx()->baseInfo->Add_Gold($gold);
  103. ctx()->baseInfo->Add_Exp($exp);
  104. UserProc::updateUserInfo();
  105. $ret = array(
  106. 'gates' => ctx()->gates,
  107. 'store' => ctx()->store,
  108. );
  109. return Resp::ok($ret);
  110. }
  111. /**
  112. * 章节宝箱的领取
  113. * @return type
  114. */
  115. public static function PassGateTsPrizeReceive() {
  116. list($gateId,$index) = req()->paras;
  117. $gateMo = GameConfig::gate_getItem($gateId);
  118. my_Assert($gateMo!=null, ErrCode::err_const_no);
  119. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo);
  120. $gateInfo = ctx()->gates->GateList->$gateId;
  121. $tag = false;
  122. $prize = "";
  123. $mask =0;
  124. switch ($index) {
  125. case 1:
  126. $ts = $gateMo->first_ts1 *60;
  127. if($ts >= $gateInfo->MaxSeconds){
  128. $tag = true;
  129. }
  130. $mask=1;
  131. $prize = $gateMo->first_reward1;
  132. break;
  133. case 2:
  134. $ts = $gateMo->first_ts2*60;
  135. if($ts >= $gateInfo->MaxSeconds){
  136. $tag = true;
  137. }
  138. $mask = 2;
  139. $prize = $gateMo->first_reward2;
  140. break;
  141. case 3:
  142. if($gateInfo->pass > 0){
  143. $tag = true;
  144. }
  145. $mask =3;
  146. $prize = $gateMo->first_reward3;
  147. break;
  148. default:
  149. break;
  150. }
  151. if($tag){
  152. StoreProc::AddMultiItemInStore($prize);
  153. $gateInfo->FirstReward = $mask;
  154. }
  155. ctx()->gates->GateList->$gateId=$gateInfo;
  156. UserProc::updateUserInfo();
  157. $ret = array(
  158. 'gates' => ctx()->gates,
  159. 'store' => ctx()->store,
  160. );
  161. return Resp::ok($ret);
  162. }
  163. }