From 7f4d57d3e4682f91abc61b06e9c26406f9fa263f Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Wed, 15 Feb 2023 15:06:06 -0600 Subject: [PATCH] Added incredibly dangerous deleteLowerSaves function to window --- src/util/save.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/save.ts b/src/util/save.ts index 2955fd1..4137e5b 100644 --- a/src/util/save.ts +++ b/src/util/save.ts @@ -140,14 +140,22 @@ window.onbeforeunload = () => { declare global { /** - * Augment the window object so the save function, and the hard reset function can be accessed from the console. + * Augment the window object so the save, hard reset, and deleteLowerSaves functions can be accessed from the console. */ interface Window { save: VoidFunction; hardReset: VoidFunction; + deleteLowerSaves: VoidFunction; } } window.save = save; export const hardReset = (window.hardReset = async () => { await loadSave(newSave()); }); +export const deleteLowerSaves = (window.deleteLowerSaves = () => { + const index = Object.values(settings.saves).indexOf(player.id) + 1; + Object.values(settings.saves) + .slice(index) + .forEach(id => localStorage.removeItem(id)); + settings.saves = settings.saves.slice(0, index); +});