The Great Autobuyer Unfuckening II

This commit is contained in:
Andrei Andreev 2019-07-20 16:28:59 +03:00
parent a3081a5247
commit 866b84dac1
31 changed files with 440 additions and 693 deletions

View File

@ -183,17 +183,6 @@
<script type="text/javascript" src="javascripts/core/constants.js"></script>
<script type="text/javascript" src="javascripts/core/math.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/dimension-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/tickspeed-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/dimboost-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/galaxy-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/big-crunch-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/sacrifice-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/eternity-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/reality-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/autobuyers.js"></script>
<script type="text/javascript" src="javascripts/core/automator/automator-backend.js"></script>
<script type="text/javascript" src="javascripts/core/secret-formula/effects.js"></script>
<script type="text/javascript" src="javascripts/core/secret-formula/game-database.js"></script>
@ -209,6 +198,17 @@
<script type="text/javascript" src="javascripts/core/hotkeys.js"></script>
<script type="text/javascript" src="javascripts/core/galaxy.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/dimension-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/tickspeed-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/dimboost-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/galaxy-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/big-crunch-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/sacrifice-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/eternity-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/reality-autobuyer.js"></script>
<script type="text/javascript" src="javascripts/core/autobuyers/autobuyers.js"></script>
<script type="text/javascript" src="javascripts/core/storage/serializer.js"></script>
<script type="text/javascript" src="javascripts/core/storage/storage.js"></script>
<script type="text/javascript" src="javascripts/core/storage/migrations.js"></script>

View File

