OpeCode.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 功能码常量定义, 要求: 常量名称和对应的功能处理模块的名称相一致(无需Proc后缀).
  5. * @version 2023.8.31 修改约定: cmdcode前两位为opecode. 参数传递过程中不单独传输opecode了.
  6. * @author gwang,cyzhao
  7. */
  8. class OpeCode {
  9. /**
  10. * 支付功能
  11. */
  12. const Pay = 88;
  13. /**
  14. * 玩家主功能
  15. */
  16. const User = 60;
  17. const Active = 61;
  18. const Task = 62;
  19. const Email = 63;
  20. const Store = 64;
  21. const Shop = 65;
  22. const Hero = 66;
  23. const Fight = 68;
  24. // <editor-fold defaultstate="collapsed" desc="反射方法">
  25. //
  26. /**
  27. * 依据opecode=> Proc模块名称
  28. * @param type $ope
  29. * @return string
  30. * @author gwang
  31. */
  32. public static function getProc($ope) {
  33. $r = new \ReflectionClass(__CLASS__); # 新建反射对象
  34. $procs = array_flip($r->getConstants()); # 提取操作码到数组中
  35. if (!isset($procs[$ope])) { # 找不到
  36. return 'err'; # 返回固定的字符串: err
  37. }
  38. return __NAMESPACE__ . '\\' . $procs[$ope] . 'Proc'; # 拼装处理模块的名称
  39. }
  40. // </editor-fold>
  41. }