HeroProc.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  4. * Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
  5. */
  6. namespace loyalsoft;
  7. /**
  8. * Description of HeroProc
  9. *
  10. * @author gwang
  11. */
  12. class HeroProc {
  13. //put your code here
  14. /**
  15. * 逻辑分发
  16. * 所有的Proc中必须有这样一个方法
  17. * @param Req $req
  18. */
  19. public static function procMain($req) {
  20. switch ($req->cmd) {
  21. case CmdCode::hero_swith: # 6601 切换英雄
  22. return HeroProc::SwithHero();
  23. case CmdCode::hero_unlock: # 6602 解锁英雄
  24. return self::UnlockHero();
  25. default:
  26. Err(ErrCode::cmd_err);
  27. }
  28. }
  29. /**
  30. * 6602 解锁英雄
  31. * @return type
  32. */
  33. private static function UnlockHero() {
  34. list($newHeroId) = req()->paras; # 切换英雄id
  35. my_Assert(GameConfig::hero_getItem($newHeroId) != null, "找不到英雄配置数据!");
  36. // 解锁消耗,
  37. // 解锁成功.
  38. ctx()->heros->Dic->$newHeroId = new Ins_Hero();
  39. return Resp::ok();
  40. }
  41. /**
  42. * 6601 切换英雄
  43. */
  44. private static function SwithHero() {
  45. list($newHeroId) = req()->paras; # 切换英雄id
  46. my_Assert(CommUtil::isPropertyExists(ctx()->heros->Dic, $newHeroId), "尚未获得此英雄!");
  47. ctx()->heros->CurrentHeroId = $newHeroId;
  48. return Resp::ok();
  49. }
  50. }