From b1c847757d42de26be2a7fe4119caa261b6ccf2b Mon Sep 17 00:00:00 2001 From: Mtarnuhal Date: Thu, 22 Oct 2020 11:26:19 +0200 Subject: [PATCH 1/2] autoGodzamok, autoSL & autoRigidel (#45) * Fix #18 autoSL + autoRigidel Seems Auto harvest, and auto rigidel+harvest attempt to harvest a sugar lump just a teensy bit before it's actually ripe, therefore botching the harvest in half the cases. Game.timetoRipe returns a float number in some cases, so adding Math.ceil to the Game.timeToRipe in the equations should give it just enough leeway to make sure it computes the correct millisecond. (It's my theory anyway. The math seemed to have come out ok when I paper tested). With thnx to @Darkroman * autoGodzamok Sane & Insane option restored Attempt to restore the autoGodzamok Sane and Insane options. Has to be tested to make sure everything behaves as it should. * Update frozen_cookies.js * Attempt fix autoGodzamok Sane and Insane Second try And some minor changes to make it more efficient. * safeBuy safeBuy instead of visually change the buy-sell option. Changing the variable should be enough. * Attempt fix autoGodzamok Sane and Insane Third try Preventing the sell of cursors and farms while Devastation is active. * Finalizing autoGodzamok finalizing autoGodzamok * Update Version 1.8.1 * Simplifying autoGodzamok simplified autoGodzamok. - If AutoGodz is on and a click buff is active, but Devastation is NOT active: - sell the cursors and farms - if autoBuy is turned on, the user has already signaled their intent to have things purchased for them, so rebuy what you sold (up to the limit if any limit is set). - Otherwise, don't rebuy anything. * Remove unnecessary autoGodzamok preference Removed Sane and Insane mode from autoGodzamok cause they were removed. * autoGodzamok Reversed variables Reversed the variables of buy back * autoGodzamok wrong parameter Used the wrong parameter * autoGodzamok extra check Extra check if the limit doesn't exceed the current buildings. * autoGodzamok Forgot to add -1 to the buyback of farms --- fc_main.js | 66 ++++++++++++++++++++++++----------------------- fc_preferences.js | 4 +-- frozen_cookies.js | 2 +- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/fc_main.js b/fc_main.js index 5db40868..a14d68ac 100644 --- a/fc_main.js +++ b/fc_main.js @@ -623,7 +623,7 @@ function swapIn(godId, targetSlot) { //mostly code copied from minigamePantheon. function autoRigidel() { if (!T) return; //Exit if pantheon doesnt even exist - var timeToRipe = (Game.lumpRipeAge - (Date.now() - Game.lumpT))/60000; //Minutes until sugar lump ripens + var timeToRipe = (Math.ceil(Game.lumpRipeAge) - (Date.now() - Game.lumpT))/60000; //Minutes until sugar lump ripens var orderLvl = Game.hasGod('order') ? Game.hasGod('order') : 0; switch (orderLvl) { case 0: //Rigidel isn't in a slot @@ -2170,43 +2170,45 @@ function autoGSBuy() { function safeBuy(bldg,count) { // If store is in Sell mode, Game.Objects[].buy will sell the building! - if (Game.buyMode == -1) - { - document.getElementById('storeBulkBuy').click(); + if (Game.buyMode == -1) { + Game.buyMode = 1; bldg.buy(count); - document.getElementById('storeBulkSell').click(); + Game.buyMode = -1 } else { bldg.buy(count); } } -function autoGodzamokAction() -{ - if (!T) return; //Just leave if Pantheon isn't here yet - //Now has option to not trigger until current Devastation buff expires (i.e. won't rapidly buy & sell cursors throughout Godzamok duration) - //added Farms to autoGodzamok selling. 1 farm always left to prevent garden from disappearing - if (Game.hasGod('ruin') && (!Game.hasBuff('Devastation')) && hasClickBuff()) - { - if ((FrozenCookies.autoGodzamok >= 1) && Game.Objects['Cursor'].amount >= 10) - { - var count = Game.Objects['Cursor'].amount; - Game.Objects['Cursor'].sell(count); +function autoGodzamokAction() { + if ( T && FrozenCookies.autoGodzamok ) { // if Pantheon is here and autoGodzamok is set + if ( Game.hasGod('ruin') && ( Game.Objects['Cursor'].amount > 10 || Game.Objects['Farm'].amount > 10 ) ) { + var countC = Game.Objects['Cursor'].amount; + var countF = Game.Objects['Farm'].amount-1; + + //Automatically sell all cursors and farms (except one) during Dragonflight and Click Frenzy if you worship Godzamok and prevent rapid buy/sell spam + if ( ( FrozenCookies.autoGodzamok >= 1 ) && hasClickBuff() && !Game.hasBuff('Devastation') ) { + Game.Objects['Cursor'].sell( countC ); + Game.Objects['Farm'].sell( countF ); + + if ( FrozenCookies.autoBuy == 1 ) { + if ( ( FrozenCookies.cursorLimit ) && countC > FrozenCookies.cursorMax ) { + safeBuy( Game.Objects['Cursor'], FrozenCookies.cursorMax ); + logEvent( "AutoGodzamok", "Bought " + FrozenCookies.cursorMax + " cursors" ); + } else { + safeBuy( Game.Objects['Cursor'], countC ); + logEvent( "AutoGodzamok", "Bought " + countC + " cursors" ); + } + if ( ( FrozenCookies.farmLimit ) && countF > ( FrozenCookies.farmMax - 1 ) ) { + safeBuy( Game.Objects['Farm'], FrozenCookies.farmMax - 1 ); + logEvent( "AutoGodzamok", "Bought " + ( FrozenCookies.farmMax - 1 ) + " farms" ); + } else { + safeBuy( Game.Objects['Farm'], countF ); + logEvent( "AutoGodzamok", "Bought " + countF + " farms" ); + } + } + } } - if ((FrozenCookies.autoGodzamok >= 1) && Game.Objects['Farm'].amount >= 10) - { - var count2 = Game.Objects['Farm'].amount-1; - Game.Objects['Farm'].sell(count2); - } - - if ((FrozenCookies.autoGodzamok >= 1) && Game.Objects['Cursor'].amount < 10) - { - safeBuy(Game.Objects['Cursor'],count); - } - if ((FrozenCookies.autoGodzamok >= 1) && Game.Objects['Farm'].amount < 10) - { - safeBuy(Game.Objects['Farm'],count2); - } - } + } } function goldenCookieLife() { @@ -2259,7 +2261,7 @@ function autoCookie() { } if (FrozenCookies.autoSL) { var started = Game.lumpT; - var ripeAge = Game.lumpRipeAge; + var ripeAge = Math.ceil(Game.lumpRipeAge); if ((Date.now() - started) >= ripeAge) { Game.clickLump(); } diff --git a/fc_preferences.js b/fc_preferences.js index 208975af..ca2cc2be 100644 --- a/fc_preferences.js +++ b/fc_preferences.js @@ -106,8 +106,8 @@ FrozenCookies.preferenceValues = { 'default': 0 }, 'autoGodzamok': { - 'hint': 'Automatically sell all cursors and farms (except one) during Dragonflight and Click Frenzy if you worship Godzamok ("Sane" prevents rapid buy/sell spam)', - 'display': ['Auto-Godzamok OFF', 'Auto-Godzamok ON', 'Auto-Godzamok ON (Sane)', 'Auto-Godzamok ON (REALLY INSANE)'], + 'hint': 'Automatically sell all cursors and farms (except one farm) during Dragonflight and Click Frenzy if you worship Godzamok and prevents rapid buy/sell spam', + 'display': ['Auto-Godzamok OFF', 'Auto-Godzamok ON'], 'default': 0 }, 'autoSpell': { diff --git a/frozen_cookies.js b/frozen_cookies.js index b6d363e4..ab89827b 100644 --- a/frozen_cookies.js +++ b/frozen_cookies.js @@ -8,7 +8,7 @@ var baseUrl = scriptElement !== null ? var FrozenCookies = { 'baseUrl': baseUrl, 'branch': '', - 'version': '1.8.0' + 'version': '1.8.1' }; // Load external libraries From ce37c76fe4a39a0c065818962f42294d1d6b551f Mon Sep 17 00:00:00 2001 From: Aaron Wright Date: Thu, 22 Oct 2020 03:28:23 -0600 Subject: [PATCH 2/2] show current buff value on Devastation tooltip (#46) --- fc_main.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fc_main.js b/fc_main.js index a14d68ac..852c49ae 100644 --- a/fc_main.js +++ b/fc_main.js @@ -102,7 +102,8 @@ function setOverrides() { Game.sayTime = function(time, detail) { return timeDisplay(time / Game.fps); } - Game.oldReset = Game.Reset; + Game.tooltip.oldDraw = Game.tooltip.draw; + Game.tooltip.draw = fcDraw; Game.oldReset = Game.Reset; Game.oldWriteSave = Game.WriteSave; Game.oldLoadSave = Game.LoadSave; Game.Reset = fcReset; @@ -299,6 +300,15 @@ function timeDisplay(seconds) { return (days + hours + minutes + seconds).trim(); } +function fcDraw(from, text, origin) { + if (typeof(text) == "string") { + if (text.includes('Devastation')) { + text = text.replace(/\+\d+\%/,"+" + Math.round((Game.hasBuff('Devastation').multClick - 1) * 100) + "%") + } + } + Game.tooltip.oldDraw(from, text, origin); +} + function fcReset() { Game.CollectWrinklers(); if (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')) {