FightProc.php 4.7 KB

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