GameConfig.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <?php
  2. ////////////////////
  3. // 由CodeGenerator创建。
  4. // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  5. // author: gwang
  6. // 日期: 2024-05-06 16:53:57
  7. ////////////////////
  8. namespace loyalsoft;
  9. /**
  10. * 常量配置数据
  11. */
  12. class GameConfig {
  13. // <editor-fold defaultstate="collapsed" desc=" 基础代码 ">
  14. /**
  15. * 是否启用codegen
  16. */
  17. private static function isCG() {
  18. return defined('CodeGen_Enabled') && CodeGen_Enabled;
  19. }
  20. /**
  21. * @var bool 分区是否使用独立的常量配置数据
  22. */
  23. private static $useZoneId = false;
  24. /**
  25. * 追加分区列表字符串
  26. * @return string
  27. */
  28. private static function zoneid()
  29. {
  30. global $zoneid;
  31. return self::$useZoneId ? "-zone$zoneid" : "";
  32. }
  33. /**
  34. * @return ClientVersion
  35. */
  36. private static function CV() {
  37. return req() ? req()->CV . '-' : "";
  38. }
  39. /**
  40. * 初始化指定变量, 非null的情况下直接跳出
  41. * 可能从文件中或者redis中获取原始数据对变量进行初始化
  42. * @param mixed $a 变量
  43. * @param string $modelName 用来初始化变量的资源名称
  44. * @param bool $isHash 数据是否采用hash结构(否:普通字符串)
  45. */
  46. static private function initValue(&$a, $modelName, $isHash = true) {
  47. $key = 'gamecfg-' . self::CV() . $modelName . self::zoneid();
  48. if (is_null($a)) {
  49. if (self::isCG()) {
  50. $a = include $key . '.php';
  51. if ($isHash) {
  52. $para = is_array($a) ? $a : (array) $a; # 转关联数组
  53. foreach ($para as $name => &$value) {
  54. $value = JsonUtil::decode($value); # 取参数中的或者默认值
  55. }
  56. $a = arr2obj($para);
  57. }
  58. } else {
  59. $a = $isHash ? gMem()->hgetall($key) : gMem()->get($key);
  60. }
  61. }
  62. return $a;
  63. }
  64. /**
  65. * 获取hash结构的一个item
  66. * @param string $modelName 模块名称
  67. * @param mixed/string/int $itemId 索引
  68. * @return mixed
  69. */
  70. private static function get_hash_item($modelName, $itemId) {
  71. if (self::isCG()) {
  72. $data = self::$modelName();
  73. if (property_exists($data, $itemId)) {
  74. return $data->$itemId;
  75. }
  76. } else {
  77. $key = 'gamecfg-' . self::CV() . $modelName . self::zoneid();
  78. return gMem()->hget($key, $itemId);
  79. }
  80. return null;
  81. }
  82. // </editor-fold>
  83. /**
  84. * 全局参数
  85. * @return \globalsettings
  86. */
  87. public static function globalsettings()
  88. {
  89. static $a = null;
  90. return self::initValue($a, 'globalsettings');
  91. }
  92. /**
  93. * 停服计划
  94. * @return \service_schedule
  95. */
  96. public static function service_schedule()
  97. {
  98. static $a = null;
  99. return self::initValue($a, 'service_schedule');
  100. }
  101. /**
  102. * @return \sm_service_schedule service_schedule item数据
  103. */
  104. public static function service_schedule_getItem($itemid)
  105. {
  106. return self::get_hash_item('service_schedule', $itemid);
  107. }
  108. /**
  109. * 道具表
  110. * @return \item
  111. */
  112. public static function item()
  113. {
  114. static $a = null;
  115. return self::initValue($a, 'item');
  116. }
  117. /**
  118. * @return \sm_item item item数据
  119. */
  120. public static function item_getItem($itemid)
  121. {
  122. return self::get_hash_item('item', $itemid);
  123. }
  124. /**
  125. * 系统邮件
  126. * @return \sysmail
  127. */
  128. public static function sysmail()
  129. {
  130. static $a = null;
  131. return self::initValue($a, 'sysmail');
  132. }
  133. /**
  134. * @return \sm_sysmail sysmail item数据
  135. */
  136. public static function sysmail_getItem($itemid)
  137. {
  138. return self::get_hash_item('sysmail', $itemid);
  139. }
  140. /**
  141. * 客户端版本信息
  142. * @return \clientVersionHistory
  143. */
  144. public static function clientVersionHistory()
  145. {
  146. static $a = null;
  147. return self::initValue($a, 'clientVersionHistory');
  148. }
  149. /**
  150. * @return \sm_clientVersionHistory clientVersionHistory item数据
  151. */
  152. public static function clientVersionHistory_getItem($itemid)
  153. {
  154. return self::get_hash_item('clientVersionHistory', $itemid);
  155. }
  156. /**
  157. * 错误信息表
  158. * @return \errmsg
  159. */
  160. public static function errmsg()
  161. {
  162. static $a = null;
  163. return self::initValue($a, 'errmsg');
  164. }
  165. /**
  166. * @return \sm_errmsg errmsg item数据
  167. */
  168. public static function errmsg_getItem($itemid)
  169. {
  170. return self::get_hash_item('errmsg', $itemid);
  171. }
  172. /**
  173. * 活动: 七日签到
  174. * @return \activity_day7
  175. */
  176. public static function activity_day7()
  177. {
  178. static $a = null;
  179. return self::initValue($a, 'activity_day7');
  180. }
  181. /**
  182. * @return \sm_activity_day7 activity_day7 item数据
  183. */
  184. public static function activity_day7_getItem($itemid)
  185. {
  186. return self::get_hash_item('activity_day7', $itemid);
  187. }
  188. /**
  189. * 章节表
  190. * @return \gate
  191. */
  192. public static function gate()
  193. {
  194. static $a = null;
  195. return self::initValue($a, 'gate');
  196. }
  197. /**
  198. * @return \sm_gate gate item数据
  199. */
  200. public static function gate_getItem($itemid)
  201. {
  202. return self::get_hash_item('gate', $itemid);
  203. }
  204. /**
  205. * 角色
  206. * @return \hero
  207. */
  208. public static function hero()
  209. {
  210. static $a = null;
  211. return self::initValue($a, 'hero');
  212. }
  213. /**
  214. * @return \sm_hero hero item数据
  215. */
  216. public static function hero_getItem($itemid)
  217. {
  218. return self::get_hash_item('hero', $itemid);
  219. }
  220. /**
  221. * 装备表
  222. * @return \equip
  223. */
  224. public static function equip()
  225. {
  226. static $a = null;
  227. return self::initValue($a, 'equip');
  228. }
  229. /**
  230. * @return \sm_equip equip item数据
  231. */
  232. public static function equip_getItem($itemid)
  233. {
  234. return self::get_hash_item('equip', $itemid);
  235. }
  236. /**
  237. * 装备升级表
  238. * @return \equip_levelupgrade
  239. */
  240. public static function equip_levelupgrade()
  241. {
  242. static $a = null;
  243. return self::initValue($a, 'equip_levelupgrade');
  244. }
  245. /**
  246. * @return \sm_equip_levelupgrade equip_levelupgrade item数据
  247. */
  248. public static function equip_levelupgrade_getItem($itemid)
  249. {
  250. return self::get_hash_item('equip_levelupgrade', $itemid);
  251. }
  252. /**
  253. * 章节礼包表
  254. * @return \shop_gategift
  255. */
  256. public static function shop_gategift()
  257. {
  258. static $a = null;
  259. return self::initValue($a, 'shop_gategift');
  260. }
  261. /**
  262. * @return \sm_shop_gategift shop_gategift item数据
  263. */
  264. public static function shop_gategift_getItem($itemid)
  265. {
  266. return self::get_hash_item('shop_gategift', $itemid);
  267. }
  268. /**
  269. * 每日商店
  270. * @return \shop_daily
  271. */
  272. public static function shop_daily()
  273. {
  274. static $a = null;
  275. return self::initValue($a, 'shop_daily');
  276. }
  277. /**
  278. * @return \sm_shop_daily shop_daily item数据
  279. */
  280. public static function shop_daily_getItem($itemid)
  281. {
  282. return self::get_hash_item('shop_daily', $itemid);
  283. }
  284. /**
  285. * 钻石
  286. * @return \shop_cash
  287. */
  288. public static function shop_cash()
  289. {
  290. static $a = null;
  291. return self::initValue($a, 'shop_cash');
  292. }
  293. /**
  294. * @return \sm_shop_cash shop_cash item数据
  295. */
  296. public static function shop_cash_getItem($itemid)
  297. {
  298. return self::get_hash_item('shop_cash', $itemid);
  299. }
  300. /**
  301. * 金币
  302. * @return \shop_gold
  303. */
  304. public static function shop_gold()
  305. {
  306. static $a = null;
  307. return self::initValue($a, 'shop_gold');
  308. }
  309. /**
  310. * @return \sm_shop_gold shop_gold item数据
  311. */
  312. public static function shop_gold_getItem($itemid)
  313. {
  314. return self::get_hash_item('shop_gold', $itemid);
  315. }
  316. /**
  317. *
  318. * @return \shop_supply
  319. */
  320. public static function shop_supply()
  321. {
  322. static $a = null;
  323. return self::initValue($a, 'shop_supply');
  324. }
  325. /**
  326. * @return \sm_shop_supply shop_supply item数据
  327. */
  328. public static function shop_supply_getItem($itemid)
  329. {
  330. return self::get_hash_item('shop_supply', $itemid);
  331. }
  332. /**
  333. * 词条配置表
  334. * @return \predicate
  335. */
  336. public static function predicate()
  337. {
  338. static $a = null;
  339. return self::initValue($a, 'predicate');
  340. }
  341. /**
  342. * @return \sm_predicate predicate item数据
  343. */
  344. public static function predicate_getItem($itemid)
  345. {
  346. return self::get_hash_item('predicate', $itemid);
  347. }
  348. /**
  349. * 商城军备
  350. * @return \shop_junbei
  351. */
  352. public static function shop_junbei()
  353. {
  354. static $a = null;
  355. return self::initValue($a, 'shop_junbei');
  356. }
  357. /**
  358. * @return \sm_shop_junbei shop_junbei item数据
  359. */
  360. public static function shop_junbei_getItem($itemid)
  361. {
  362. return self::get_hash_item('shop_junbei', $itemid);
  363. }
  364. /**
  365. * 进化表
  366. * @return \evolve
  367. */
  368. public static function evolve()
  369. {
  370. static $a = null;
  371. return self::initValue($a, 'evolve');
  372. }
  373. /**
  374. * @return \sm_evolve evolve item数据
  375. */
  376. public static function evolve_getItem($itemid)
  377. {
  378. return self::get_hash_item('evolve', $itemid);
  379. }
  380. /**
  381. * 7日签到累计
  382. * @return \active_day7_accumulate
  383. */
  384. public static function active_day7_accumulate()
  385. {
  386. static $a = null;
  387. return self::initValue($a, 'active_day7_accumulate');
  388. }
  389. /**
  390. * @return \sm_active_day7_accumulate active_day7_accumulate item数据
  391. */
  392. public static function active_day7_accumulate_getItem($itemid)
  393. {
  394. return self::get_hash_item('active_day7_accumulate', $itemid);
  395. }
  396. /**
  397. * 宝石表
  398. * @return \gem
  399. */
  400. public static function gem()
  401. {
  402. static $a = null;
  403. return self::initValue($a, 'gem');
  404. }
  405. /**
  406. * @return \sm_gem gem item数据
  407. */
  408. public static function gem_getItem($itemid)
  409. {
  410. return self::get_hash_item('gem', $itemid);
  411. }
  412. /**
  413. * 秘宝表
  414. * @return \gate_sbox
  415. */
  416. public static function gate_sbox()
  417. {
  418. static $a = null;
  419. return self::initValue($a, 'gate_sbox');
  420. }
  421. /**
  422. * @return \sm_gate_sbox gate_sbox itemArray
  423. */
  424. public static function gate_sbox_getItemArray($key)
  425. {
  426. return self::get_hash_item('gate_sbox', $key);
  427. }
  428. /**
  429. * 最新的成就
  430. * @return \achieve_new
  431. */
  432. public static function achieve_new()
  433. {
  434. static $a = null;
  435. return self::initValue($a, 'achieve_new');
  436. }
  437. /**
  438. * @return \sm_achieve_new achieve_new item数据
  439. */
  440. public static function achieve_new_getItem($itemid)
  441. {
  442. return self::get_hash_item('achieve_new', $itemid);
  443. }
  444. /**
  445. * 人物属性
  446. * @return \heroattr
  447. */
  448. public static function heroattr()
  449. {
  450. static $a = null;
  451. return self::initValue($a, 'heroattr');
  452. }
  453. /**
  454. * @return \sm_heroattr heroattr item数据
  455. */
  456. public static function heroattr_getItem($itemid)
  457. {
  458. return self::get_hash_item('heroattr', $itemid);
  459. }
  460. /**
  461. * 剧情对话
  462. * @return \plots
  463. */
  464. public static function plots()
  465. {
  466. static $a = null;
  467. return self::initValue($a, 'plots');
  468. }
  469. /**
  470. * @return \sm_plots plots item数据
  471. */
  472. public static function plots_getItem($itemid)
  473. {
  474. return self::get_hash_item('plots', $itemid);
  475. }
  476. /**
  477. * 商城宝箱表
  478. * @return \shop_box
  479. */
  480. public static function shop_box()
  481. {
  482. static $a = null;
  483. return self::initValue($a, 'shop_box');
  484. }
  485. /**
  486. * @return \sm_shop_box shop_box item数据
  487. */
  488. public static function shop_box_getItem($itemid)
  489. {
  490. return self::get_hash_item('shop_box', $itemid);
  491. }
  492. /**
  493. * 商城月卡
  494. * @return \shop_monthcard
  495. */
  496. public static function shop_monthcard()
  497. {
  498. static $a = null;
  499. return self::initValue($a, 'shop_monthcard');
  500. }
  501. /**
  502. * @return \sm_shop_monthcard shop_monthcard item数据
  503. */
  504. public static function shop_monthcard_getItem($itemid)
  505. {
  506. return self::get_hash_item('shop_monthcard', $itemid);
  507. }
  508. /**
  509. * 7日狂欢活跃点奖励
  510. * @return \activepointreward
  511. */
  512. public static function activepointreward()
  513. {
  514. static $a = null;
  515. return self::initValue($a, 'activepointreward');
  516. }
  517. /**
  518. * @return \sm_activepointreward activepointreward item数据
  519. */
  520. public static function activepointreward_getItem($type, $pointId)
  521. {
  522. return self::get_hash_item('activepointreward', "$type-$pointId");
  523. }
  524. /**
  525. * 活动任务
  526. * @return \activeTask
  527. */
  528. public static function activeTask()
  529. {
  530. static $a = null;
  531. return self::initValue($a, 'activeTask');
  532. }
  533. /**
  534. * @return \sm_activeTask activeTask item数据
  535. */
  536. public static function activeTask_getItem($itemid)
  537. {
  538. return self::get_hash_item('activeTask', $itemid);
  539. }
  540. /**
  541. * 活动任务根据类型的不同分开
  542. * @return \activeTask_type
  543. */
  544. public static function activeTask_type()
  545. {
  546. static $a = null;
  547. return self::initValue($a, 'activeTask_type');
  548. }
  549. /**
  550. * @return \sm_activeTask_type activeTask_type itemArray
  551. */
  552. public static function activeTask_type_getItemArray($key)
  553. {
  554. return self::get_hash_item('activeTask_type', $key);
  555. }
  556. /**
  557. * 活动
  558. * @return \activity
  559. */
  560. public static function activity()
  561. {
  562. static $a = null;
  563. return self::initValue($a, 'activity');
  564. }
  565. /**
  566. * @return \sm_activity activity item数据
  567. */
  568. public static function activity_getItem($itemid)
  569. {
  570. return self::get_hash_item('activity', $itemid);
  571. }
  572. /**
  573. * 当前版本(时间戳)
  574. * @return \ver
  575. */
  576. public static function ver()
  577. {
  578. static $a = null;
  579. return self::initValue($a, 'ver', false);
  580. }
  581. /**
  582. * 客户端配置数据
  583. * @return \client
  584. */
  585. public static function client()
  586. {
  587. static $a = null;
  588. return self::initValue($a, 'client', false);
  589. }
  590. }