1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-12-22 18:21:18 +00:00

Do upgrades through Game object instead of interface

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-04-21 12:29:58 +02:00
parent 5ca3fcc919
commit 6a19e97ccb
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.18.2 // @version 0.18.3
// @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
@ -43,10 +43,11 @@ function executeAutoActions() {
} }
// Look for upgrades being available // Look for upgrades being available
let availableUpgrades = $('.upgrade.enabled').filter(upgradeFilter); let availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !blockingUpgrades.includes(obj.id));
if (availableUpgrades.length > 0) { while (availableUpgrades.length > 0) {
availableUpgrades.click(); let upgrade = availableUpgrades[0];
note('Purchased ' + availableUpgrades.length + ' upgrades for you.'); upgrade.buy();
note('Purchased upgrade ' + upgrade.name + ' for you.');
} }
// Get the top enabled purchase to be made // Get the top enabled purchase to be made
@ -123,15 +124,6 @@ function note(msg, quick = true) {
Game.Notify('Auto-CookieClicker', msg, [12, 0], quick, true); Game.Notify('Auto-CookieClicker', msg, [12, 0], quick, true);
} }
function upgradeFilter() {
let onClickHandler = $(this).attr('onclick');
if (onClickHandler == null) {
return false;
}
let upgradeID = parseInt(onClickHandler.replace(/^.*\[([0-9]+)\].*$/, '$1'));
return !blockingUpgrades.includes(upgradeID);
}
(function() { (function() {
'use strict'; 'use strict';