Skip to content

Commit

Permalink
remove followup system
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian committed Oct 21, 2023
1 parent 5582656 commit c276ca1
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/cookieclickermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const store = document.getElementById("store");
const buffs = document.getElementById("buffs");
const bankContent = document.getElementById("bankContent");
const grimoireSpells = document.getElementById("grimoireSpells");
const actualRunModHook = Game.runModHook.bind(Game);

var clicksps = 100;
var intervals = {};
Expand Down Expand Up @@ -51,7 +50,6 @@ function shopGreedily() {
if (item && item.profitability > 0 && item.l.matches(".product:not(.disabled), .upgrade.enabled")) {
clickOn(item.l);
console.log(`%cCookie manager: Purchased ${item.name}`, "font-weight:bold");
followup(shopGreedily);
return item;
}
}
Expand Down Expand Up @@ -229,43 +227,11 @@ function lastOf(arr) {
return arr[arr.length - 1];
}

/*:・゚✧*:・゚✧ ----- FOLLOWUP SYSTEM ----- *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ */

var followupfns = [];
var requiredhooks = ["logic", "draw"];
var hithooks = [];

function followup(fn) {
followupfns.push(fn);
}

function tickFollowups() {
followupfns.forEach((fn, i) => {
var index = timers.length;
var timer = setTimeout(() => {
timers.splice(index, 1);
fn();
}, i * 100);
timers.push(timer);
});
followupfns = [];
}

function hijackedRunModHook(hook, ...args) {
actualRunModHook(hook, ...args);
hithooks.push(hook);
if (!requiredhooks.some(req => !hithooks.includes(req))) {
tickFollowups();
hithooks = [];
}
}

/*:・゚✧*:・゚✧ ----- SCRIPT LIFECYCLE ----- *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ *:・゚✧*:・゚✧ */

function cleanup() {
Object.values(window.cookieclickerhacks.intervals).forEach(clearInterval);
timers.forEach(clearTimeout);
Game.runModHook = actualRunModHook;
}

function init() {
Expand All @@ -282,8 +248,6 @@ function init() {
intervals.lump = setInterval(harvestLumpIfRipe, 2999);
intervals.stockmarket = setInterval(adjustStockPortfolio, 4999);

Game.runModHook = hijackedRunModHook;

if (isRestart) {
console.log("cookie clicker manager restarted");
} else {
Expand All @@ -309,7 +273,6 @@ window.cookieclickerhacks = {
analyzeStockMarket,
handOfFateToBoostBuffs,
lastOf,
followup,
intervals,
timers,
cleanup,
Expand Down

0 comments on commit c276ca1

Please sign in to comment.