ShopItemConfig.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0}),
  5. (i.getShopItemData = i.ShopGiftItemData = i.ShopBoxItemData = i.ShopItemData = void 0);
  6. const a = t("App"),
  7. s = t("GameText"),
  8. o = t("ConfigManager"),
  9. n = t("ControllerConst"),
  10. r = t("BagConst"),
  11. l = t("SystemOpenConst"),
  12. h = t("ShopConst");
  13. class c {
  14. constructor() {
  15. this.buyCnt = 0;
  16. }
  17. parse(t) {
  18. for (var e in t) this[e] = t[e];
  19. return (this.cfg = t), (this.shopType = t.shopType), this;
  20. }
  21. parseMutil(t) {
  22. let e = [];
  23. for (const s of t.split("|")) {
  24. const t = s.split(":");
  25. var i = {id: parseInt(t[0]), cnt: parseInt(t[1])};
  26. e.push(i);
  27. }
  28. return e;
  29. }
  30. parseMutil_1(t) {
  31. let e = [],
  32. i = t.split("|");
  33. for (var s of i) e.push(parseInt(s));
  34. return e;
  35. }
  36. getDiamondIconUrl() {
  37. return "Texture/itemIcon/diamond_" + this.cfg.icon;
  38. }
  39. getName() {
  40. return s.GameText.getTextByStr("shop_name_" + this.id);
  41. }
  42. }
  43. class d extends (i.ShopItemData = c) {}
  44. i.ShopBoxItemData = d;
  45. class u extends c {
  46. constructor() {
  47. super(...arguments),
  48. (this.items = null),
  49. (this.costumeItemIds = null),
  50. (this._costumes = null),
  51. (this.isSysOpen = !0);
  52. }
  53. get costumes() {
  54. var t = this.cfg.shopGift.costumes;
  55. return t && !this._costumes && this.parseCostume(t), this._costumes;
  56. }
  57. parse(t) {
  58. return (
  59. super.parse(t), (this.items = this.parseMutil(t.shopGift.items)), (this.giftType = t.shopGift.type), this
  60. );
  61. }
  62. parseCostume(t) {
  63. let e = [],
  64. i = [];
  65. const s = t.split("|");
  66. for (const o of s) {
  67. const t = parseInt(o);
  68. i.push(t);
  69. const s = a.default.ControllerManager.applyFunc(n.ControllerConst.Item, r.BagConst.GET_ITEM, t);
  70. e.push(s.getTempCostume());
  71. }
  72. e.length && ((this._costumes = e), (this.costumeItemIds = i));
  73. }
  74. isCanGetFirstGift() {
  75. return (
  76. this.buyCnt && this.buyCnt <= 3 && a.default.DateUtils.isLastDay(this.time, a.default.DateUtils.secondNow())
  77. );
  78. }
  79. isBuyGift() {
  80. return 0 < this.buyCnt;
  81. }
  82. isHideGift() {
  83. return this.shopType == h.ShopType.GIFT ? 3 < this.buyCnt : 0 < this.buyCnt;
  84. }
  85. isShowInShopView() {
  86. return (
  87. a.default.ControllerManager.applyFunc(
  88. n.ControllerConst.SystemOpen,
  89. l.OpenConst.CHCEK_OPEN,
  90. l.OpenTypeConst.FIRST_GIFT
  91. ) && !this.buyCnt
  92. );
  93. }
  94. }
  95. (i.ShopGiftItemData = u),
  96. (i.getShopItemData = function (t) {
  97. let e = null;
  98. switch (t.shopType) {
  99. case h.ShopType.REMOVE_AD_GIFT:
  100. case h.ShopType.GIFT:
  101. case h.ShopType.ONCE_GIFT:
  102. e = new u();
  103. break;
  104. case h.ShopType.BOX:
  105. e = new d();
  106. break;
  107. default:
  108. e = new c();
  109. }
  110. return e.parse(t);
  111. }),
  112. o.registerJSONConf("ShopItemConfig", "files/shopItem"),
  113. o.registerJSONConf("ProductConfig", "files/productConfig");