Last active
December 23, 2015 13:59
-
-
Save trashtoy/6646173 to your computer and use it in GitHub Desktop.
Automatic cookie bakery. (ver 1.0466)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Hack = { | |
cookieCount: 0, | |
goldenCount: 0, | |
cookieClick: setInterval(function() { $("#bigCookie").click(); Hack.cookieCount++; }, 1000), | |
goldenClick: setInterval(function() { $("#goldenCookie").click(); Hack.goldenCount++; }, 5000), | |
seasonClick: setInterval(function() { if (Game.season === "christmas") $("#seasonPopup").click(); }, 3000), | |
justWrong : setTimeout(function() { !(Game.AchievementsById[39].won) && Game.ObjectsById[1].sell(); }, 600000), | |
phase : 0, | |
timestamp : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | |
}; | |
(function() { | |
// | |
// PRODUCT | |
// | |
var Product = function(options) { | |
var id = options.id; | |
this.id = id; | |
this.target = Game.ObjectsById[id]; | |
this.prev = (0 < id) ? Game.ObjectsById[id - 1] : null; | |
this.max = options.max; | |
this.preMax = options.preMax; | |
}; | |
Product.prototype.add = function() { | |
if (this.mustBuy(false)) { | |
$("#buttonBuy10-" + this.id).click(); | |
return true; | |
} | |
if (this.mustBuy(true)) { | |
$("#product" + this.id).click(); | |
return true; | |
} | |
return false; | |
}; | |
Product.prototype.mustBuy = function(buyOne) { | |
var current = Game.cookies; | |
var cps = Game.cookiesPs; | |
var price = this.target.price; | |
var amount = this.target.amount; | |
if (current < price) { | |
return false; | |
} | |
if (amount === this.max) { | |
return false; | |
} | |
if (buyOne) { | |
if (amount === 0) { | |
var id = this.id; | |
if (Hack.phase < id) { | |
Hack.phase = id; | |
Hack.timestamp[id] = (new Date()).getTime(); | |
var lap = (function() { | |
for (var i = id - 1; i >= 0; i++) { | |
var t = Hack.timestamp[i]; | |
if (0 < t) { | |
return Math.ceil((Hack.timestamp[id] - t) / 1000); | |
} | |
} | |
return 0; | |
})(); | |
console.log("LAP: " + lap); | |
console.log("Phase " + id + " started."); | |
} | |
return true; | |
} | |
if (Hack.phase === this.id && amount < this.preMax) { | |
return true; | |
} | |
if (amount === 49 || amount === 99 || amount === 149 || amount === 199 || amount === 249 || amount === 399) { | |
return true; | |
} | |
} else if (this.max < amount + 10) { | |
return false; | |
} | |
var ratio = (Game.frenzy ? Game.frenzyPower : 1) * (buyOne ? 1 : 20); | |
if (price * ratio < cps) { | |
return true; | |
} | |
if (this.prev !== null && price < this.prev.price) { | |
return true; | |
} | |
return false; | |
}; | |
var productList = [ | |
new Product({id : 0, max : 400, preMax : 1}), // Cursor | |
new Product({id : 1, max : 250, preMax : 3}), // Grandma | |
new Product({id : 2, max : 200, preMax : 3}), // Farm | |
new Product({id : 3, max : 200, preMax : 3}), // Factory | |
new Product({id : 4, max : 200, preMax : 3}), // Mine | |
new Product({id : 5, max : 200, preMax : 3}), // Shipment | |
new Product({id : 6, max : 200, preMax : 4}), // Alchemy lab | |
new Product({id : 7, max : 200, preMax : 8}), // Portal | |
new Product({id : 8, max : 200, preMax : 6}), // Time machine | |
new Product({id : 9, max : 200, preMax : 2}), // Antimatter condenser | |
new Product({id : 10, max : 200, preMax : 2}) // Prism | |
]; | |
// | |
// UPGRADE | |
// | |
var upgradeNG = [69, 74, 84, 85, 91, 181, 182, 183, 184, 185, 209, 227]; // Grandma hazard (74: Elder Pledge), cheats, seasonal events, Chocolate egg | |
var upgradeOK = [32, 54, 108, 187, 176, 177, 178, 179, 201, 129, 130, 131, 132, 133]; // Kittens, Prism twice upgrades, HC performance | |
var upgrade = function(upgrade) { | |
var current = Game.cookies; | |
var cps = Game.cookiesPs; | |
var price = upgrade.getPrice(); | |
var id = upgrade.id; | |
if (current < price) { | |
return false; | |
} | |
if (productList[0].target.amount === 0) { | |
return false; | |
} | |
if (upgradeNG.indexOf(id) !== -1) { | |
return false; | |
} | |
if (upgradeOK.indexOf(id) !== -1) { | |
upgrade.buy(); | |
return true; | |
} | |
if (Game.UpgradesById[108].bought && price < Game.ObjectsById[10].price) { | |
upgrade.buy(); | |
return true; | |
} | |
if (Game.UpgradesById[187].bought) { | |
upgrade.buy(); | |
return true; | |
} | |
var ratio = Game.frenzy ? Game.frenzyPower : 1; | |
if (upgrade.getPrice() * ratio < cps * 10.0) { | |
upgrade.buy(); | |
return true; | |
} | |
return false; | |
}; | |
// ADJUSTING | |
var adjustProducts = function() { | |
productList[10].preMax = (function() { | |
var cookies = Game.cookies; | |
if (cookies > Math.pow(2, 72) * 107) return 200; | |
for (var i = 0; i < 4; i++) { | |
var powIndex = 78 - 2 * i; | |
if (cookies > Math.pow(2, powIndex)) return (190 - i * 10); | |
} | |
if (Game.UpgradesById[187].bought) return 150; | |
if (Game.UpgradesById[108].bought) return 100; | |
if (Game.UpgradesById[54].bought) return 50; | |
if (Game.UpgradesById[101].bought) return 25; | |
if (Game.UpgradesById[100].bought) return 16; | |
if (Game.UpgradesById[32].bought) return 10; | |
return 2; | |
})(); | |
}; | |
// Detecting if Elder Pledge should be bought | |
var checkFullWrinklers = function() { | |
var wrinklersCount = 0; | |
for (var i = 0; i < Game.wrinklers.length; i++) { | |
if (Game.wrinklers[i].phase > 1) { | |
wrinklersCount++; | |
} | |
} | |
return (4 < wrinklersCount); | |
}; | |
// | |
// INITIAL SETTINGS | |
// | |
var initialize = function() { | |
Hack.phase = (function() { | |
for (var i in productList) { | |
var target = productList[i].target; | |
if (target.amount === 0) { | |
return (0 < i) ? i - 1 : 0; | |
} | |
} | |
return 10; // All your products are belong to us | |
})(); | |
Hack.timestamp[Hack.phase] = (new Date()).getTime(); | |
adjustProducts(); | |
Game.Win("Third-party"); | |
console.log("Phase " + Hack.phase + " started."); | |
}; | |
// | |
// AUTOMATION | |
// | |
Hack.buyClick = setInterval(function() { | |
for (var j in Game.UpgradesInStore) { | |
if (upgrade(Game.UpgradesInStore[j])) { | |
adjustProducts(); | |
return; | |
} | |
} | |
for (var i = 10; i >= 0; i--) { | |
if (productList[i].add()) { | |
return; | |
} | |
} | |
var oneMind = Game.UpgradesById[69]; | |
var elderPledge = Game.UpgradesById[74]; | |
var seasonSwitcher = Game.UpgradesById[181]; | |
var christmas = Game.UpgradesById[182]; | |
var valentines = Game.UpgradesById[184]; | |
var easter = Game.UpgradesById[209]; | |
var halloween = Game.UpgradesById[183]; | |
var currentSeason = Game.season; | |
var hasAllEggs = Hack.hasAllEggs(); | |
var hasAllHalloweens = Hack.hasAllHalloweens(); | |
var hasAllHearts = Hack.hasAllHearts(); | |
if (oneMind.unlocked && !oneMind.bought) { | |
Hack.buyOneMind(oneMind); | |
} | |
if (hasAllEggs && hasAllHalloweens) { | |
elderPledge.buy(); | |
} | |
if (checkFullWrinklers() && Game.UpgradesInStore.indexOf(elderPledge) > -1 && elderPledge.getPrice() < Game.cookies) { | |
elderPledge.buy(); | |
} | |
if (!seasonSwitcher.bought && Game.UpgradesById[108].bought) { | |
seasonSwitcher.buy(); | |
} | |
// Season switching | |
if (!hasAllHearts) { | |
if (currentSeason !== "valentines") { | |
valentines.buy(); | |
} | |
return; | |
} | |
if (Game.santaLevel < 14) { | |
if (currentSeason !== "christmas") { | |
christmas.buy(); | |
} | |
return; | |
} | |
if (!hasAllEggs) { | |
if (currentSeason !== "easter") { | |
easter.buy(); | |
} | |
return; | |
} | |
if (!hasAllHalloweens) { | |
if (currentSeason !== "halloween") { | |
halloween.buy(); | |
} | |
return; | |
} | |
if (currentSeason !== "christmas" && hasAllEggs && hasAllHalloweens && hasAllHearts) { | |
christmas.buy(); | |
} | |
}, 1000); | |
Hack.adjustMax = setInterval(adjustProducts, 600000); | |
Hack.hasAllEggs = function() { | |
for (var i = 210; i <= 229; i++) { | |
if (Game.UpgradesById[i].unlocked === 0) { | |
return false; | |
} | |
} | |
return true; | |
}; | |
Hack.hasAllHalloweens = function() { | |
for (var i = 134; i <= 140; i++) { | |
if (Game.UpgradesById[i].unlocked === 0) { | |
return false; | |
} | |
} | |
return true; | |
}; | |
Hack.hasAllHearts = function() { | |
for (var i = 169; i <= 174; i++) { | |
if (Game.UpgradesById[i].unlocked === 0) { | |
return false; | |
} | |
} | |
return true; | |
}; | |
Hack.buyOneMind = function(oneMind) { | |
oneMind.buy(); | |
setTimeout(function() { $("#promptOption0").click(); }, 3000); | |
}; | |
Hack.reset = function() { | |
(function() { | |
var chocolateEgg = Game.UpgradesById[227]; | |
if (Game.UpgradesInStore.indexOf(chocolateEgg) !== -1 && chocolateEgg.getPrice() < Game.cookies) { | |
chocolateEgg.buy(); | |
} | |
})(); | |
setTimeout(function() { if ($("a.option.warning:first-child") === null) $("#prefsButton").click(); }, 1000); | |
setTimeout(function() { $("a.option.warning:first-child").click(); }, 1000); | |
setTimeout(function() { $("#promptOption0").click(); initialize(); }, 3000); | |
}; | |
initialize(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment