From 630263a487912fda2edb02aebc9dad0949824442 Mon Sep 17 00:00:00 2001 From: gen BTC Date: Wed, 28 Mar 2018 11:49:54 -0400 Subject: [PATCH] Merged buttons into multitoggles, added Autostance3+Windstack feature, changes to Swiffy's overlay #150 REFIX AutoGolden UpGrades. Lot of whitespace cleanup. # Conflicts: # .user.js # AutoTrimps2.js # SettingsGUI.js # modules/fight-info.js # user.js --- AutoTrimps2.js | 2 +- Graphs.js | 22 +++++++++++++++------- SettingsGUI.js | 5 ++++- modules/battlecalc.js | 10 +++++----- modules/breedtimer.js | 12 ++++++------ modules/buildings.js | 2 +- modules/client-server.js | 18 +++++++++--------- modules/dynprestige.js | 2 +- modules/fight-info.js | 2 +- modules/fight.js | 4 ++-- modules/import-export.js | 4 ++-- modules/maps.js | 2 +- modules/other.js | 13 ++++++++----- modules/performance.js | 4 ++-- modules/perks.js | 2 +- modules/utils.js | 6 +++--- 16 files changed, 62 insertions(+), 48 deletions(-) diff --git a/AutoTrimps2.js b/AutoTrimps2.js index 1f65eadc8..f89cc3a7f 100644 --- a/AutoTrimps2.js +++ b/AutoTrimps2.js @@ -8,7 +8,7 @@ // @include *kongregate.com/games/GreenSatellite/trimps // @grant none // ==/UserScript== -var ATversion = '2.1.6.9-genbtc-3-23-2018'; +var ATversion = '2.1.6.9-genbtc-3-23-2018 + KFrowde-28-3-18'; //////////////////////////////////////////////////////////////////////////////// //Main Loader Initialize Function (loads first, load everything else)/////////// diff --git a/Graphs.js b/Graphs.js index ac398a8b0..712f412e1 100644 --- a/Graphs.js +++ b/Graphs.js @@ -95,7 +95,7 @@ function removeDarkGraphs() { document.head.removeChild($link); debug("Removing dark-graph.css file","graphs"); } -function toggleDarkGraphs() { +function toggleDarkGraphs() { if (game) { var $link = document.getElementById("dark-graph.css"); var blackCB = document.getElementById('blackCB').checked; @@ -108,9 +108,9 @@ function toggleDarkGraphs() { //Runs once on startup to color the graph footer elements Black. //Then every time the theme is changed. Called out of updateCustomButtons() loop in SettingsGUI. var lastTheme=-1; -MODULES["graphs"].themeChanged = function() { +MODULES["graphs"].themeChanged = function() { //Everything else in Settings, (for now: all Inputs, Dropdowns) - if (game && game.options.menu.darkTheme.enabled != lastTheme) { + if (game && game.options.menu.darkTheme.enabled != lastTheme) { //GRAPHS: toggleDarkGraphs(); debug("Theme change - AutoTrimps styles updating..."); @@ -313,7 +313,7 @@ function autoToggleGraph() { var $item = document.getElementById('autoTrimpsTabBarMenu'); if ($item) { if ($item.style.display === 'block') $item.style.display = 'none'; - } + } var $graph = document.getElementById('graphParent'); if ($graph.style.display === 'block') $graph.style.display = 'none'; else { @@ -335,7 +335,7 @@ function escapeATWindows() { var $item = document.getElementById('autoTrimpsTabBarMenu'); if ($item.style.display === 'block') $item.style.display = 'none'; var $graph = document.getElementById('graphParent'); - if ($graph.style.display === 'block') $graph.style.display = 'none'; + if ($graph.style.display === 'block') $graph.style.display = 'none'; } document.addEventListener("keydown",function (event) { //Hotkeys have to be enabled, and all these conditions have to be met or else we cant use the hotkey. @@ -381,7 +381,7 @@ function pushData() { magmite: game.global.magmite, magmamancers: game.jobs.Magmamancer.owned, fluffy: game.global.fluffyExp, - nursery: game.buildings.Nursery.purchased + nursery: game.buildings.Nursery.purchased }); //only keep 15 portals worth of runs to prevent filling storage clearData(15); @@ -572,7 +572,7 @@ function drawGraph(minus,plus) { if ($item.selectedIndex < 0) $item.selectedIndex = 0; } - else if (plus) { + else if (plus) { if ($item.selectedIndex != ($item.options.length-1)) $item.selectedIndex++; } @@ -1036,6 +1036,14 @@ function setGraphData(graph) { loop--; } }*/ + if (currentZone != allSaveData[i].world - 1) { + //console.log(allSaveData[i].totalPortals + " / " + allSaveData[i].world); + var loop = allSaveData[i].world - 1 - currentZone; + while (loop > 0) { + graphData[graphData.length - 1].data.push(allSaveData[i-1][item]*1); + loop--; + } + } //write datapoint (one of 3 ways) if (currentZone != 0) { graphData[graphData.length - 1].data.push(Math.floor((allSaveData[i].fluffy - startFluffy) / ((allSaveData[i].currentTime - allSaveData[i].portalTime) / 3600000))); diff --git a/SettingsGUI.js b/SettingsGUI.js index bad10d3a1..c1df15ad4 100644 --- a/SettingsGUI.js +++ b/SettingsGUI.js @@ -451,6 +451,7 @@ function initializeAllSettings() { document.getElementById('battleSideTitle').setAttribute('onclick','MODULES["performance"].EnableAFKMode()'); document.getElementById('battleSideTitle').setAttribute('onmouseover', "getZoneStats(event);this.style.cursor='pointer'"); createSetting('ChangeLog', 'Show Changelog', '(Action Button). Shows the changelog popup message that AT loads on startup again, in case you missed it. The blue color means this is not a settable setting, just a button.', 'action', 'printChangelog()', null, 'Display'); + createSetting('ShowSettings', 'Show Extra Settings', 'Show/Hide settings that are rarely useful', 'boolean', false, null, 'Display') document.getElementById('Display').lastChild.insertAdjacentHTML('afterend','
'); //SPAM settings: @@ -823,10 +824,12 @@ function updateCustomButtons() { //if HeHr is not selected, remove HeHr buffer settingsbox (heHr) ? turnOn("HeliumHrBuffer") : turnOff("HeliumHrBuffer"); //if ShieldBlock is for sure, remove ShieldBlock from settingsbox (achievement=12 means z100). - (game.achievements.zones.finished < 12) ? turnOn("BuyShieldblock") : function(){turnOff("BuyShieldblock");setPageSetting("BuyShieldblock",false);}(); + //(game.achievements.zones.finished < 12) ? turnOn("BuyShieldblock") : function(){turnOff("BuyShieldblock");setPageSetting("BuyShieldblock",false);}(); //if AS3 is not selected, remove Windstack settingsbox getPageSetting('AutoStance')==3 ? turnOn("WindStacking") : turnOff("WindStacking"); getPageSetting('AutoStance')!=3 ? turnOn("IgnoreCrits") : turnOff("IgnoreCrits"); + //Show and Hide useless settings to reduce UI clutter + getPageSetting('ShowSettings') ? (turnOn("ManualGather2"), turnOn("BuyUpgrades"), turnOn("ManualCoords"), turnOn("AutoEggs"), turnOn("UsePatience"), turnOn("TrapTrimps"), turnOn("GymWall"), turnOn("WarpstationWall3"), turnOn("TrainerCaptoTributes")) : (turnOff("ManualGather2"), turnOff("BuyUpgrades"), turnOn("ManualCoords"), turnOff("AutoEggs"), turnOff("UsePatience"), turnOff("TrapTrimps"), turnOff("GymWall"), turnOff("WarpstationWall3"), turnOff("TrainerCaptoTributes")); //DROPDOWNS: updates dropdown selections. (ALL DROPDOWNS REQUIRE THIS BIT TO BE UPDATEY) //todo check why this isnt possible to set automatically in the dropdown code. diff --git a/modules/battlecalc.js b/modules/battlecalc.js index 5aa6e07cd..c365db94c 100644 --- a/modules/battlecalc.js +++ b/modules/battlecalc.js @@ -122,7 +122,7 @@ function getBattleStats(what,form,crit) { } if (what == "attack" && game.global.challengeActive == "Life"){ currentCalc *= game.challenges.Life.getHealthMult(); - } + } if (what == "health" && game.global.challengeActive == "Balance"){ currentCalc *= game.challenges.Balance.getHealthMult(); } @@ -196,8 +196,8 @@ function getBattleStats(what,form,crit) { //Pumpkimp buff if (game.global.sugarRush > 0 && what == "attack"){ currentCalc *= sugarRush.getAttackStrength(); - textString += "Sugar Rush  x " + sugarRush.getAttackStrength() + "" + prettify(currentCalc) + "" + ((what == "attack") ? getFluctuation(currentCalc, minFluct, maxFluct) : "") + ""; - } + textString += "Sugar Rush  x " + sugarRush.getAttackStrength() + "" + prettify(currentCalc) + "" + ((what == "attack") ? getFluctuation(currentCalc, minFluct, maxFluct) : "") + ""; + } //Magma if (mutations.Magma.active() && (what == "attack" || what == "health")){ var mult = mutations.Magma.getTrimpDecay(); @@ -217,8 +217,8 @@ function getBattleStats(what,form,crit) { //Fluffy if (what == "attack" && Fluffy.isActive()){ var amt = Fluffy.getDamageModifier(); - currentCalc *= amt; - } + currentCalc *= amt; + } if (crit) { var critChance = getPlayerCritChance(); if (what == "attack" && critChance){ diff --git a/modules/breedtimer.js b/modules/breedtimer.js index 079f065ab..25ebb0dc8 100644 --- a/modules/breedtimer.js +++ b/modules/breedtimer.js @@ -58,9 +58,9 @@ function controlGeneticistassist(targetTime) { if (hasGA) { //The targetTime GA setting has to match one in the list. [use the last slot] game.global.GeneticistassistSetting = targetTime; - game.global.GeneticistassistSteps = [-1,10,30,targetTime]; + game.global.GeneticistassistSteps = [-1,10,30,targetTime]; toggleGeneticistassist(true); //true means updateOnly - } + } } //controlGeneticistassist(45); @@ -72,7 +72,7 @@ function autoBreedTimer() { var defaultBreedTimer = game.talents.patience.purchased && getPageSetting('UsePatience') ? 45 : 30; var targetBreed = getPageSetting('GeneticistTimer'); var newGeneTimerSetting=0; -//TIMER MANAGEMENT SECTION: +//TIMER MANAGEMENT SECTION: var manageBreedTimer = getPageSetting('ManageBreedtimer'); if (manageBreedTimer) { if(game.portal.Anticipation.level == 0) newGeneTimerSetting = 0; @@ -86,7 +86,7 @@ function autoBreedTimer() { } else if (getPageSetting('SpireBreedTimer') > -1 && isActiveSpireAT()) newGeneTimerSetting = getPageSetting('SpireBreedTimer'); - else + else newGeneTimerSetting = defaultBreedTimer; if (newGeneTimerSetting != targetBreed) { setPageSetting('GeneticistTimer',newGeneTimerSetting); @@ -117,9 +117,9 @@ function autoBreedTimer() { boughtGenRound1 = true; } } -//FIRING SECTION: +//FIRING SECTION: var time = getBreedTime(); - var timeLeft = getBreedTime(true); + var timeLeft = getBreedTime(true); var fire1 = targetBreed*1.02 < time; var fire2 = targetBreed*1.02 < timeLeft; var fireobj = fire1 ? time : timeLeft; diff --git a/modules/buildings.js b/modules/buildings.js index d9f465bca..79ab89e13 100644 --- a/modules/buildings.js +++ b/modules/buildings.js @@ -234,7 +234,7 @@ function buyBuildings() { //Activate dynamic Nurseries to buy nurseries from NoNurseriesUntilZone up to portal before zone. function dynamicNurseries() { var maxNursery = getPageSetting('MaxNursery'); - var finalZone = getPageSetting('HeHrDontPortalBefore') + var finalZone = getPageSetting('HeHrDontPortalBefore') var numZ = finalZone - nursminlvl; var perZ = maxNursery / ((numZ / 10 + 1)); return perZ; diff --git a/modules/client-server.js b/modules/client-server.js index ff271df24..988cd7ef1 100644 --- a/modules/client-server.js +++ b/modules/client-server.js @@ -8,7 +8,7 @@ //The ATServer{} object has 3 commands: GetID(), SaveData(), Upload() //All Data is uncompressed, unencrypted, plaintext for clarity. No private info is leaked. -var ATServer = +var ATServer = { //SERVER_IP: '207.246.77.188', SERVER_HOSTNAME: 'https://autotrimps.site/ATendpoint.php' @@ -18,9 +18,9 @@ ATServer.GetID = function(callback) { var req = new XMLHttpRequest(); - req.onreadystatechange = function() + req.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) + if (this.readyState == 4 && this.status == 200) { callback(JSON.parse(req.responseText).data.id); } @@ -35,9 +35,9 @@ ATServer.SaveData = function(id, data, callback) { var req = new XMLHttpRequest(); - req.onreadystatechange = function() + req.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) + if (this.readyState == 4 && this.status == 200) { callback(JSON.parse(req.responseText)); } @@ -51,12 +51,12 @@ ATServer.SaveData = function(id, data, callback) ATServer.Upload = function(data) { - ATServer.GetID(function(id) - { + ATServer.GetID(function(id) + { autoTrimpSettings.analyticsID = autoTrimpSettings.analyticsID || id; //debug("Server generated ID: " + autoTrimpSettings.analyticsID, "other"); - ATServer.SaveData(autoTrimpSettings.analyticsID, data, function(response) - { + ATServer.SaveData(autoTrimpSettings.analyticsID, data, function(response) + { debug("Submitted analytics data w/ ID: " + autoTrimpSettings.analyticsID, "other"); }); }); diff --git a/modules/dynprestige.js b/modules/dynprestige.js index 2759cd0b1..96f109d82 100644 --- a/modules/dynprestige.js +++ b/modules/dynprestige.js @@ -61,4 +61,4 @@ function prestigeChanging2(){ //If we are not in the prestige farming zone (the beginning of the run), use dagger: if (game.global.world <= lastzone-zonesToFarm || game.global.mapBonus == 10) autoTrimpSettings.Prestige.selected = "Dagadder"; -} \ No newline at end of file +} diff --git a/modules/fight-info.js b/modules/fight-info.js index 91753a17c..8923b769b 100644 --- a/modules/fight-info.js +++ b/modules/fight-info.js @@ -123,7 +123,7 @@ //$cell.style.color = M["fightinfo"].colors.powerful; //(This changes the colour of the glyph - bad bc it overrides trimps and looks bad against corruption etc) $cell.style.textShadow = '0px 0px 10px #8c0000'; } - + //This shit doesn't work and I don't know why (What is the celltitle??? is it the name of the nature? Imps are labelled Toxic/Gusty/Frozen but that didin't work either) if(cell.name.toLowerCase().indexOf('poison') > -1) // Poison Token cell { diff --git a/modules/fight.js b/modules/fight.js index c4a1db78a..4368395ea 100644 --- a/modules/fight.js +++ b/modules/fight.js @@ -6,13 +6,13 @@ MODULES["fight"].enableDebug = true; //controls whether betterAutoFight2 is S //selector function, called from main. var BAFsetting, oldBAFsetting; -function ATselectAutoFight() { +function ATselectAutoFight() { BAFsetting = getPageSetting('BetterAutoFight'); if (BAFsetting==1) betterAutoFight(); //"Better Auto Fight" (autofight.js) else if (BAFsetting==2) betterAutoFight2(); //"Better Auto Fight2" (") else if (BAFsetting==0 && BAFsetting!=oldBAFsetting && game.global.autoBattle && game.global.pauseFight) pauseFight(); //turn on autofight on once when BAF is toggled off. else if (BAFsetting==0 && game.global.world == 1 && game.global.autoBattle && game.global.pauseFight) pauseFight(); //turn on autofight on lvl 1 if its off. - else if (BAFsetting==0 && !game.global.autoBattle && game.global.soldierHealth == 0) betterAutoFight(); //use BAF as a backup for pre-Battle situations + else if (BAFsetting==0 && !game.global.autoBattle && game.global.soldierHealth == 0) betterAutoFight(); //use BAF as a backup for pre-Battle situations oldBAFsetting = BAFsetting; //enables built-in autofight once when disabled } diff --git a/modules/import-export.js b/modules/import-export.js index fdccacec3..9dd9566d2 100644 --- a/modules/import-export.js +++ b/modules/import-export.js @@ -42,7 +42,7 @@ settingsProfileMakeGUI(); //This switches into the new profile when the dropdown is selected. //it is the "onchange" handler of the settingsProfiles dropdown -//Asks them do a confirmation check tooltip first. The +//Asks them do a confirmation check tooltip first. The function settingsProfileDropdownHandler() { if ($settingsProfiles == null) return; var index = $settingsProfiles.selectedIndex; @@ -398,4 +398,4 @@ function resetModuleVars(imported) { ATrunning = true; //restart AT. } setTimeout(waitRemoveLoad(imported),101); -} \ No newline at end of file +} diff --git a/modules/maps.js b/modules/maps.js index e407ebb88..387fec346 100644 --- a/modules/maps.js +++ b/modules/maps.js @@ -346,7 +346,7 @@ function autoMap() { vanillaMapatZone = (game.options.menu.mapAtZone.enabled && game.options.menu.mapAtZone.setZone == game.global.world); if (vanillaMapatZone) shouldDoMaps = true; - + //Dynamic Siphonology section (when necessary) //Lower Farming Zone = Lowers the zone used during Farming mode. Starts 10 zones below current and Finds the minimum map level you can successfully one-shot diff --git a/modules/other.js b/modules/other.js index 646cf2b1c..b5134de4b 100644 --- a/modules/other.js +++ b/modules/other.js @@ -22,6 +22,10 @@ function autoRoboTrimp() { function autoGoldenUpgradesAT(setting) { var num = getAvailableGoldenUpgrades(); if (num == 0) return; //if we have nothing to buy, exit. + //Challenge^2 cant Get/Buy Helium, so adapt - do Derskagg mod. + var challSQ = game.global.runningChallengeSquared; + if (setting == ("Helium" || "Void") && ChallSQ) + buyGoldenUpgrade("Battle"); //Try to achieve 60% Void //Default: True = Always get 60% void by skipping the 12% upgrade then buying 14%/16% var goldStrat = getPageSetting('goldStrat'); @@ -32,11 +36,10 @@ function autoGoldenUpgradesAT(setting) { } //buy one upgrade per loop. var success = buyGoldenUpgrade(setting); - //Challenge^2 cant Get/Buy Helium, so adapt - do Derskagg mod. - var challSQ = game.global.runningChallengeSquared; + var doDerskaggChallSQ = false; - if (setting == "Helium" && challSQ && !success) - doDerskaggChallSQ = true; + if (setting == ("Helium" || "Void") && challSQ) + {doDerskaggChallSQ = true; setting = (challSQ) ? "Battle" : "Helium"} // DZUGAVILI MOD - SMART VOID GUs // Assumption: buyGoldenUpgrades is not an asynchronous operation and resolves completely in function execution. // Assumption: "Locking" game option is not set or does not prevent buying Golden Void @@ -53,7 +56,7 @@ function autoGoldenUpgradesAT(setting) { var goldZone = getPageSetting('goldZone'); setting = (game.global.world <= goldZone || noBat) ? "Helium" : "Battle"; } else if (goldStrat == "Max then Helium") { - setting = "Helium"; + setting = (challSQ) ? "Battle" : "Helium"; } else setting = (challSQ) ? "Battle" : "Helium"; buyGoldenUpgrade(setting); diff --git a/modules/performance.js b/modules/performance.js index 4698c3298..79661e2de 100644 --- a/modules/performance.js +++ b/modules/performance.js @@ -11,7 +11,7 @@ // AFK OVERLAY CSS Style document.head.appendChild(document.createElement('style')).innerHTML = ` - .at-afk-overlay + .at-afk-overlay { position: absolute; left: 0px; @@ -116,7 +116,7 @@ M["performance"].AFKOverlay.appendChild(M["performance"].AFKOverlayHelium); M["performance"].AFKOverlay.appendChild(M["performance"].AFKOverlayStatus); M["performance"].AFKOverlay.appendChild(M["performance"].AFKOverlayDisable); - + // Insert the afk page, at the top level tag document.body.appendChild(M["performance"].AFKOverlay); diff --git a/modules/perks.js b/modules/perks.js index 8f531a15b..90dc3e876 100644 --- a/modules/perks.js +++ b/modules/perks.js @@ -497,7 +497,7 @@ AutoPerks.FixedPerk = function(name, base, level, max, fluffy) { this.max = max || Number.MAX_VALUE; if (fluffy == "fluffy") { //This affects cost calculation on "Capable" fixed perk (during line 273) - this.fluffy = true; + this.fluffy = true; this.type = "linear"; this.increase = 10; } diff --git a/modules/utils.js b/modules/utils.js index e0a66c36b..3eb6335ba 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -44,7 +44,7 @@ function safeSetItems(name,data) { function versionIsOlder(old, testcase) { var oldVer = parseVersion(old); var testVer = parseVersion(testcase); - + if (oldVer.length == 0) return true; //compare major to minor numbers, if older it's older, if newer it's not for (var i=0; i < oldVer.length; i++) { @@ -74,7 +74,7 @@ function updateOldSettings(oldSettings) { oldSettings['AutoMaps']++; delete oldSettings['RunUniqueMaps']; } - + autoTrimpSettings = oldSettings; } @@ -371,4 +371,4 @@ window.addEventListener('error', function(event) { */ function throwErrorfromModule() { throw new Error("We have successfully read the thrown error message out of a module"); -} \ No newline at end of file +}