@ -25,7 +25,7 @@ Vue.component("break-infinity-button", {
methods: {
update() {
this.isBroken = player.break;
this.isUnlocked = Autobuyer.bigCrunch.isUnlocked && Autobuyer.bigCrunch.hasMaxedInterval;
this.isUnlocked = Autobuyer.bigCrunch.hasMaxedInterval;
}
},
template:

View File

@ -34,7 +34,7 @@ Vue.component("break-infinity-tab", {
},
methods: {
update() {
this.isUnlocked = Autobuyer.bigCrunch.isUnlocked && Autobuyer.bigCrunch.hasMaxedInterval;
this.isUnlocked = Autobuyer.bigCrunch.hasMaxedInterval;
},
btnClassObject(column) {
return {

View File

@ -61,7 +61,7 @@ class AchievementState extends GameMechanicState {
if (this.isUnlocked) return;
player.achievements.add(this.id);
if (this.id === 85 || this.id === 93) {
Autobuyer.bigCrunch.bumpLimit(4);
Autobuyer.bigCrunch.bumpAmount(4);
}
GameUI.notify.success(this.name);
kong.submitAchievements();

View File

@ -1,208 +1,105 @@
"use strict";
const Autobuyer = function Autobuyer(interval) {
this.target = 1;
this.cost = 1;
this.interval = interval;
this.priority = 1;
this.ticks = 0;
this.isOn = false;
this.bulk = 1;
};
Autobuyer.tickTimer = 0;
Autobuyer.intervalTimer = 0;
Autobuyer.lastDimBoost = 0;
Autobuyer.lastGalaxy = 0;
/**
* @abstract
*/
class AutobuyerState {
constructor(getAutobuyer) {
this._getAutobuyer = getAutobuyer;
}
/**
* @abstract
*/
get data() { throw NotImplementedCrash(); }
/**
* @returns {Autobuyer|undefined}
* @abstract
*/
get autobuyer() {
// What
const autobuyer = this._getAutobuyer();
return autobuyer % 1 !== 0 ? autobuyer : undefined;
get isUnlocked() { throw NotImplementedCrash(); }
get canTick() {
return this.isUnlocked && this.isActive;
}
/**
* @returns {boolean}
*/
get isUnlocked() {
return this.autobuyer !== undefined;
}
tryUnlock() {
if (!this.isUnlocked && this.challenge.isCompleted) {
this.initialize();
}
}
/**
* @returns {NormalChallengeState|InfinityChallengeState}
*/
get challenge() {
throw "This method should be overridden in inheriting class";
}
initialize() {
throw "This method should be overridden in inheriting class";
}
/**
* @returns {boolean}
*/
get isOn() {
return this.autobuyer.isOn;
}
/**
* @param {boolean} value
*/
set isOn(value) {
this.autobuyer.isOn = value;
}
/**
* @returns {number}
*/
get cost() {
return this.autobuyer.cost;
}
/**
* @param {number} value
*/
set cost(value) {
this.autobuyer.cost = value;
}
/**
* @returns {number}
*/
get ticks() {
return this.autobuyer.ticks;
}
/**
* @param {number} value
*/
set ticks(value) {
this.autobuyer.ticks = value;
}
/**
* @returns {boolean}
*/
canTick() {
if (!this.isUnlocked) return false;
if (this.ticks * 100 < this.interval) {
this.ticks++;
return false;
}
return this.isOn;
}
resetTicks() {
this.ticks = 1;
}
/**
* @returns {number}
*/
get priority() {
return this.autobuyer.priority;
}
/**
* @param {number} value
*/
set priority(value) {
this.autobuyer.priority = value;
}
/**
* @returns {number}
*/
get interval() {
return this.autobuyer.interval;
}
/**
* @param {number} value
*/
set interval(value) {
this.autobuyer.interval = value;
}
/**
* @returns {boolean}
*/
get hasMaxedInterval() {
return this.isUnlocked && this.interval <= 100;
}
/**
* @returns {number}
*/
get bulk() {
return this.autobuyer.bulk;
}
/**
* @param {number} value
*/
set bulk(value) {
this.autobuyer.bulk = value;
}
/**
* @returns {boolean}
*/
get isActive() {
return this.isUnlocked && this.autobuyer.isOn;
return this.data.isActive;
}
set isActive(value) {
this.data.isActive = value;
}
toggle() {
this.isOn = !this.isOn;
}
upgradeInterval() {
if (this.hasMaxedInterval) return;
if (player.infinityPoints.lt(this.cost)) return;
player.infinityPoints = player.infinityPoints.minus(this.cost);
this.interval = Math.max(this.interval * 0.6, 100);
if (this.interval > 120) {
// if your last purchase wont be very strong, dont double the cost
this.cost *= 2;
}
Autobuyer.checkIntervalAchievements();
GameUI.update();
this.isActive = !this.isActive;
}
get hasInterval() {
return true;
return false;
}
/**
* @abstract
*/
tick() { throw NotImplementedCrash(); }
// eslint-disable-next-line no-empty-function
reset() { }
}
/**
* @abstract
*/
class IntervaledAutobuyerState extends AutobuyerState {
/**
* @abstract
*/
get baseInterval() { throw NotImplementedCrash(); }
get cost() {
return this.data.cost;
}
get interval() {
const interval = this.data.interval;
return BreakInfinityUpgrade.autobuyerSpeed.isBought ? interval / 2 : interval;
}
get hasInterval() {
return true;
}
get hasMaxedInterval() {
return this.data.interval <= 100;
}
get canTick() {
return super.canTick && this.timeSinceLastTick >= this.interval;
}
get timeSinceLastTick() {
return player.realTimePlayed - this.data.lastTick;
}
tick() {
this.data.lastTick = player.realTimePlayed;
}
upgradeInterval() {
if (this.hasMaxedInterval) return;
if (Currency.infinityPoints.isAffordable(this.cost)) return;
Currency.infinityPoints.subtract(this.cost);
this.data.interval = Math.clampMin(this.data.interval * 0.6, 100);
if (this.data.interval > 120) {
// If your last purchase wont be very strong, dont double the cost
this.data.cost *= 2;
}
Achievement(52).tryUnlock();
Achievement(53).tryUnlock();
GameUI.update();
}
reset() {
if (EternityMilestone.keepAutobuyers.isReached) return;
this.data.interval = this.baseInterval;
this.data.cost = 1;
}
}
const Autobuyer = {};

View File

@ -16,7 +16,14 @@ const Autobuyers = (function() {
return {
all,
dimensions,
withPriority: [Autobuyer.tickspeed].concat(dimensions),
intervaled: dimensions
.concat([
Autobuyer.tickspeed,
Autobuyer.dimboost,
Autobuyer.galaxy,
Autobuyer.sacrifice,
Autobuyer.bigCrunch
]),
get unlocked() {
return Autobuyers.all.filter(a => a.isUnlocked);
@ -34,65 +41,35 @@ const Autobuyers = (function() {
tick() {
PerformanceStats.start("Autobuyers");
Autobuyer.reality.tick();
Autobuyer.eternity.tick();
Autobuyer.bigCrunch.tick();
Autobuyer.galaxy.tick();
Autobuyer.dimboost.tick();
Autobuyer.sacrifice.tick();
const priorityQueue = Autobuyers.withPriority
.filter(a => a.isUnlocked)
const priorityQueue = [Autobuyer.tickspeed]
.concat(dimensions)
.sort((a, b) => a.priority - b.priority);
for (const autobuyer of priorityQueue) {
const autobuyers = [
Autobuyer.reality,
Autobuyer.eternity,
Autobuyer.bigCrunch,
Autobuyer.galaxy,
Autobuyer.dimboost,
Autobuyer.sacrifice
]
.concat(priorityQueue)
.filter(a => a.canTick);
for (const autobuyer of autobuyers) {
autobuyer.tick();
}
PerformanceStats.end();
},
reset() {
for (const autobuyer of Autobuyers.all) {
autobuyer.reset();
}
}
};
}());
/**
* @type {AutobuyerState[]}
*/
Autobuyer.unlockables = Autobuyers.dimensions
.concat([
Autobuyer.tickspeed,
Autobuyer.dimboost,
Autobuyer.galaxy,
Autobuyer.sacrifice,
Autobuyer.bigCrunch
]);
Autobuyer.tryUnlockAny = function() {
for (const autobuyer of this.unlockables) {
autobuyer.tryUnlock();
}
};
Autobuyer.resetUnlockables = function() {
player.autobuyers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
Autobuyer.tryUnlockAny();
};
Autobuyer.checkIntervalAchievements = function() {
Achievement(52).tryUnlock();
Achievement(53).tryUnlock();
};
Autobuyer.checkBulkAchievements = function() {
Achievement(61).tryUnlock();
SecretAchievement(38).tryUnlock();
};
Autobuyer.convertPropertiesToDecimal = function() {
if (
player.autobuyers[11] % 1 !== 0 &&
player.autobuyers[11].priority !== undefined &&
player.autobuyers[11].priority !== null &&
player.autobuyers[11].priority !== "undefined"
) {
player.autobuyers[11].priority = new Decimal(player.autobuyers[11].priority);
}
};
EventHub.logic.on(GameEvent.ETERNITY_RESET_AFTER, () => Autobuyers.reset());
EventHub.logic.on(GameEvent.REALITY_RESET_AFTER, () => Autobuyers.reset());

View File

@ -1,84 +1,94 @@
"use strict";
Autobuyer.bigCrunch = new class BigCrunchAutobuyerState extends AutobuyerState {
constructor() {
super(() => player.autobuyers[11]);
Autobuyer.bigCrunch = new class BigCrunchAutobuyerState extends IntervaledAutobuyerState {
get data() {
return player.auto.bigCrunch;
}
initialize() {
player.autobuyers[11] = new Autobuyer(300000);
this.limit = new Decimal(1);
get isUnlocked() {
return NormalChallenge(12).isCompleted;
}
get challenge() {
return NormalChallenge(12);
get baseInterval() {
return Player.defaultStart.auto.bigCrunch.interval;
}
/**
* @returns {AutoCrunchMode}
*/
get mode() {
return player.autoCrunchMode;
return this.data.mode;
}
/**
* @param {AutoCrunchMode} value
*/
set mode(value) {
player.autoCrunchMode = value;
this.data.mode = value;
}
/**
* @returns {boolean}
*/
get hasAdditionalModes() {
return EternityMilestone.bigCrunchModes.isReached;
}
/**
* @returns {Decimal}
*/
get limit() {
return this.autobuyer.priority;
get amount() {
return this.data.amount;
}
/**
* @param {Decimal} value
*/
set limit(value) {
this.autobuyer.priority = value;
set amount(value) {
this.data.amount = value;
}
bumpLimit(mult) {
if (this.isUnlocked && this.mode === AutoCrunchMode.AMOUNT) {
this.limit = this.limit.times(mult);
get time() {
return this.data.time;
}
set time(value) {
this.data.time = value;
}
get xLast() {
return this.data.xLast;
}
set xLast(value) {
this.data.xLast = value;
}
bumpAmount(mult) {
if (this.isUnlocked) {
this.amount = this.amount.times(mult);
}
}
toggleMode() {
this.mode = Object.values(AutoCrunchMode).nextSibling(this.mode);
this.mode = [
AutoCrunchMode.AMOUNT,
AutoCrunchMode.TIME,
AutoCrunchMode.RELATIVE
]
.nextSibling(this.mode);
}
tick() {
if (!this.canTick()) return;
super.tick();
if (!player.antimatter.gte(Decimal.MAX_NUMBER)) return;
let proc = !player.break || NormalChallenge.isRunning || InfinityChallenge.isRunning;
if (!proc) {
switch (this.mode) {
case AutoCrunchMode.AMOUNT:
proc = gainedInfinityPoints().gte(this.limit);
proc = gainedInfinityPoints().gte(this.amount);
break;
case AutoCrunchMode.TIME:
proc = Decimal.gt(Time.thisInfinityRealTime.totalSeconds, this.limit);
proc = Time.thisInfinityRealTime.totalSeconds > this.time;
break;
case AutoCrunchMode.RELATIVE:
proc = gainedInfinityPoints().gte(player.lastTenRuns[0][1].times(this.limit));
proc = gainedInfinityPoints().gte(player.lastTenRuns[0][1].times(this.xLast));
break;
}
}
if (proc) {
bigCrunchResetRequest();
}
this.resetTicks();
}
reset() {
super.reset();
if (EternityMilestone.bigCrunchModes.isReached) return;
this.mode = AutoCrunchMode.AMOUNT;
}
}();

View File

@ -1,100 +1,82 @@
"use strict";
Autobuyer.dimboost = new class DimboostAutobuyerState extends AutobuyerState {
constructor() {
super(() => player.autobuyers[9]);
Autobuyer.dimboost = new class DimBoostAutobuyerState extends IntervaledAutobuyerState {
get data() {
return player.auto.dimBoost;
}
initialize() {
player.autobuyers[9] = new Autobuyer(8000);
get isUnlocked() {
return NormalChallenge(10).isCompleted;
}
get challenge() {
return NormalChallenge(10);
get baseInterval() {
return Player.defaultStart.auto.dimBoost.interval;
}
/**
* @returns {number}
*/
get maxDimBoosts() {
return this.priority;
return this.data.maxDimBoosts;
}
/**
* @param {number} value
*/
set maxDimBoosts(value) {
this.priority = value;
this.data.maxDimBoosts = value;
}
get galaxies() {
return this.data.galaxies;
}
set galaxies(value) {
this.data.galaxies = value;
}
get bulk() {
return this.data.bulk;
}
set bulk(value) {
this.data.bulk = value;
}
/**
* @returns {boolean}
*/
get isBulkBuyUnlocked() {
return BreakInfinityUpgrade.bulkDimBoost.isBought || this.isBuyMaxUnlocked;
return BreakInfinityUpgrade.bulkDimBoost.isBought;
}
get buyMaxInterval() {
return this.data.buyMaxInterval;
}
set buyMaxInterval(value) {
this.data.buyMaxInterval = value;
}
/**
* @returns {boolean}
*/
get isBuyMaxUnlocked() {
return EternityMilestone.autobuyMaxDimboosts.isReached;
}
/**
* @returns {number}
*/
get galaxies() {
return player.overXGalaxies;
get interval() {
return this.isBuyMaxUnlocked ? this.buyMaxInterval : super.interval;
}
/**
* @param {number} value
*/
set galaxies(value) {
player.overXGalaxies = value;
}
/**
* @returns {number}
*/
get buyMaxInterval() {
return this.bulk;
}
get hasInterval() {
return !this.isBuyMaxUnlocked && super.hasInterval;
}
/**
* @param {number} value
*/
set buyMaxInterval(value) {
this.bulk = value;
get canTick() {
return !Ra.isRunning && super.canTick;
}
tick() {
if (Ra.isRunning) return;
if (!this.canTick()) return;
super.tick();
if (this.isBuyMaxUnlocked) {
if (Autobuyer.intervalTimer - Autobuyer.lastDimBoost >= this.buyMaxInterval) {
Autobuyer.lastDimBoost = Autobuyer.intervalTimer;
maxBuyDimBoosts();
}
maxBuyDimBoosts();
return;
}
if (this.maxDimBoosts <= player.resets && this.galaxies > player.galaxies) {
if (player.resets >= this.maxDimBoosts && player.galaxies < this.galaxies) {
return;
}
if (this.isBulkBuyUnlocked && !DimBoost.isShift) {
var bulk = Math.max(this.bulk, 1);
const bulk = Math.clampMin(this.bulk, 1);
if (!DimBoost.bulkRequirement(bulk).isSatisfied) return;
softReset(bulk);
return;
}
else {
if (!DimBoost.requirement.isSatisfied) return;
softReset(1);
}
this.resetTicks();
if (!DimBoost.requirement.isSatisfied) return;
softReset(1);
}
}();

View File

@ -2,7 +2,7 @@
class DimensionAutobuyerState extends IntervaledAutobuyerState {
constructor(tier) {
super(() => player.autobuyers[tier - 1]);
super();
this._tier = tier;
}
@ -10,73 +10,69 @@ class DimensionAutobuyerState extends IntervaledAutobuyerState {
return player.auto.dimensions[this._tier - 1];
}
initialize() {
const baseIntervals = [
null,
1500,
2000,
2500,
3000,
4000,
5000,
6000,
7500,
];
player.autobuyers[this._tier - 1] = new Autobuyer(baseIntervals[this._tier]);
get baseInterval() {
return Player.defaultStart.auto.dimensions[this._tier - 1].interval;
}
get challenge() {
return NormalChallenge(this._tier);
get isUnlocked() {
return NormalChallenge(this._tier).isCompleted;
}
get bulk() {
return this.data.bulk;
}
/**
* @returns {boolean}
*/
get hasMaxedBulk() {
return this.isUnlocked && this.bulk >= 1e100;
return this.bulk >= 1e100;
}
/**
* @returns {AutobuyerMode}
*/
get mode() {
return this.autobuyer.target;
return this.data.mode;
}
/**
* @param {AutobuyerMode} value
*/
set mode(value) {
this.autobuyer.target = value;
this.data.mode = value;
}
toggleMode() {
this.mode = this.mode === AutobuyerMode.BUY_SINGLE ? AutobuyerMode.BUY_10 : AutobuyerMode.BUY_SINGLE;
this.mode = [
AutobuyerMode.BUY_SINGLE,
AutobuyerMode.BUY_10
]
.nextSibling(this.mode);
}
tick() {
if (!this.canTick()) return;
super.tick();
const tier = this._tier;
if (!NormalDimension(tier).isAvailable) return;
if (this.mode === AutobuyerMode.BUY_SINGLE) {
buyOneDimension(tier);
switch (this.mode) {
case AutobuyerMode.BUY_SINGLE:
buyOneDimension(tier);
break;
case AutobuyerMode.BUY_10:
buyManyDimensionAutobuyer(tier, player.options.bulkOn ? this.bulk : 1);
break;
}
else {
const bulk = player.options.bulkOn ? this.bulk : 1;
buyManyDimensionAutobuyer(tier, bulk);
}
this.resetTicks();
}
upgradeBulk() {
if (this.hasMaxedBulk) return;
if (player.infinityPoints.lt(this.cost)) return;
player.infinityPoints = player.infinityPoints.minus(this.cost);
this.bulk = Math.min(this.bulk * 2, 1e100);
this.cost = Math.ceil(2.4 * this.cost);
Autobuyer.checkBulkAchievements();
if (Currency.infinityPoints.isAffordable(this.cost)) return;
Currency.infinityPoints.subtract(this.cost);
this.data.bulk = Math.clampMax(this.bulk * 2, 1e100);
this.data.cost = Math.ceil(2.4 * this.cost);
Achievement(61).tryUnlock();
SecretAchievement(38).tryUnlock();
GameUI.update();
}
reset() {
super.reset();
if (EternityMilestone.keepAutobuyers.isReached) return;
this.data.isUnlocked = false;
this.data.bulk = 1;
}
}
DimensionAutobuyerState.index = Array.range(1, 8).map(tier => new DimensionAutobuyerState(tier));

View File

@ -1,85 +1,84 @@
"use strict";
Autobuyer.eternity = {
/**
* @returns {boolean}
*/
Autobuyer.eternity = new class EternityAutobuyerState extends AutobuyerState {
get data() {
return player.auto.eternity;
}
get isUnlocked() {
return EternityMilestone.autobuyerEternity.isReached;
},
/**
* @returns {boolean}
*/
}
get mode() {
return this.data.mode;
}
set mode(value) {
this.data.mode = value;
}
get amount() {
return this.data.amount;
}
set amount(value) {
this.data.amount = value;
}
get time() {
return this.data.time;
}
set time(value) {
this.data.time = value;
}
get xLast() {
return this.data.xLast;
}
set xLast(value) {
this.data.xLast = value;
}
get hasAdditionalModes() {
return RealityUpgrade(13).isBought;
},
/**
* @returns {boolean}
*/
get isOn() {
return player.eternityBuyer.isOn;
},
/**
* @param {boolean} value
*/
set isOn(value) {
player.eternityBuyer.isOn = value;
},
toggle() {
this.isOn = !this.isOn;
},
/**
* @returns {boolean}
*/
get isActive() {
return this.isUnlocked && this.isOn;
},
/**
* @returns {Decimal}
*/
get limit() {
return player.eternityBuyer.limit;
},
/**
* @param {Decimal} value
*/
set limit(value) {
player.eternityBuyer.limit = value;
},
bumpLimit(mult) {
if (this.isUnlocked && this.mode === AutoEternityMode.AMOUNT) {
this.limit = this.limit.times(mult);
}
bumpAmount(mult) {
if (this.isUnlocked) {
this.amount = this.amount.times(mult);
}
},
/**
* @returns {AutoEternityMode}
*/
get mode() {
return player.autoEternityMode;
},
/**
* @param {AutoEternityMode} value
*/
set mode(value) {
player.autoEternityMode = value;
},
}
toggleMode() {
this.mode = Object.values(AutoEternityMode).nextSibling(this.mode);
},
this.mode = [
AutoEternityMode.AMOUNT,
AutoEternityMode.TIME,
AutoEternityMode.RELATIVE
]
.nextSibling(this.mode);
}
tick() {
if (!this.isActive) return;
let proc = false;
switch (this.mode) {
case AutoEternityMode.AMOUNT:
proc = EternityChallenge.isRunning || gainedEternityPoints().gte(this.limit);
proc = EternityChallenge.isRunning || gainedEternityPoints().gte(this.amount);
break;
case AutoEternityMode.TIME:
proc = Decimal.gt(Time.thisEternityRealTime.totalSeconds, this.limit)
proc = Time.thisEternityRealTime.totalSeconds > this.time;
break;
case AutoEternityMode.RELATIVE:
proc = gainedEternityPoints().gte(player.lastTenEternities[0][1].times(this.limit));
proc = gainedEternityPoints().gte(player.lastTenEternities[0][1].times(this.xLast));
break;
}
if (proc) eternity(false, true);
}
};
reset() {
if (!RealityUpgrade(10).isBought) {
this.isActive = false;
}
}
}();

View File

@ -1,74 +1,55 @@
"use strict";
Autobuyer.galaxy = new class GalaxyAutobuyerState extends AutobuyerState {
constructor() {
super(() => player.autobuyers[10]);
Autobuyer.galaxy = new class GalaxyAutobuyerState extends IntervaledAutobuyerState {
get data() {
return player.auto.galaxy;
}
initialize() {
player.autobuyers[10] = new Autobuyer(150000);
get isUnlocked() {
return NormalChallenge(11).isCompleted;
}
get challenge() {
return NormalChallenge(11);
get baseInterval() {
return Player.defaultStart.auto.galaxy.interval;
}
/**
* @returns {number}
*/
get limit() {
return this.priority;
get maxGalaxies() {
return this.data.maxGalaxies;
}
/**
* @param {number} value
*/
set limit(value) {
this.priority = value;
set maxGalaxies(value) {
this.data.maxGalaxies = value;
}
get buyMaxInterval() {
return this.data.buyMaxInterval;
}
set buyMaxInterval(value) {
this.data.buyMaxInterval = value;
}
/**
* @returns {boolean}
*/
get isBuyMaxUnlocked() {
return EternityMilestone.autobuyMaxGalaxies.isReached;
}
/**
* @returns {number}
*/
get buyMaxInterval() {
return this.bulk;
get isBuyMaxActive() {
// TODO
return this.isBuyMaxUnlocked && this.buyMaxInterval > 0;
}
/**
* @param {number} value
*/
set buyMaxInterval(value) {
this.bulk = value;
get interval() {
return this.isBuyMaxActive ? this.buyMaxInterval : super.interval;
}
tick() {
if (!this.canTick()) return;
super.tick();
if (!Galaxy.requirement.isSatisfied) return;
if (this.limit <= player.galaxies) return;
if (this.isBuyMaxUnlocked && this.buyMaxInterval > 0) {
this.buyMax();
}
else {
this.buySingle();
this.resetTicks();
}
}
buyMax() {
if (Autobuyer.intervalTimer - Autobuyer.lastGalaxy >= this.buyMaxInterval) {
Autobuyer.lastGalaxy = Autobuyer.intervalTimer;
if (player.galaxies >= this.maxGalaxies) return;
if (this.isBuyMaxActive) {
maxBuyGalaxies();
return;
}
}
buySingle() {
galaxyResetBtnClick();
}
}();

View File

@ -1,74 +1,53 @@
"use strict";
Autobuyer.reality = {
/**
* @returns {boolean}
*/
Autobuyer.reality = new class RealityAutobuyerState extends AutobuyerState {
get data() {
return player.auto.reality;
}
get isUnlocked() {
return RealityUpgrade(25).isBought;
},
/**
* @returns {boolean}
*/
get isOn() {
return player.realityBuyer.isOn;
},
/**
* @param {boolean} value
*/
set isOn(value) {
player.realityBuyer.isOn = value;
},
toggle() {
this.isOn = !this.isOn;
},
/**
* @returns {boolean}
*/
get isActive() {
return this.isUnlocked && this.isOn;
},
/**
* @returns {Decimal}
*/
get rm() {
return player.realityBuyer.rm;
},
/**
* @param {Decimal} value
*/
set rm(value) {
player.realityBuyer.rm = value;
},
/**
* @returns {number}
*/
get glyph() {
return player.realityBuyer.glyph;
},
/**
* @param {number} value
*/
set glyph(value) {
player.realityBuyer.glyph = value;
},
/**
* @returns {AutoRealityMode}
*/
}
get canTick() {
return super.canTick && !GlyphSelection.active;
}
get mode() {
return player.autoRealityMode;
},
/**
* @param {AutoRealityMode} value
*/
return this.data.mode;
}
set mode(value) {
player.autoRealityMode = value;
},
this.data.mode = value;
}
get rm() {
return this.data.rm;
}
set rm(value) {
this.data.rm = value;
}
get glyph() {
return this.data.rm;
}
set glyph(value) {
this.data.rm = value;
}
toggleMode() {
this.mode = Object.values(AutoRealityMode).nextSibling(this.mode);
},
this.mode = [
AutoRealityMode.RM,
AutoRealityMode.GLYPH,
AutoRealityMode.EITHER,
AutoRealityMode.BOTH
]
.nextSibling(this.mode);
}
tick() {
if (!this.isActive || GlyphSelection.active) return;
let proc = false;
const rmProc = gainedRealityMachines().gte(this.rm);
const glyphProc = gainedGlyphLevel().actualLevel >= this.glyph;
@ -88,4 +67,4 @@ Autobuyer.reality = {
}
if (proc) autoReality();
}
};
}();

View File

@ -1,41 +1,24 @@
"use strict";
Autobuyer.sacrifice = new class SacrificeAutobuyerState extends AutobuyerState {
constructor() {
super(() => player.autoSacrifice);
get data() {
return player.auto.sacrifice;
}
initialize() {
player.autoSacrifice = new Autobuyer(100);
this.limit = new Decimal(5);
get isUnlocked() {
return EternityMilestone.autoIC.isReached || InfinityChallenge(2).isCompleted;
}
get challenge() {
return InfinityChallenge(2);
get multiplier() {
return this.data.multiplier;
}
/**
* @returns {Decimal}
*/
get limit() {
return this.autobuyer.priority;
}
/**
* @param {Decimal} value
*/
set limit(value) {
this.autobuyer.priority = value;
}
get hasInterval() {
return false;
set multiplier(value) {
this.data.multiplier = value;
}
tick() {
if (!this.canTick()) return;
if (!Sacrifice.nextBoost.gte(this.limit)) return;
if (Sacrifice.nextBoost.lt(this.multiplier)) return;
sacrificeReset(true);
this.resetTicks();
}
}();

View File

@ -1,44 +1,49 @@
"use strict";
Autobuyer.tickspeed = new class TickspeedAutobuyerState extends AutobuyerState {
constructor() {
super(() => player.autobuyers[8]);
Autobuyer.tickspeed = new class TickspeedAutobuyerState extends IntervaledAutobuyerState {
get data() {
return player.auto.tickspeed;
}
initialize() {
player.autobuyers[8] = new Autobuyer(5000);
get isUnlocked() {
return NormalChallenge(9).isCompleted;
}
get challenge() {
return NormalChallenge(9);
get baseInterval() {
return Player.defaultStart.auto.tickspeed.interval;
}
/**
* @returns {AutobuyerMode}
*/
get mode() {
return this.autobuyer.target;
return this.data.mode;
}
/**
* @param {AutobuyerMode} value
*/
set mode(value) {
this.autobuyer.target = value;
this.data.mode = value;
}
toggleMode() {
this.mode = this.mode === AutobuyerMode.BUY_SINGLE ? AutobuyerMode.BUY_MAX : AutobuyerMode.BUY_SINGLE;
this.mode = [
AutobuyerMode.BUY_SINGLE,
AutobuyerMode.BUY_MAX
]
.nextSibling(this.mode);
}
tick() {
if (!this.canTick()) return;
if (this.mode === AutobuyerMode.BUY_SINGLE) {
buyTickSpeed();
super.tick();
switch (this.mode) {
case AutobuyerMode.BUY_SINGLE:
buyTickSpeed();
break;
case AutobuyerMode.BUY_MAX:
buyMaxTickSpeed();
break;
}
else {
buyMaxTickSpeed();
}
this.resetTicks();
}
reset() {
super.reset();
if (EternityMilestone.keepAutobuyers.isReached) return;
this.data.isUnlocked = false;
}
}();

View File

@ -21,10 +21,7 @@ function handleChallengeCompletion() {
}
const challenge = NormalChallenge.current || InfinityChallenge.current;
if (!challenge) return;
if (!challenge.isCompleted) {
challenge.complete();
Autobuyer.tryUnlockAny();
}
challenge.complete();
challenge.updateChallengeTime();
if (NormalChallenge(9).isRunning) {
kong.submitStats("NormalChallenge 9 time record (ms)", Math.floor(player.thisInfinityTime));
@ -296,7 +293,7 @@ class InfinityIPMultUpgrade extends GameMechanicState {
const costIncrease = this.costIncrease;
const mult = Decimal.pow(2, amount);
player.infMult = player.infMult.times(mult);
Autobuyer.bigCrunch.bumpLimit(mult);
Autobuyer.bigCrunch.bumpAmount(mult);
player.infMultCost = this.cost.times(Decimal.pow(costIncrease, amount));
player.infinityPoints = player.infinityPoints.minus(this.cost.dividedBy(costIncrease));
this.adjustToCap();

View File

@ -19,7 +19,6 @@ function tryUnlockInfinityChallenges() {
++player.postChallUnlocked;
if (player.eternities > 6) {
InfinityChallenge(player.postChallUnlocked).complete();
Autobuyer.tryUnlockAny();
}
}
}
@ -87,7 +86,6 @@ class NormalChallengeState extends GameMechanicState {
complete() {
// eslint-disable-next-line no-bitwise
player.challenge.normal.completedBits |= 1 << this.id;
Autobuyer.tryUnlockAny();
}
get goal() {

View File

@ -84,15 +84,8 @@ dev.cancerize = function() {
dev.fixSave = function() {
const save = JSON.stringify(player, GameSaveSerializer.jsonConverter);
const fixed = save.replace(/NaN/gui, "10");
const stillToDo = JSON.parse(fixed);
for (let i = 0; i < stillToDo.autobuyers.length; i++) {
stillToDo.autobuyers[i].isOn = false;
}
console.log(stillToDo);
const saveData = stillToDo;
const saveData = JSON.parse(fixed);
if (!saveData || !GameStorage.verifyPlayerObject(saveData)) {
alert("Could not fix the save..");
return;
@ -410,4 +403,4 @@ dev.kongTest = function() {
page.style.height = "";
page.style.marginTop = "";
}
};
};

View File

@ -141,7 +141,7 @@ function maxBuyDimBoosts(manual) {
return;
}
let availableBoosts = Number.MAX_VALUE;
if (player.overXGalaxies > player.galaxies && !manual) {
if (Autobuyer.dimboost.galaxies > player.galaxies && !manual) {
availableBoosts = Autobuyer.dimboost.maxDimBoosts - player.resets;
}
if (availableBoosts <= 0) return;

View File

@ -24,7 +24,6 @@ function eternity(force, auto, specialConditions = {}) {
player.eternities += Effects.product(RealityUpgrade(3));
}
if (player.eternities < 20 && Autobuyer.dimboost.isUnlocked) Autobuyer.dimboost.buyMaxInterval = 1;
if (EternityChallenge.isRunning) {
const challenge = EternityChallenge.current;
challenge.addCompletion();
@ -49,8 +48,8 @@ function eternity(force, auto, specialConditions = {}) {
initializeChallengeCompletions();
initializeResourcesAfterEternity();
if (player.eternities < 2) {
Autobuyer.resetUnlockables();
if (!EternityMilestone.keepAutobuyers.isReached) {
// Fix infinity because it can only break after big crunch autobuyer interval is maxed
player.break = false;
}
@ -144,9 +143,6 @@ function initializeResourcesAfterEternity() {
player.onlyFirstDimensions = true;
player.noEighthDimensions = true;
player.postChallUnlocked = Achievement(133).isEnabled ? 8 : 0;
if (player.eternities < 7 && !Achievement(133).isEnabled) {
player.autoSacrifice = 1;
}
}
function applyRealityUpgrades() {
@ -285,7 +281,7 @@ class EPMultiplierState extends GameMechanicState {
player.epmultUpgrades = value;
this.cachedCost.invalidate();
this.cachedEffectValue.invalidate();
Autobuyer.eternity.bumpLimit(Decimal.pow(5, diff));
Autobuyer.eternity.bumpAmount(Decimal.pow(5, diff));
}
get effectValue() {

View File

@ -14,7 +14,6 @@ function startEternityChallenge() {
IPminpeak = new Decimal(0);
EPminpeak = new Decimal(0);
resetTimeDimensions();
if (player.eternities < 20) Autobuyer.dimboost.buyMaxInterval = 1;
kong.submitStats("Eternities", player.eternities);
resetTickspeed();
resetAntimatter();

View File

@ -156,7 +156,7 @@ function galaxyResetBtnClick() {
}
function maxBuyGalaxies(manual) {
const limit = manual ? Number.MAX_VALUE : Autobuyer.galaxy.limit;
const limit = manual ? Number.MAX_VALUE : Autobuyer.galaxy.maxGalaxies;
if (player.galaxies >= limit || !Galaxy.canBeBought) return false;
// Check for ability to buy one galaxy (which is pretty efficient)
const req = Galaxy.requirement;

View File

@ -84,4 +84,4 @@ const PerformanceStats = {
render(this.stats);
this.container.innerHTML = text;
}
};
};

View File

@ -76,7 +76,7 @@ let player = {
dimBoost: {
cost: 1,
interval: 8000,
dimBoosts: 1,
maxDimBoosts: 1,
galaxies: 10,
bulk: 1,
buyMaxInterval: 0,
@ -139,7 +139,6 @@ let player = {
// TODO: Not used, remove
interval: null,
lastUpdate: new Date().getTime(),
autobuyers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
tickspeedMultiplier: new Decimal(10),
chall2Pow: 1,
chall3Pow: new Decimal(0.01),
@ -160,7 +159,6 @@ let player = {
lastTenRealities: Array.range(0, 10).map(() => [defaultMaxTime, new Decimal(1), defaultMaxTime, 0]),
infMult: new Decimal(1),
infMultCost: new Decimal(10),
overXGalaxies: 10,
version: 13,
infinityPower: new Decimal(1),
spreadingCancer: 0,
@ -208,14 +206,7 @@ let player = {
eternityChalls: {},
etercreq: 0,
infMultBuyer: false,
autoCrunchMode: AutoCrunchMode.AMOUNT,
autoEternityMode: AutoEternityMode.AMOUNT,
autoRealityMode: AutoRealityMode.RM,
respec: false,
eternityBuyer: {
limit: new Decimal(0),
isOn: false
},
eterc8ids: 50,
eterc8repl: 40,
noSacrifices: true,
@ -243,11 +234,6 @@ let player = {
thisReality: 0,
thisRealityRealTime: 0,
bestReality: 999999999999,
realityBuyer: {
rm: new Decimal(0),
glyph: 0,
isOn: false
},
reality: {
realityMachines: new Decimal(0),
glyphs: {
@ -537,8 +523,8 @@ function guardFromNaNValues(obj) {
for (let key in obj) {
if (!obj.hasOwnProperty(key)) continue;
//TODO: rework autobuyer saving
if (key === "autobuyers" || key === "autoSacrifice" || key === "automator") continue;
// TODO: rework autobuyer saving
if (key === "autoSacrifice" || key === "automator") continue;
let value = obj[key];
if (isObject(value)) {

View File

@ -281,9 +281,6 @@ function completeReality(force, reset, auto = false) {
player.galaxies = isRUPG10Bought ? 1 : 0;
player.tickDecrease = 0.9;
player.interval = null;
if (!isRUPG10Bought) {
Autobuyer.resetUnlockables();
}
player.partInfinityPoint = 0;
player.partInfinitied = 0;
player.break = isRUPG10Bought ? player.break : false;
@ -325,9 +322,6 @@ function completeReality(force, reset, auto = false) {
player.challenge.eternity.unlocked = 0;
player.etercreq = 0;
player.infMultBuyer = isRUPG10Bought ? player.infMultBuyer : false;
if (!isRUPG10Bought) {
player.autoCrunchMode = AutoCrunchMode.AMOUNT;
}
player.respec = false;
player.eterc8ids = 50;
player.eterc8repl = 40;
@ -346,9 +340,6 @@ function completeReality(force, reset, auto = false) {
player.timestudy.epcost = new Decimal(1);
player.timestudy.studies = [];
player.celestials.v.additionalStudies = 0;
if (!RealityUpgrade(10).isBought) {
player.eternityBuyer.isOn = false;
}
player.dilation.studies = [];
player.dilation.active = false;
player.dilation.tachyonParticles = new Decimal(0);
@ -389,7 +380,6 @@ function completeReality(force, reset, auto = false) {
if (player.infinitied.gt(0) && !NormalChallenge(1).isCompleted) {
NormalChallenge(1).complete();
}
Autobuyer.tryUnlockAny()
if (player.realities === 4) player.reality.automatorCommands = new Set([12, 24, 25]);
player.reality.upgReqChecks = [true];
InfinityDimensions.resetAmount();

View File

@ -246,15 +246,15 @@ GameDatabase.achievements.normal = [
id: 52,
name: "Age of Automation",
tooltip: "Max any 9 autobuyers.",
checkRequirement: () => Autobuyer.unlockables
.countWhere(a => a.hasMaxedInterval) >= 9
checkRequirement: () => Autobuyer.intervaled
.countWhere(a => a.hasMaxedInterval) === 9
},
{
id: 53,
name: "Definitely not worth it",
tooltip: "Max all the autobuyers.",
checkRequirement: () => Autobuyer.unlockables
.countWhere(a => a.hasMaxedInterval) >= 12
checkRequirement: () => Autobuyer.intervaled
.countWhere(a => !a.hasMaxedInterval) === 0
},
{
id: 54,

View File

@ -399,8 +399,6 @@ GameStorage.devMigrations = {
autobuyer.rm = old.rm;
autobuyer.glyph = old.glyph;
autobuyer.isActive = old.isOn;
// KILLME
player.autoRealityMode = ["rm", "glyph", "either", "both"].indexOf(player.autoRealityMode);
}
],

View File

@ -494,7 +494,7 @@ GameStorage.migrations = {
const autobuyer = player.auto.dimBoost;
autobuyer.cost = old.cost;
autobuyer.interval = old.interval;
autobuyer.dimBoosts = old.priority;
autobuyer.maxDimBoosts = old.priority;
autobuyer.galaxies = player.overXGalaxies;
autobuyer.bulk = old.bulk;
autobuyer.buyMaxInterval = old.bulk;
@ -541,10 +541,6 @@ GameStorage.migrations = {
autobuyer.xLast = new Decimal(old.limit);
autobuyer.isActive = old.isOn;
}
// KILLME
player.autoCrunchMode = ["amount", "time", "relative"].indexOf(player.autoCrunchMode);
player.autoEternityMode = ["amount", "time", "relative"].indexOf(player.autoEternityMode);
},
prePatch(saveData) {

View File

@ -136,10 +136,6 @@ const GameStorage = {
}
recalculateAllGlyphs();
Autobuyer.tryUnlockAny();
Autobuyer.checkIntervalAchievements();
Autobuyer.checkBulkAchievements();
Autobuyer.convertPropertiesToDecimal();
checkPerkValidity();
Teresa.checkPPShopValidity();
drawPerkNetwork();

View File

@ -467,17 +467,7 @@ function gameLoop(diff, options = {}) {
if (diff < 0) diff = 1;
if (autobuyerOnGameLoop) {
Autobuyer.intervalTimer += diff / 20;
Autobuyer.tickTimer += diff;
let autobuyerInterval = BreakInfinityUpgrade.autobuyerSpeed.isBought ? 50 : 100;
if (Autobuyer.tickTimer >= autobuyerInterval) {
Autobuyer.tickTimer -= autobuyerInterval;
// failsafe
if (Autobuyer.tickTimer > autobuyerInterval) {
Autobuyer.tickTimer = autobuyerInterval;
}
Autobuyers.tick();
}
Autobuyers.tick();
}
// We do these after autobuyers, since it's possible something there might
// change a multiplier.

View File

@ -68,7 +68,7 @@ function updateSpoilers() {
if (i === 10 && (player.infinitied.gte(1) || player.eternities >= 1)) {
(displayed === 0) ? displayed = 1 : displayed = 0;
}
if (i === 11 && (player.autobuyers[11].interval>100 || player.eternities >= 1)) {
if (i === 11 && (player.auto.bigCrunch.interval>100 || player.eternities >= 1)) {
(displayed === 0) ? displayed = 1 : displayed = 0;
}
if (i === 12 && (player.infDimensionsUnlocked[0] == true || player.eternities >= 1)) {

View File

@ -4,7 +4,6 @@ function fixSave() {
var fixed = save.replace(/NaN/gi, "10")
var fixed2 = fixed.replace("notyetfixed", "hasbeenfixed")
var stillToDo = JSON.parse(fixed2)
for (var i=0; i<stillToDo.autobuyers.length; i++) stillToDo.autobuyers[i].isOn = false
document.getElementById("fixed").value = btoa(JSON.stringify(stillToDo))
}
}