var t = require; var e = module; var i = exports; Object.defineProperty(i, "__esModule", {value: !0}); const s = t("Toast"), o = t("CurrencyService"); i.default = class { constructor() { (this.cfg = null), (this.curLevel = null), (this.data = null), (this.value = 0), (this.nextLvValue = 0), (this.cost = 0), (this.installCost = 0); } getValue(t) { return this.value ? this.value / 100 : t; } init(e, t) { if (((this.cfg = e), (this.data = t), (this.installCost = e.unlock_cost), t.lv)) { this.value = this.cfg.value; const e = t.lv; (this.cost = t.lv = 0), this.unlock(); for (let t = 1; t < e; t++) this.$levelUp(); } } isMaxLevel() { return this.data.lv >= this.cfg.max_level; } $levelUp() { this.data.lv++, (this.value += this.cfg.value_add), (this.cost += this.cfg.upgrade_cost_add), (this.nextLvValue = this.value + this.cfg.value_add), (this.curLevel = this.data.lv); } canUnlock() { return o.default.ins.checkDiamondEnough(this.cfg.unlock_cost); } unlock() { (this.value = this.cfg.value), (this.data.lv = 1), (this.cost = this.cfg.upgrade_cost), (this.nextLvValue = this.value + this.cfg.value_add), (this.curLevel = this.data.lv); } canLvUp() { return o.default.ins.checkDiamondEnough(this.cost); } levelUp() { var t; this.isMaxLevel() ? s.default.launch("已经是最大等级!") : ((t = -this.cost), o.default.ins.checkDiamondEnough(t) ? (this.$levelUp(), o.default.ins.diamondChange(t)) : s.default.launch("金币不足!")); } isUnlock() { return 0 < this.data.lv; } getAvilityIconUrl() { return `Texture/ability/ability_icon_${this.cfg.idx}`; } getAvilityLockIconUrl() { return `Texture/ability/ability_icon_lock_${this.cfg.idx}`; } };