ConfigM.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.ITEM_BOX == id || GoodsId.POG_BOX == id) {
  101. return true;
  102. }
  103. if (GoodsId.FREE_ITEM_BOX == id || GoodsId.FREE_POG_BOX == id) {
  104. return true;
  105. }
  106. return false;
  107. }
  108. Grades(): ConfigGrade[] {
  109. let r = [];
  110. r.push({
  111. id: 1,
  112. name: "SUPREME",
  113. addition: 12.5,
  114. });
  115. r.push({
  116. id: 2,
  117. name: "AURORA",
  118. addition: 10,
  119. });
  120. r.push({
  121. id: 3,
  122. name: "DIAMOND",
  123. addition: 8.5,
  124. });
  125. r.push({
  126. id: 4,
  127. name: "TITAN",
  128. addition: 7.0,
  129. });
  130. r.push({
  131. id: 5,
  132. name: "GOLD",
  133. addition: 5.0,
  134. });
  135. r.push({
  136. id: 6,
  137. name: "SILVER",
  138. addition: 3.0,
  139. });
  140. r.push({
  141. id: 7,
  142. name: "BRONZE",
  143. addition: 2.0,
  144. });
  145. // r.push({
  146. // id: 8,
  147. // name: "ROOKIE",
  148. // addition: 0,
  149. // });
  150. r = r.sort((a, b) => b.id - a.id);
  151. return r;
  152. }
  153. getHelpDesc(type: number): string {
  154. switch (type) {
  155. case 2:
  156. return `Single-use boosters amplify your POG earnings.
  157. Get a 100-300% critical bonus on POG, multiplying it 1x-3x!`;
  158. case 3:
  159. return `Item Box`;
  160. case 4:
  161. return `Pog Box`;
  162. }
  163. }
  164. // getHelpTitle(type: number) {
  165. // switch (type) {
  166. // case 1:
  167. // return "Title : " + type;
  168. // case 2:
  169. // return `POG Crit Tickets`
  170. // case 3:
  171. // return `Item Box`
  172. // case 4:
  173. // return `Pog Box`
  174. // }
  175. // }
  176. getGamePassAddValue(gamePassCount: number): number {
  177. let gamePassAddValue = 0;
  178. if (gamePassCount >= 1) {
  179. gamePassAddValue += 10;
  180. }
  181. if (gamePassCount >= 2) {
  182. gamePassAddValue += 5;
  183. }
  184. if (gamePassCount >= 3) {
  185. gamePassAddValue += 5;
  186. }
  187. if (gamePassCount >= 4) {
  188. gamePassAddValue += 5;
  189. }
  190. if (gamePassCount >= 5) {
  191. gamePassAddValue += 5;
  192. }
  193. return gamePassAddValue;
  194. }
  195. getRechargeItem(id: number): ConfigRecharge {
  196. return this._config.rechargeList.find((item) => item.id === id);
  197. }
  198. private _version: string = "1.0.0";
  199. getVersionText(): string {
  200. let versionText = window["pog_init_data"]?.version;
  201. if (versionText) {
  202. return versionText;
  203. }
  204. return "Version:" + "local-" + new Date().toLocaleDateString();
  205. }
  206. private static _ins: ConfigM;
  207. public static get ins(): ConfigM {
  208. return (ConfigM._ins ??= new ConfigM());
  209. }
  210. private _config: Config;
  211. public async loadConfig(): Promise<boolean> {
  212. let config = await PogHttp.ins.allConfig();
  213. console.warn("config", config);
  214. if (!config) {
  215. return false;
  216. }
  217. this._config = config;
  218. return true;
  219. }
  220. public getShopListByStoreId(storeId: number): ConfigShopItem[] {
  221. return this._config.storeList.find((item) => item.id === storeId)?.shopList;
  222. }
  223. public getConfigShopIteByShopId(
  224. storeId: number,
  225. itemId: number
  226. ): ConfigShopItem {
  227. return this._config.storeList
  228. .find((item) => item.id === storeId)
  229. ?.shopList.find((item) => item.id === itemId);
  230. }
  231. public async openLink(url: string) {
  232. if (await TgM.ins.isTG()) {
  233. TgM.ins.openTelegramLink(url);
  234. } else {
  235. window.open(url, "_blank");
  236. }
  237. }
  238. }