1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-11-08 14:00:12 +00:00

Don't try to buy an upgrade twice

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-04-21 14:08:04 +02:00
parent 9141d86ea0
commit 23dc21bdfc
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name Automate CookieClicker
// @namespace https://luzifer.io/
// @version 0.19.1
// @version 0.19.2
// @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me>
// @source https://github.com/Luzifer/automate-cookie-clicker
@ -42,13 +42,13 @@ function executeAutoActions() {
}
// Look for upgrades being available
let availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !blockingUpgrades.includes(obj.id));
let availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !obj.bought && !blockingUpgrades.includes(obj.id));
while (availableUpgrades.length > 0) {
let upgrade = availableUpgrades[0];
upgrade.buy();
note(`Purchased upgrade ${upgrade.name} for you.`);
availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !blockingUpgrades.includes(obj.id));
availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !obj.bought && !blockingUpgrades.includes(obj.id));
}
// Get the top enabled purchase to be made