SystemOpenController.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const a = t("App"),
  6. s = t("BaseController"),
  7. n = t("ControllerConst"),
  8. o = t("NotificationConst"),
  9. r = t("MachineService"),
  10. l = t("MapService"),
  11. h = t("StageUpgradeService"),
  12. c = t("GuideModel"),
  13. d = t("SystemOpenConfig"),
  14. u = t("SystemOpenConst");
  15. let p = null;
  16. i.default = class extends s.default {
  17. constructor() {
  18. super(),
  19. (this._waitOpenList = []),
  20. (p = this),
  21. a.default.NotificationCenter.addListener(o.NotificationConst.INIT_GAME, this.init, this);
  22. }
  23. static get ins() {
  24. return p;
  25. }
  26. init() {
  27. if (
  28. (a.default.NotificationCenter.removeListener(o.NotificationConst.INIT_GAME, this.init, this),
  29. !this._configMap)
  30. ) {
  31. for (var t in (this.initConfig(), this._configMap)) {
  32. var e = this._configMap[t],
  33. t = this.checkSystemOpen(e.index, !0);
  34. t
  35. ? a.default.NotificationCenter.dispatch(o.NotificationConst.SYS_OPEN, e.index, t)
  36. : this._waitOpenList.push(e);
  37. }
  38. this.initSelfEvent(),
  39. a.default.NotificationCenter.addListener(o.NotificationConst.CHECK_SYS_OPEN, this.checkSys, this),
  40. a.default.NotificationCenter.addListener(o.NotificationConst.GUIDE_STEP_FINISH, this.checkAllSys, this),
  41. a.default.NotificationCenter.addListener(
  42. o.NotificationConst.STAGE_UPGRADE_UPDATE,
  43. this.checkAllSys,
  44. this
  45. ),
  46. a.default.NotificationCenter.addListener(o.NotificationConst.ENTER_MAP, this.checkAllSys, this),
  47. a.default.NotificationCenter.addListener(o.NotificationConst.MACHINE_UPDATE, this.checkAllSys, this);
  48. }
  49. }
  50. initSelfEvent() {
  51. this.registerFunc(u.OpenConst.CHCEK_OPEN, this.checkSystemOpen, this);
  52. }
  53. initConfig() {
  54. var t,
  55. e = a.default.ConfigManager.getConfig("SystemDataManager");
  56. for (t in ((this._configMap = {}), e)) {
  57. var i = e[t],
  58. i = new d.default().parse(i);
  59. this._configMap[i.id] = i;
  60. }
  61. }
  62. getConfigByIndex(t) {
  63. if (this._configMap) {
  64. t = u.OpenTypeConst[t];
  65. return this._configMap[t];
  66. }
  67. }
  68. getConfigByType(t) {
  69. if (this._configMap) return this._configMap[t];
  70. }
  71. checkSystemGuide() {}
  72. checkSystemOpen(t, e) {
  73. t = this.getConfigByIndex(t);
  74. if (!t) return !1;
  75. for (const o of t.openConList)
  76. switch (o.type) {
  77. case "i":
  78. if (!a.default.Platform.getIsShowPay()) return !1;
  79. break;
  80. case "m":
  81. if (!l.default.ins.curCfg) return !1;
  82. var i = l.default.ins.curId;
  83. if (o.value > i) return !1;
  84. if (o.value < i) return !0;
  85. break;
  86. case "l":
  87. if (o.value > r.default.ins.getCurMachineMaxLv()) return !1;
  88. break;
  89. case "u":
  90. if (!h.default.ins.isUnlock(o.value)) return !1;
  91. break;
  92. case "d":
  93. var s = a.default.GameDataMsr.playerInfo.registerTime / 1e3 / 3600 / 24,
  94. i = a.default.DateUtils.Now() / 1e3 / 3600 / 24;
  95. if (o.value > i - s) return !1;
  96. break;
  97. case "g":
  98. let t = a.default.ControllerManager.applyFunc(
  99. n.ControllerConst.Guide,
  100. c.GuideConst.CHECK_IS_GUIDE,
  101. o.value
  102. );
  103. if (
  104. !t &&
  105. (902 == o.value &&
  106. (t = a.default.ControllerManager.applyFunc(
  107. n.ControllerConst.Guide,
  108. c.GuideConst.CHECK_IS_GUIDE,
  109. 400
  110. )),
  111. (t =
  112. t ||
  113. a.default.ControllerManager.applyFunc(
  114. n.ControllerConst.Guide,
  115. c.GuideConst.CHECK_IS_GUIDE,
  116. 1
  117. )),
  118. !t)
  119. )
  120. return !1;
  121. }
  122. return !0;
  123. }
  124. checkAllSys(e = !1) {
  125. for (let t = this._waitOpenList.length - 1; 0 <= t; t--) {
  126. var i = this._waitOpenList[t],
  127. s = this.checkSystemOpen(i.index, e);
  128. s &&
  129. (this._waitOpenList.splice(t, 1),
  130. i.isPlayAni && e
  131. ? a.default.NotificationCenter.dispatch(o.NotificationConst.SYS_OPEN, i.index, s, !0)
  132. : a.default.NotificationCenter.dispatch(o.NotificationConst.SYS_OPEN, i.index, s));
  133. }
  134. }
  135. checkSys(t, e = !1) {
  136. e = this.checkSystemOpen(t, e);
  137. null != e && a.default.NotificationCenter.dispatch(o.NotificationConst.SYS_OPEN, t, e);
  138. }
  139. };