ConfigM.ts 4.6 KB

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