ConfigM.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. import Utils from "../../../../extensions/快闪-Tab标签王(prefab标签栏)/@types/packages/scene/@types/cce/public/gizmos/utils";
  2. import PogHttp from "../net/PogHttp";
  3. import { GoodsId } from "./GoodsId";
  4. import { GoodInfo } from "./UserM";
  5. export class ConfigGood {
  6. id: number;
  7. name: string;
  8. desc: string;
  9. type: number;
  10. param1: any;
  11. param2: any;
  12. param3: any;
  13. param4: any;
  14. }
  15. export class ConfigShopItem {
  16. id: number;
  17. goodId: number;
  18. num: number;
  19. storeId: number;
  20. usdPrice: number;
  21. diamondPrice: number;
  22. adPrice: number;
  23. total: number;
  24. dailyUserLimit: number;
  25. userLimit: number;
  26. userAdLimit: number;
  27. dailyUserAdLimit: number;
  28. sort: number;
  29. expireTime: number | null;
  30. }
  31. export class ConfigStore {
  32. id: number;
  33. name: string;
  34. shopList: ConfigShopItem[];
  35. }
  36. export class ConfigRecharge {
  37. id: number;
  38. usd: number;
  39. tgStars: number;
  40. goodList: GoodInfo[];
  41. bonusList: GoodInfo[];
  42. firstRechargeList: GoodInfo[];
  43. }
  44. export class ConfigBadge {
  45. addition: number;
  46. desc: string;
  47. id: number;
  48. type: number;
  49. }
  50. export class ConfigGame {
  51. gameDesc: string;
  52. gameIcon: string;
  53. gameId: number;
  54. gameLink: string;
  55. gameName: string;
  56. gameUsers: number;
  57. hot: boolean;
  58. isDeleted: boolean;
  59. queryUserUrl: string;
  60. seasonPog: number;
  61. }
  62. export class Config {
  63. goodList: ConfigGood[];
  64. storeList: ConfigStore[];
  65. rechargeList: ConfigRecharge[];
  66. badgeList: ConfigBadge[];
  67. gameList: ConfigGame[];
  68. }
  69. export class ClientConfig {
  70. static readonly PuzzleToGamePassCount: number = 10;
  71. }
  72. export class ConfigGrade {
  73. id: number;
  74. name: string;
  75. addition: number;
  76. }
  77. export default class ConfigM {
  78. getGame(gameId: number): ConfigGame {
  79. return this._config.gameList.find((item) => item.gameId == gameId);
  80. }
  81. getBadge(id: number): ConfigBadge {
  82. return this._config.badgeList.find((item) => item.id == id);
  83. }
  84. getGradeAllocation(_grade: number) {
  85. let r = [5, 10, 10, 24, 26, 20, 5];
  86. return r[_grade - 1];
  87. }
  88. getGrade(grade: number): ConfigGrade {
  89. return this.Grades().find((item) => item.id == grade);
  90. }
  91. getGoodName(id: number): string {
  92. let good = this._config.goodList.find((item) => item.id == id);
  93. if (good) {
  94. return good.name;
  95. }
  96. return "Unknown";
  97. }
  98. GoodIsBox(id: number): boolean {
  99. if (GoodsId.ITEM_BOX == id || GoodsId.POG_BOX == id) {
  100. return true;
  101. }
  102. if (GoodsId.FREE_ITEM_BOX == id || GoodsId.FREE_POG_BOX == id) {
  103. return true;
  104. }
  105. return false;
  106. }
  107. Grades(): ConfigGrade[] {
  108. let r = [];
  109. r.push({
  110. id: 1,
  111. name: "SUPREME",
  112. addition: 12.5,
  113. });
  114. r.push({
  115. id: 2,
  116. name: "AURORA",
  117. addition: 10,
  118. });
  119. r.push({
  120. id: 3,
  121. name: "DIAMOND",
  122. addition: 8.5,
  123. });
  124. r.push({
  125. id: 4,
  126. name: "TITAN",
  127. addition: 7.0,
  128. });
  129. r.push({
  130. id: 5,
  131. name: "GOLD",
  132. addition: 5.0,
  133. });
  134. r.push({
  135. id: 6,
  136. name: "SILVER",
  137. addition: 3.0,
  138. });
  139. r.push({
  140. id: 7,
  141. name: "BRONZE",
  142. addition: 2.0,
  143. });
  144. r = r.sort((a, b) => b.id - a.id);
  145. return r;
  146. }
  147. getHelpDesc(type: number): string {
  148. switch (type) {
  149. case 2:
  150. return `Single-use boosters amplify your POG earnings.
  151. Get a 100-300% critical bonus on POG, multiplying it 1x-3x!`;
  152. case 3:
  153. return `Item Box`;
  154. case 4:
  155. return `Pog Box`;
  156. }
  157. }
  158. // getHelpTitle(type: number) {
  159. // switch (type) {
  160. // case 1:
  161. // return "Title : " + type;
  162. // case 2:
  163. // return `POG Crit Tickets`
  164. // case 3:
  165. // return `Item Box`
  166. // case 4:
  167. // return `Pog Box`
  168. // }
  169. // }
  170. getGamePassAddValue(gamePassCount: number): number {
  171. let gamePassAddValue = 0;
  172. if (gamePassCount >= 1) {
  173. gamePassAddValue += 10;
  174. }
  175. if (gamePassCount >= 2) {
  176. gamePassAddValue += 5;
  177. }
  178. if (gamePassCount >= 3) {
  179. gamePassAddValue += 5;
  180. }
  181. if (gamePassCount >= 4) {
  182. gamePassAddValue += 5;
  183. }
  184. if (gamePassCount >= 5) {
  185. gamePassAddValue += 5;
  186. }
  187. return gamePassAddValue;
  188. }
  189. getRechargeItem(id: number): ConfigRecharge {
  190. return this._config.rechargeList.find((item) => item.id === id);
  191. }
  192. private _version: string = "1.0.0";
  193. getVersionText(): string {
  194. let versionText = window["pog_init_data"]?.version;
  195. if (versionText) {
  196. return versionText;
  197. }
  198. return "Version:" + "local-" + new Date().toLocaleDateString();
  199. }
  200. private static _ins: ConfigM;
  201. public static get ins(): ConfigM {
  202. return (ConfigM._ins ??= new ConfigM());
  203. }
  204. private _config: Config;
  205. public async loadConfig(): Promise<boolean> {
  206. let config = await PogHttp.ins.allConfig();
  207. console.warn("config", config);
  208. if (!config) {
  209. return false;
  210. }
  211. this._config = config;
  212. return true;
  213. }
  214. public getShopListByStoreId(storeId: number): ConfigShopItem[] {
  215. return this._config.storeList.find((item) => item.id === storeId)?.shopList;
  216. }
  217. public getConfigShopIteByShopId(
  218. storeId: number,
  219. itemId: number
  220. ): ConfigShopItem {
  221. return this._config.storeList
  222. .find((item) => item.id === storeId)
  223. ?.shopList.find((item) => item.id === itemId);
  224. }
  225. }