From 59cfc9f69596b23bc68c432246b82c78895eebad Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 25 Apr 2018 12:59:08 +0200 Subject: [PATCH] Don't cap buys but buy in 50pcs steps Signed-off-by: Knut Ahlers --- autocookieclicker.user.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/autocookieclicker.user.js b/autocookieclicker.user.js index 92a9a95..6b14e0d 100644 --- a/autocookieclicker.user.js +++ b/autocookieclicker.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Automate CookieClicker // @namespace https://luzifer.io/ -// @version 0.20.0 +// @version 0.21.0 // @description Automate everything! // @author Knut Ahlers // @source https://github.com/Luzifer/automate-cookie-clicker @@ -52,11 +52,11 @@ function executeAutoActions() { } // Get the top enabled purchase to be made - let availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies && obj.amount < getMaxBuy()); + let availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies); while (availableProducts.length > 0 && Game.buyMode === 1) { // buyMode 1 = buy, -1 = sell let product = availableProducts[availableProducts.length - 1]; - for (let buyAmount = getMaxBuy() - product.amount; buyAmount > 0; buyAmount--) { + for (let buyAmount = purchaseSteps - product.amount; buyAmount > 0; buyAmount--) { if (product.getSumPrice(buyAmount) <= Game.cookies) { product.buy(buyAmount); note(`Purchased ${buyAmount} ${buyAmount === 1 ? product.name : product.plural} for you.`); @@ -64,7 +64,7 @@ function executeAutoActions() { } } - availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies && obj.amount < getMaxBuy()); + availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies); } } @@ -82,12 +82,6 @@ function controlAutoClicker() { } } -function getMaxBuy() { - let topPurchaseCount = Game.ObjectsById[Game.ObjectsN - 1].amount; - - return Math.max(Math.ceil((topPurchaseCount + 1) / purchaseSteps), 1) * purchaseSteps; -} - function hasActiveClickBuff() { let hasBuff = false; for (let key in Game.buffs) {