FightProc.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. default:
  26. Err(ErrCode::cmd_err);
  27. }
  28. }
  29. public static function FightSettle() {
  30. }
  31. /**
  32. * 章节宝箱的领取
  33. * @return type
  34. */
  35. public static function PassGateTsPrizeReceive() {
  36. list($gateId,$index) = req()->paras;
  37. $gateMo = GameConfig::gate_getItem($gateId);
  38. my_Assert($gateMo!=null, ErrCode::err_const_no);
  39. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList, $gateId), ErrCode::user_Gate_NoUserGateInfo);
  40. $gateInfo = ctx()->gates->GateList->$gateId;
  41. $tag = false;
  42. $prize = "";
  43. $mask =0;
  44. switch ($index) {
  45. case 1:
  46. $ts = $gateMo->first_ts1 *60;
  47. if($ts >= $gateInfo->MaxSeconds){
  48. $tag = true;
  49. }
  50. $mask=1;
  51. $prize = $gateMo->first_reward1;
  52. break;
  53. case 2:
  54. $ts = $gateMo->first_ts2*60;
  55. if($ts >= $gateInfo->MaxSeconds){
  56. $tag = true;
  57. }
  58. $mask = 2;
  59. $prize = $gateMo->first_reward2;
  60. break;
  61. case 3:
  62. if($gateInfo->pass > 0){
  63. $tag = true;
  64. }
  65. $mask =3;
  66. $prize = $gateMo->first_reward3;
  67. break;
  68. default:
  69. break;
  70. }
  71. if($tag){
  72. StoreProc::AddMultiItemInStore($prize);
  73. $gateInfo->FirstReward = $mask;
  74. }
  75. ctx()->gates->GateList->$gateId=$gateInfo;
  76. UserProc::updateUserInfo();
  77. $ret = array(
  78. 'gate' => $gateInfo,
  79. 'store' => ctx()->store,
  80. );
  81. return Resp::ok($ret);
  82. }
  83. }