FightProc.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. public static function PassGateTsPrizeReceive() {
  32. list($gateId,$index) = req()->paras;
  33. $gateMo = GameConfig::gate_getItem($gateId);
  34. my_Assert($gateMo!=null, ErrCode::err_const_no);
  35. $prizelist = ctx()->fight()->gateTsPrizeRevicedList;
  36. $recordlist = ctx()->fight()->gateTsRecord;
  37. for($i = $index -1 ; $i >0; $i--){//校验是否满足条件
  38. $str = $gateId.'-'.$i;
  39. my_Assert(in_array($str, $recordlist) && in_array($str, $prizelist), ErrCode::err_const_no);
  40. }
  41. my_Assert(in_array($str, $recordlist) && !in_array($str, $prizelist), ErrCode::err_const_no);
  42. $key = 'first_reward'.$index;
  43. StoreProc::AddMultiItemInStore($gateMo->$key);
  44. ctx()->fight()->gateTsPrizeRevicedList[] = $gateId.'-'.$index;
  45. UserProc::updateUserInfo();
  46. $ret = array(
  47. 'gateTsPrize' => ctx()->fight()->gateTsPrizeRevicedList,
  48. 'store' => 'ok',
  49. );
  50. return Resp::ok($ret);
  51. }
  52. }