ConfigM.ts 4.8 KB

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