OpeCode.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Store = 64;
  20. const Shop = 65;
  21. const Hero = 66;
  22. const Email = 67;
  23. const Fight = 68;
  24. const System = 69;
  25. // <editor-fold defaultstate="collapsed" desc="反射方法">
  26. //
  27. /**
  28. * 依据opecode=> Proc模块名称
  29. * @param type $ope
  30. * @return string
  31. * @author gwang
  32. */
  33. public static function getProc($ope) {
  34. $r = new \ReflectionClass(__CLASS__); # 新建反射对象
  35. $procs = array_flip($r->getConstants()); # 提取操作码到数组中
  36. if (!isset($procs[$ope])) { # 找不到
  37. return 'err'; # 返回固定的字符串: err
  38. }
  39. return __NAMESPACE__ . '\\' . $procs[$ope] . 'Proc'; # 拼装处理模块的名称
  40. }
  41. // </editor-fold>
  42. }