Skip to content

Commit

Permalink
Merged buttons into multitoggles, added Autostance3+Windstack feature…
Browse files Browse the repository at this point in the history
…, 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
  • Loading branch information
genbtc committed Mar 28, 2018
1 parent 086d11b commit 630263a
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 48 deletions.
2 changes: 1 addition & 1 deletion AutoTrimps2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)///////////
Expand Down
22 changes: 15 additions & 7 deletions Graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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...");
Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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)));
Expand Down
5 changes: 4 additions & 1 deletion SettingsGUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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','<br>');

//SPAM settings:
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions modules/battlecalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -196,8 +196,8 @@ function getBattleStats(what,form,crit) {
//Pumpkimp buff
if (game.global.sugarRush > 0 && what == "attack"){
currentCalc *= sugarRush.getAttackStrength();
textString += "<tr class='pumpkimpRow'><td class='bdTitle'>Sugar Rush</td><td>&nbsp;</td><td>&nbsp;</td><td>x " + sugarRush.getAttackStrength() + "</td><td class='bdNumberSm'>" + prettify(currentCalc) + "</td>" + ((what == "attack") ? getFluctuation(currentCalc, minFluct, maxFluct) : "") + "</tr>";
}
textString += "<tr class='pumpkimpRow'><td class='bdTitle'>Sugar Rush</td><td>&nbsp;</td><td>&nbsp;</td><td>x " + sugarRush.getAttackStrength() + "</td><td class='bdNumberSm'>" + prettify(currentCalc) + "</td>" + ((what == "attack") ? getFluctuation(currentCalc, minFluct, maxFluct) : "") + "</tr>";
}
//Magma
if (mutations.Magma.active() && (what == "attack" || what == "health")){
var mult = mutations.Magma.getTrimpDecay();
Expand All @@ -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){
Expand Down
12 changes: 6 additions & 6 deletions modules/breedtimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion modules/buildings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions modules/client-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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);
}
Expand All @@ -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));
}
Expand All @@ -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");
});
});
Expand Down
2 changes: 1 addition & 1 deletion modules/dynprestige.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
2 changes: 1 addition & 1 deletion modules/fight-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions modules/fight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions modules/import-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -398,4 +398,4 @@ function resetModuleVars(imported) {
ATrunning = true; //restart AT.
}
setTimeout(waitRemoveLoad(imported),101);
}
}
2 changes: 1 addition & 1 deletion modules/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions modules/other.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <body> tag
document.body.appendChild(M["performance"].AFKOverlay);

Expand Down
2 changes: 1 addition & 1 deletion modules/perks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -74,7 +74,7 @@ function updateOldSettings(oldSettings) {
oldSettings['AutoMaps']++;
delete oldSettings['RunUniqueMaps'];
}

autoTrimpSettings = oldSettings;
}

Expand Down Expand Up @@ -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");
}
}

0 comments on commit 630263a

Please sign in to comment.