ConfigM.ts 5.5 KB

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