mirror of
https://github.com/Luzifer/automate-cookie-clicker.git
synced 2024-11-08 14:00:12 +00:00
Recover method to get max buy
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
c9600caa61
commit
25fbc3b767
1 changed files with 9 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Automate CookieClicker
|
// @name Automate CookieClicker
|
||||||
// @namespace https://luzifer.io/
|
// @namespace https://luzifer.io/
|
||||||
// @version 0.17.0
|
// @version 0.17.1
|
||||||
// @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
|
||||||
|
@ -53,7 +53,7 @@ function executeAutoActions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the top enabled purchase to be made
|
// Get the top enabled purchase to be made
|
||||||
let availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies && obj.amount < purchaseSteps);
|
let availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies && obj.amount < getMaxBuy());
|
||||||
while (availableProducts.length > 0 && Game.buyMode === 1) { // buyMode 1 = buy, -1 = sell
|
while (availableProducts.length > 0 && Game.buyMode === 1) { // buyMode 1 = buy, -1 = sell
|
||||||
let product = availableProducts[availableProducts.length - 1];
|
let product = availableProducts[availableProducts.length - 1];
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ function executeAutoActions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
product.buy(buyAmount);
|
product.buy(buyAmount);
|
||||||
availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies && obj.amount < purchaseSteps);
|
availableProducts = Game.ObjectsById.filter(obj => obj.price < Game.cookies && obj.amount < getMaxBuy());
|
||||||
}
|
}
|
||||||
|
|
||||||
manageDragon();
|
manageDragon();
|
||||||
|
@ -85,6 +85,12 @@ function controlAutoClicker() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMaxBuy() {
|
||||||
|
let topPurchaseCount = Game.ObjectsById[Game.ObjectsN - 1].amount;
|
||||||
|
|
||||||
|
return Math.max(Math.ceil((topPurchaseCount + 1) / purchaseSteps), 1) * purchaseSteps;
|
||||||
|
}
|
||||||
|
|
||||||
function hasActiveClickBuff() {
|
function hasActiveClickBuff() {
|
||||||
let hasBuff = false;
|
let hasBuff = false;
|
||||||
for (let key in Game.buffs) {
|
for (let key in Game.buffs) {
|
||||||
|
|
Loading…
Reference in a new issue