1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-11-09 14:30:08 +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==
// @name Automate CookieClicker
// @namespace https://luzifer.io/
// @version 0.18.2
// @version 0.18.3
// @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me>
// @source https://github.com/Luzifer/automate-cookie-clicker
@ -43,10 +43,11 @@ function executeAutoActions() {
}
// Look for upgrades being available
let availableUpgrades = $('.upgrade.enabled').filter(upgradeFilter);
if (availableUpgrades.length > 0) {
availableUpgrades.click();
note('Purchased ' + availableUpgrades.length + ' upgrades for you.');
let availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !blockingUpgrades.includes(obj.id));
while (availableUpgrades.length > 0) {
let upgrade = availableUpgrades[0];
upgrade.buy();
note('Purchased upgrade ' + upgrade.name + ' for you.');
}
// 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);
}
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() {
'use strict';