ErrCode.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 错误码及错误描述字典
  5. * @author gwang
  6. */
  7. class ErrCode {
  8. /**
  9. * 交互成功
  10. */
  11. const ok = 0;
  12. //
  13. // <editor-fold defaultstate="collapsed" desc=" 基础错误码 10xx ">
  14. /**
  15. * 未知原因错误
  16. */
  17. const err_unknownn = 1001;
  18. /**
  19. * 内部错误
  20. */
  21. const err_innerfault = 1002;
  22. /**
  23. * 数据库操作失败
  24. */
  25. const err_db = 1003;
  26. /**
  27. * 内存操作失败
  28. */
  29. const err_mem = 1004;
  30. /**
  31. * 断言失败
  32. */
  33. const err_assert = 1005;
  34. /**
  35. * 消息内容非法(不满足tk校验的条件)
  36. */
  37. const err_illegal = 1011;
  38. /**
  39. * 消息内容缺少校验值
  40. */
  41. const err_signo = 1012;
  42. /**
  43. * 消息超时
  44. */
  45. const err_outtime = 1021;
  46. /**
  47. * Just重试
  48. */
  49. const err_retry = 1024;
  50. /**
  51. * 客户端版本过低-整包更
  52. */
  53. const clientversionlow_err = 1031;
  54. /**
  55. * 客户端版本过低-增量更
  56. */
  57. const clientnewversion_msg = 1032;
  58. /**
  59. * 客户端打印信息并且退出
  60. */
  61. const clientPrintMsg_Halt = 1033;
  62. /**
  63. * 功能码非法
  64. */
  65. const ope_err = 1210;
  66. /**
  67. * 操作码非法
  68. */
  69. const cmd_err = 1211;
  70. /**
  71. * 参数非法
  72. */
  73. const paras_err = 1212;
  74. /**
  75. * 参数不足
  76. */
  77. const parasnotenough_msg = 1213;
  78. /**
  79. * 内容包含敏感词
  80. */
  81. const sensword_msg = 1234;
  82. /**
  83. * 服务器正在维护中
  84. */
  85. const err_server_maintaining = 1301;
  86. /**
  87. * 服务器正在升级,请过会儿再来。
  88. */
  89. const err_server_updating = 1302;
  90. /**
  91. * 已经在其他地方登录
  92. */
  93. const err_anotherlogin = 1303;
  94. /**
  95. * 功能暂未开放
  96. */
  97. const function_notopen_msg = 1801;
  98. /**
  99. * 方法尚未实现
  100. */
  101. const err_method_notimplement = 1802;
  102. /**
  103. * 方法已过时, 废弃的.
  104. */
  105. const err_method_obsoleted = 1803;
  106. /**
  107. * 游戏常量数据错误
  108. */
  109. const err_const_no = 1825;
  110. // </editor-fold>
  111. //
  112. // // <editor-fold defaultstate="collapsed" desc=" 商城/付费 88xx ">
  113. /**
  114. * 尚未首付
  115. */
  116. const pay_firstpayno_err = 8801;
  117. /**
  118. * 已经领取首付
  119. */
  120. const pay_firstpaygetted = 8802;
  121. /**
  122. * 系统繁忙
  123. */
  124. const pay_systembusy_err = 8803;
  125. /**
  126. * 不是黄钻或已经领取黄钻礼包
  127. */
  128. const pay_vipnewerno = 8804;
  129. /**
  130. * amt数值小于等于0
  131. */
  132. const pay_m_amtzero_err = 8805;
  133. /**
  134. * 价格异常
  135. */
  136. const pay_price_err = 8806;
  137. /**
  138. * 支付类型异常
  139. */
  140. const pay_m_type_err = 8807;
  141. /**
  142. * 商品常量数据错误-货物内容
  143. */
  144. const pay_shopItem_cosnt_goods_err = 8808;
  145. /**
  146. * 商城 已达刷新次数上限
  147. */
  148. const pay_refresh_times = 8809;
  149. /**
  150. * 神秘商城 - 购买次数已达上限
  151. */
  152. const pay_secretshop_buytimes = 8810;
  153. /**
  154. * 神秘商城 - 物品数据错误
  155. */
  156. const pay_secretshop_noitem_err = 8811;
  157. /**
  158. * 充值 - 订单不存在
  159. */
  160. const pay_order_no = 8812;
  161. /**
  162. * 充值 - 付款状态不正确 正在重新查询...
  163. */
  164. const pay_order_paystatus = 8813;
  165. /**
  166. * 充值 - 此订单已经发货, 无需重复请求
  167. */
  168. const pay_order_drawed = 8814;
  169. /**
  170. * 充值 - 订单uid不符
  171. */
  172. const pay_order_uid = 8815;
  173. /**
  174. * 神秘商城 - 免费刷新时间未到
  175. */
  176. const pay_secretshopt_freeRefresh_Time = 8816;
  177. const pay_order_product_id = 8817;
  178. const pay_fail = 8818;
  179. /**
  180. * 不能重复购买
  181. */
  182. const pay_repeatbuy = 8819;
  183. // </editor-fold>
  184. //
  185. // <editor-fold defaultstate="collapsed" desc=" not enough 系列 ">
  186. /**
  187. * 金币不足
  188. */
  189. const notenough_gold_msg = 3014;
  190. /**
  191. * 宝石不足
  192. */
  193. const notenough_cash_msg = 3015;
  194. /**
  195. * 友情点不足
  196. */
  197. const notenough_friendshippoint = 3016;
  198. /**
  199. * 玩家荣誉值不足[荣誉值兑换]
  200. */
  201. const notenough_honour = 3032;
  202. /**
  203. * 元宝不足
  204. */
  205. const notenought_yuanbao = 3040;
  206. /**
  207. * 玩家体力值不足
  208. */
  209. const notenough_tili = 3046;
  210. /**
  211. * 晶石不足
  212. */
  213. const notenough_spar = 3047;
  214. /**
  215. * 资源点不足
  216. */
  217. const notenough_resPoint = 3048;
  218. // </editor-fold>
  219. //
  220. // <editor-fold defaultstate="collapsed" desc=" user 31xx ">
  221. /**
  222. * 玩家未登录
  223. */
  224. const user_login_err = 3101;
  225. /**
  226. * 玩家不存在
  227. */
  228. const user_no_err = 3102;
  229. /**
  230. * 玩家数据损坏
  231. */
  232. const user_data_broken_err = 3103;
  233. /**
  234. * 连续登录天数不够
  235. */
  236. const user_contigiftno_msg = 3104;
  237. /**
  238. * 已经领取连续登录礼包
  239. */
  240. const user_contigiftfalse_msg = 3105;
  241. /**
  242. * 设置新手引导进度失败
  243. */
  244. const user_settutorialscompletedfail_err = 3106;
  245. /**
  246. * 玩家等级不足
  247. */
  248. const user_levelnotenough_msg = 3107;
  249. /**
  250. * 找不到玩家的交互体数据
  251. */
  252. const user_interact_no_err = 3108;
  253. /**
  254. * 找不到玩家的分区记录
  255. */
  256. const user_zoneinfo_no_err = 3109;
  257. /**
  258. * 玩家昵称已经存在,请换一个再试
  259. */
  260. const user_nicknameexist = 3110;
  261. /**
  262. * 没有这种奖励类型
  263. */
  264. const user_reward_typeno = 3031;
  265. // </editor-fold>
  266. //
  267. // // <editor-fold defaultstate="collapsed" desc=" 关卡 ">
  268. const user_Gate_NoUserGateInfo = 3201;
  269. // </editor-fold>
  270. //
  271. // // <editor-fold defaultstate="collapsed" desc=" store 3300 ">
  272. const user_store_NoEquip = 3301;
  273. // </editor-fold>
  274. //
  275. // <editor-fold defaultstate="collapsed" desc=" 反射方法 ">
  276. /**
  277. * 辅助方法, 将所有错误码信息转换到CSV文本中.
  278. * 用法: 先在本文件中用ctrl + H 全部替换掉 'c onst ' -> 's tatic $'
  279. * 然后再调用本方法,即可在同目录下生成ErrCode.txt, 里面包含了所需信息.
  280. * @throws \Exception
  281. * @author gwang
  282. */
  283. static function L() {
  284. $class = new \ReflectionClass(__CLASS__); # 建立这个类的反射对象
  285. $properties = $class->getProperties(\ReflectionProperty::IS_STATIC); # 拉取所有静态属性
  286. $fileName = __DIR__ . "/ErrCode.txt"; # 输出文件名
  287. $fd = fopen($fileName, "w");
  288. if (false === $fd) { # 打开文件失败
  289. throw new \Exception("打开$fileName 失败");
  290. }
  291. foreach ($properties as &$p) {
  292. $d = preg_replace('/[\*|\/|\s+]/', '', $p->getDocComment()); # 处理下注释
  293. $type = (strpos($p->getName(), 'err') === false ? 0 : 1); # errorType: 0 继续, 1 重启
  294. $n = fputs($fd, $p->getName() . ";" . $p->getValue() . ";$type;$d" . PHP_EOL); # 写入文件
  295. if (false === $n) { # 写入时失败
  296. throw new Exception("写入$fileName 时失败");
  297. }
  298. }
  299. fclose($fd);
  300. }
  301. /**
  302. * 辅助方法, 将所有错误码信息转换到CS文件中.
  303. * 用法: 先在本文件中用ctrl + H 全部替换掉 'c onst ' -> 's tatic $'
  304. * 然后再调用本方法,即可在同目录下生成ErrCode.cs, 里面包含了所有错误信息.
  305. * @throws \Exception
  306. * @author gwang
  307. */
  308. static function M() {
  309. $class = new \ReflectionClass(__CLASS__); # 建立这个类的反射对象
  310. $properties = $class->getProperties(\ReflectionProperty::IS_STATIC); # 拉取所有静态属性
  311. $fileName = __DIR__ . "/ErrCode.cs"; # 输出文件名
  312. $fd = fopen($fileName, "w");
  313. if (false === $fd) { # 打开文件失败
  314. throw new \Exception("打开$fileName 失败");
  315. }
  316. $classHead = <<<HEAD
  317. /// <summary>
  318. /// 错误码
  319. /// </summary>
  320. class ErrCode
  321. {
  322. HEAD;
  323. $classEnd = <<<END
  324. }
  325. END;
  326. $cst = 'const';
  327. fputs($fd, $classHead); # 类头
  328. foreach ($properties as &$p) {
  329. $d = preg_replace('/[\*|\/|\s+]/', '', $p->getDocComment()); # 提取注释
  330. $pname = $p->getName(); # 字段名称
  331. $pvalue = $p->getValue(); # 错误码
  332. $filed = <<<FILED
  333. /// <summary>
  334. /// {$d}
  335. /// </summary>
  336. public {$cst} int {$pname} = {$pvalue};
  337. FILED;
  338. $n = fputs($fd, $filed); # 写入错误编号
  339. if (false === $n) { # 写入时失败
  340. throw new Exception("写入$fileName 时失败");
  341. }
  342. }
  343. fputs($fd, $classEnd); # 类尾
  344. fclose($fd);
  345. }
  346. // </editor-fold>
  347. }
  348. //ErrCode::L();
  349. //ErrCode::M();