var t = require; var e = module; var i = exports; Object.defineProperty(i, "__esModule", {value: !0}); const s = t("GlobalAttr"), n = t("MyBigLong"), o = t("StageUpgradeService"); i.default = class { constructor() { (this.cfg = null), (this.baseValue = 0), (this.value = 0), (this.upgradeCost = 0), (this.baseUpgradeCost = 0), (this.installCost = 0), (this.foodRate = 1), (this.isUnlock = !1), (this.slotCnt = 0), (this.manufactureTime = 0), (this.maxLevel = 0), (this.maxSlot = 0), (this.data = null), (this._slotAddLv = null), (this._doubleupLv = null); } get level() { return this.data.lv; } init(e, i, t, s, o, a) { if ( ((this.data = e), (this.maxLevel = t), (this.maxSlot = s), (this.cfg = i), (this.baseValue = this.value = n.default.unpackData(i.value)), (this.baseUpgradeCost = n.default.unpackData(i.upgrade_cost)), (this.installCost = n.default.unpackData(i.install_cost)), (this._slotAddLv = o), (this._doubleupLv = a), this.calFoodRate(), this.calFoodFinalTime(), this.calCost(), e.lv) ) { (this.isUnlock = !0), (this.slotCnt = 1); const i = e.lv; for (let t = (e.lv = 1); t < i; t++) this.levelUp(); } } getIdleRate() { return (this.value * this.slotCnt) / (this.manufactureTime + 10); } calFoodRate() { this.foodRate = o.default.ins.menuprofitValue[this.cfg.machine_num] || 1; var t = o.default.ins.menuprofitValue[-1]; t && (this.foodRate *= t); } calFoodValue() { this.value = Math.ceil(this.baseValue * this.foodRate); } calCost() { this.upgradeCost = Math.ceil(this.baseUpgradeCost * s.default.ins.menuItemUpgradeDiscount); } calFoodFinalTime() { this.manufactureTime = Math.ceil( this.cfg.manufacture_time * (o.default.ins.fastermenu[this.cfg.machine_num] || 1) ); } isDoubleLevel(t) { return this._doubleupLv.includes(t); } isAddSlot(t) { return this._slotAddLv.includes(t); } getDoubleProgressRate() { var e = this._doubleupLv; let i = e.length; var s = this.data.lv; for (let t = 0; t < i; t++) { const i = e[t]; if (i > s) return 0 === t ? s / i : (s - e[t - 1]) / (i - e[t - 1]); } } isMaxLevel() { return this.data.lv >= this.maxLevel; } unlockSelf() { (this.isUnlock = !0), (this.slotCnt = 1), (this.data.lv = 1); } levelUp() { this.data.lv++; var t = this.isDoubleLevel(this.data.lv); t && (this.baseValue *= 2); var e = Math.max(Math.floor(((this.cfg.value_increment - 1e3) * this.baseValue) / 1e3), 1); this.baseValue += e; e = Math.max(Math.floor(((this.cfg.cost_increment - 1e3) * this.baseUpgradeCost) / 1e3), 1); return ( (this.baseUpgradeCost += e), this.slotCnt < this.maxSlot && this.isAddSlot(this.data.lv) && this.slotCnt++, this.calFoodValue(), this.calCost(), t ); } getCurStarNum() { let t = 0; for (const e of this._doubleupLv) this.level >= e && t++; return t; } getMaxStarNum() { let t = 0; for (const e of this._doubleupLv) this.maxLevel >= e && t++; return t; } };