ConfigM.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. webLink: string;
  63. tgLink: string;
  64. lineLink: string;
  65. }
  66. export class Config {
  67. goodList: ConfigGood[];
  68. storeList: ConfigStore[];
  69. rechargeList: ConfigRecharge[];
  70. badgeList: ConfigBadge[];
  71. gameList: ConfigGame[];
  72. }
  73. export class ClientConfig {
  74. static readonly PuzzleToGamePassCount: number = 10;
  75. }
  76. export class ConfigGrade {
  77. id: number;
  78. name: string;
  79. addition: number;
  80. }
  81. export default class ConfigM {
  82. isOpenPlay(gameId: number) {
  83. if (gameId == 2) {
  84. return true;
  85. }
  86. if (gameId == 1) {
  87. return true;
  88. }
  89. return false;
  90. }
  91. getGame(gameId: number): ConfigGame {
  92. return this._config.gameList.find((item) => item.gameId == gameId);
  93. }
  94. getBadge(id: number): ConfigBadge {
  95. return this._config.badgeList.find((item) => item.id == id);
  96. }
  97. getGradeAllocation(_grade: number) {
  98. let r = [5, 10, 10, 24, 26, 20, 5,0];
  99. return r[_grade - 1];
  100. }
  101. getGrade(grade: number): ConfigGrade {
  102. return this.Grades().find((item) => item.id == grade);
  103. }
  104. getGoodName(id: number): string {
  105. let good = this._config.goodList.find((item) => item.id == id);
  106. if (good) {
  107. return good.name;
  108. }
  109. return "Unknown";
  110. }
  111. GoodIsBox(id: number): boolean {
  112. if (GoodsId.FAMILY_BOX == id) {
  113. return true;
  114. }
  115. if (GoodsId.ITEM_BOX == id || GoodsId.POG_BOX == id) {
  116. return true;
  117. }
  118. if (GoodsId.FREE_ITEM_BOX == id || GoodsId.FREE_POG_BOX == id) {
  119. return true;
  120. }
  121. return false;
  122. }
  123. Grades(): ConfigGrade[] {
  124. let r = [];
  125. r.push({
  126. id: 1,
  127. name: "SUPREME",
  128. addition: 12.5,
  129. });
  130. r.push({
  131. id: 2,
  132. name: "AURORA",
  133. addition: 10,
  134. });
  135. r.push({
  136. id: 3,
  137. name: "DIAMOND",
  138. addition: 8.5,
  139. });
  140. r.push({
  141. id: 4,
  142. name: "TITAN",
  143. addition: 7.0,
  144. });
  145. r.push({
  146. id: 5,
  147. name: "GOLD",
  148. addition: 5.0,
  149. });
  150. r.push({
  151. id: 6,
  152. name: "SILVER",
  153. addition: 3.0,
  154. });
  155. r.push({
  156. id: 7,
  157. name: "BRONZE",
  158. addition: 2.0,
  159. });
  160. // r.push({
  161. // id: 8,
  162. // name: "ROOKIE",
  163. // addition: 0,
  164. // });
  165. r = r.sort((a, b) => b.id - a.id);
  166. return r;
  167. }
  168. getHelpDesc(type: number): string {
  169. switch (type) {
  170. case 2:
  171. return `Single-use boosters amplify your POG earnings.
  172. Get a 100-300% critical bonus on POG, multiplying it 1x-3x!`;
  173. case 3:
  174. return `Item Box`;
  175. case 4:
  176. return `Pog Box`;
  177. }
  178. }
  179. // getHelpTitle(type: number) {
  180. // switch (type) {
  181. // case 1:
  182. // return "Title : " + type;
  183. // case 2:
  184. // return `POG Crit Tickets`
  185. // case 3:
  186. // return `Item Box`
  187. // case 4:
  188. // return `Pog Box`
  189. // }
  190. // }
  191. getGamePassAddValue(gamePassCount: number): number {
  192. let gamePassAddValue = 0;
  193. if (gamePassCount >= 1) {
  194. gamePassAddValue += 10;
  195. }
  196. if (gamePassCount >= 2) {
  197. gamePassAddValue += 5;
  198. }
  199. if (gamePassCount >= 3) {
  200. gamePassAddValue += 5;
  201. }
  202. if (gamePassCount >= 4) {
  203. gamePassAddValue += 5;
  204. }
  205. if (gamePassCount >= 5) {
  206. gamePassAddValue += 5;
  207. }
  208. return gamePassAddValue;
  209. }
  210. getRechargeItem(id: number): ConfigRecharge {
  211. return this._config.rechargeList.find((item) => item.id === id);
  212. }
  213. private _version: string = "1.0.0";
  214. getVersionText(): string {
  215. let versionText = window["pog_init_data"]?.version;
  216. if (versionText) {
  217. return versionText;
  218. }
  219. return "Version:" + "local-" + new Date().toLocaleDateString();
  220. }
  221. private static _ins: ConfigM;
  222. public static get ins(): ConfigM {
  223. return (ConfigM._ins ??= new ConfigM());
  224. }
  225. private _config: Config;
  226. public async loadConfig(): Promise<boolean> {
  227. let config = await PogHttp.ins.allConfig();
  228. console.warn("config", config);
  229. if (!config) {
  230. return false;
  231. }
  232. this._config = config;
  233. return true;
  234. }
  235. public getShopListByStoreId(storeId: number): ConfigShopItem[] {
  236. return this._config.storeList.find((item) => item.id === storeId)?.shopList;
  237. }
  238. public getConfigShopIteByShopId(
  239. storeId: number,
  240. itemId: number
  241. ): ConfigShopItem {
  242. return this._config.storeList
  243. .find((item) => item.id === storeId)
  244. ?.shopList.find((item) => item.id === itemId);
  245. }
  246. public async openLink(url: string) {
  247. if (!url) {
  248. return;
  249. }
  250. if (await TgM.ins.isTG()) {
  251. TgM.ins.openTelegramLink(url);
  252. } else {
  253. window.open(url, "_blank");
  254. }
  255. }
  256. }