123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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;
- }
- };
|