ConfigM.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 Config {
  45. goodList: ConfigGood[];
  46. storeList: ConfigStore[];
  47. rechargeList: ConfigRecharge[];
  48. }
  49. export class ClientConfig {
  50. static readonly PuzzleToGamePassCount: number = 10;
  51. }
  52. export class ConfigGrade {
  53. id: number;
  54. name: string;
  55. addition: number;
  56. }
  57. export default class ConfigM {
  58. getGrade(grade: number): ConfigGrade {
  59. return this.Grades().find((item) => item.id == grade);
  60. }
  61. getGoodName(id: number): string {
  62. let good = this._config.goodList.find((item) => item.id == id);
  63. if (good) {
  64. return good.name;
  65. }
  66. return "Unknown";
  67. }
  68. GoodIsBox(id: number): boolean {
  69. if (GoodsId.ITEM_BOX == id || GoodsId.POG_BOX == id) {
  70. return true;
  71. }
  72. if (GoodsId.FREE_ITEM_BOX == id || GoodsId.FREE_POG_BOX == id) {
  73. return true;
  74. }
  75. return false;
  76. }
  77. Grades(): ConfigGrade[] {
  78. let r = [];
  79. r.push({
  80. id: 1,
  81. name: "SUPREME",
  82. addition: 12.5,
  83. });
  84. r.push({
  85. id: 2,
  86. name: "AURORA",
  87. addition: 10,
  88. });
  89. r.push({
  90. id: 3,
  91. name: "DIAMOND",
  92. addition: 8.5,
  93. });
  94. r.push({
  95. id: 4,
  96. name: "TITAN",
  97. addition: 7.0,
  98. });
  99. r.push({
  100. id: 5,
  101. name: "GOLD",
  102. addition: 5.0,
  103. });
  104. r.push({
  105. id: 6,
  106. name: "SILVER",
  107. addition: 3.0,
  108. });
  109. r.push({
  110. id: 7,
  111. name: "BRONZE",
  112. addition: 2.0,
  113. });
  114. r = r.sort((a, b) => b.id - a.id);
  115. return r;
  116. }
  117. getHelpDesc(type: number): string {
  118. switch (type) {
  119. case 2:
  120. return `Single-use boosters amplify your POG earnings.
  121. Get a 100-300% critical bonus on POG, multiplying it 1x-3x!`;
  122. case 3:
  123. return `Item Box`;
  124. case 4:
  125. return `Pog Box`;
  126. }
  127. }
  128. // getHelpTitle(type: number) {
  129. // switch (type) {
  130. // case 1:
  131. // return "Title : " + type;
  132. // case 2:
  133. // return `POG Crit Tickets`
  134. // case 3:
  135. // return `Item Box`
  136. // case 4:
  137. // return `Pog Box`
  138. // }
  139. // }
  140. getGamePassAddValue(gamePassCount: number): number {
  141. let gamePassAddValue = 0;
  142. if (gamePassCount >= 1) {
  143. gamePassAddValue += 10;
  144. }
  145. if (gamePassCount >= 2) {
  146. gamePassAddValue += 5;
  147. }
  148. if (gamePassCount >= 3) {
  149. gamePassAddValue += 5;
  150. }
  151. if (gamePassCount >= 4) {
  152. gamePassAddValue += 5;
  153. }
  154. if (gamePassCount >= 5) {
  155. gamePassAddValue += 5;
  156. }
  157. return gamePassAddValue;
  158. }
  159. getRechargeItem(id: number): ConfigRecharge {
  160. return this._config.rechargeList.find((item) => item.id === id);
  161. }
  162. private _version: string = "1.0.0";
  163. getVersionText(): string {
  164. let versionText = window["pog_init_data"]?.version;
  165. if (versionText) {
  166. return versionText;
  167. }
  168. return "Version:" + "local-" + new Date().toLocaleDateString();
  169. }
  170. private static _ins: ConfigM;
  171. public static get ins(): ConfigM {
  172. return (ConfigM._ins ??= new ConfigM());
  173. }
  174. private _config: Config;
  175. public async loadConfig(): Promise<boolean> {
  176. let config = await PogHttp.ins.allConfig();
  177. console.warn("config", config);
  178. if (!config) {
  179. return false;
  180. }
  181. this._config = config;
  182. return true;
  183. }
  184. public getShopListByStoreId(storeId: number): ConfigShopItem[] {
  185. return this._config.storeList.find((item) => item.id === storeId)?.shopList;
  186. }
  187. public getConfigShopIteByShopId(
  188. storeId: number,
  189. itemId: number
  190. ): ConfigShopItem {
  191. return this._config.storeList
  192. .find((item) => item.id === storeId)
  193. ?.shopList.find((item) => item.id === itemId);
  194. }
  195. }