From 03cd7f11dad0ebaf3688389b92ae4c12855a0277 Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Sat, 28 Nov 2020 20:10:13 -0500 Subject: [PATCH] Added fixOldSave and work on reset logic for side layers --- changelog.md | 2 ++ docs/main-mod-info.md | 2 +- js/Demo/demoMod.js | 7 ++++++- js/game.js | 12 +++++++----- js/mod.js | 5 +++++ js/utils.js | 6 +++++- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 7b75a87..e12e41e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ # The Modding Tree changelog: +- Added fixOldSaves. + ### v2.2.3 - 11/28/20 - Layers will be highlighted if you can finish a challenge. - The "can complete challenge" color now overrides the "already completed" color. diff --git a/docs/main-mod-info.md b/docs/main-mod-info.md index 72bba63..8c03cec 100644 --- a/docs/main-mod-info.md +++ b/docs/main-mod-info.md @@ -52,4 +52,4 @@ function addedPlayerData() { return { Less important things beyond this point! -- maxTickLength(): Returns the maximum tick length, in milliseconds. Only really useful if you have something that reduces over time, which long ticks mess up (usually a challenge). +- maxTickLength(): Returns the maximum tick length, in milliseconds. Only really useful if you have something that reduces over time, which long ticks mess up (usually a challenge). \ No newline at end of file diff --git a/js/Demo/demoMod.js b/js/Demo/demoMod.js index ca5c1fc..a85063e 100644 --- a/js/Demo/demoMod.js +++ b/js/Demo/demoMod.js @@ -12,7 +12,7 @@ let modInfo = { // Set your version in num and name let VERSION = { - num: "2.2.2", + num: "2.2.3", name: "Uprooted", } @@ -64,4 +64,9 @@ function isEndgame() { // You can change this if you have things that can be messed up by long tick lengths function maxTickLength() { return(3600000) // Default is 1 hour which is just arbitrarily large +} + +// Use this if you need to undo inflation from an older version. If the version is older than the version that fixed the issue, +// you can cap their current resources with this. +function fixOldSave(oldVersion){ } \ No newline at end of file diff --git a/js/game.js b/js/game.js index b504ca3..2eca59c 100644 --- a/js/game.js +++ b/js/game.js @@ -99,7 +99,7 @@ function rowReset(row, layer) { layers[lr].doReset(layer) } else - if(tmp[layer].row > tmp[lr].row && row !== "side") layerDataReset(lr) + if(tmp[layer].row > tmp[lr].row && row !== "side" && !isNaN(row)) layerDataReset(lr) } } @@ -144,6 +144,7 @@ function generatePoints(layer, diff) { var prevOnReset function doReset(layer, force=false) { + if (tmp[layer].type == "none") return let row = tmp[layer].row if (!force) { if (tmp[layer].baseAmount.lt(tmp[layer].requires)) return; @@ -282,10 +283,11 @@ function gameLoop(diff) { } if (player.devSpeed) diff *= player.devSpeed - let limit = maxTickLength() - if(diff > limit) - diff = limit - + if (maxTickLength) { + let limit = maxTickLength() + if(diff > limit) + diff = limit + } addTime(diff) player.points = player.points.add(tmp.pointGen.times(diff)).max(0) diff --git a/js/mod.js b/js/mod.js index 39cef6b..b8a7f6f 100644 --- a/js/mod.js +++ b/js/mod.js @@ -59,4 +59,9 @@ function isEndgame() { // You can change this if you have things that can be messed up by long tick lengths function maxTickLength() { return(3600000) // Default is 1 hour which is just arbitrarily large +} + +// Use this if you need to undo inflation from an older version. If the version is older than the version that fixed the issue, +// you can cap their current resources with this. +function fixOldSave(oldVersion){ } \ No newline at end of file diff --git a/js/utils.js b/js/utils.js index 799a969..219ebee 100644 --- a/js/utils.js +++ b/js/utils.js @@ -301,6 +301,7 @@ function importSave(imported=undefined, forced=false) { player = tempPlr; player.versionType = modInfo.id fixSave() + versionCheck() save() window.location.reload() } catch(e) { @@ -317,7 +318,10 @@ function versionCheck() { } if (setVersion) { - if (player.versionType == modInfo.id && VERSION.num > player.version) player.keepGoing = false + if (player.versionType == modInfo.id && VERSION.num > player.version) { + player.keepGoing = false + if (fixOldSave) fixOldSave(player.version) + } player.versionType = getStartPlayer().versionType player.version = VERSION.num player.beta = VERSION.beta