1
0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-09-19 15:23:02 +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== // ==UserScript==
// @name Automate CookieClicker // @name Automate CookieClicker
// @namespace https://luzifer.io/ // @namespace https://luzifer.io/
// @version 0.19.1 // @version 0.19.2
// @description Automate everything! // @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me> // @author Knut Ahlers <knut@ahlers.me>
// @source https://github.com/Luzifer/automate-cookie-clicker // @source https://github.com/Luzifer/automate-cookie-clicker
@ -42,13 +42,13 @@ function executeAutoActions() {
} }
// Look for upgrades being available // 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) { while (availableUpgrades.length > 0) {
let upgrade = availableUpgrades[0]; let upgrade = availableUpgrades[0];
upgrade.buy(); upgrade.buy();
note(`Purchased upgrade ${upgrade.name} for you.`); 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 // Get the top enabled purchase to be made