OpeCode.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 功能码常量定义, 要求: 常量名称和对应的功能处理模块的名称相一致(无需Proc后缀).
  5. * @author gwang
  6. */
  7. class OpeCode {
  8. /**
  9. * 支付功能
  10. */
  11. const Pay = 888;
  12. /**
  13. * 玩家主功能
  14. */
  15. const User = 600;
  16. /**
  17. * 好友功能
  18. */
  19. const Friend = 601;
  20. /**
  21. * 任务模块
  22. */
  23. const Task = 602;
  24. /**
  25. * 英雄功能
  26. */
  27. const Hero = 603;
  28. /**
  29. * 邮件功能
  30. */
  31. const Email = 604;
  32. /**
  33. * 活动功能
  34. */
  35. const Active = 605;
  36. /**
  37. * 战斗功能
  38. */
  39. const Fight = 606;
  40. /**
  41. * 商城功能
  42. */
  43. const Shop = 607;
  44. /**
  45. * 仓库功能
  46. */
  47. const Store = 608;
  48. /** 系统功能 */
  49. const System = 609;
  50. /**
  51. * 排行榜功能
  52. */
  53. const Rank = 611;
  54. /**
  55. * 事件功能
  56. */
  57. const Event = 612;
  58. //
  59. //
  60. // <editor-fold defaultstate="collapsed" desc="反射方法">
  61. //
  62. /**
  63. * 依据opecode=> Proc模块名称
  64. * @param type $ope
  65. * @return string
  66. * @author gwang
  67. */
  68. public static function getProc($ope) {
  69. $r = new \ReflectionClass(__CLASS__); # 新建反射对象
  70. $procs = array_flip($r->getConstants()); # 提取操作码到数组中
  71. if (!isset($procs[$ope])) { # 找不到
  72. return 'err'; # 返回固定的字符串: err
  73. }
  74. return __NAMESPACE__ . '\\' . $procs[$ope] . 'Proc'; # 拼装处理模块的名称
  75. }
  76. // </editor-fold>
  77. }