OpeCode.php 1.2 KB

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