Added incredibly dangerous deleteLowerSaves function to window

This commit is contained in:
thepaperpilot 2023-02-15 15:06:06 -06:00
parent 1bfa66e1c9
commit 7f4d57d3e4

View file

@ -140,14 +140,22 @@ window.onbeforeunload = () => {
declare global { 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 { interface Window {
save: VoidFunction; save: VoidFunction;
hardReset: VoidFunction; hardReset: VoidFunction;
deleteLowerSaves: VoidFunction;
} }
} }
window.save = save; window.save = save;
export const hardReset = (window.hardReset = async () => { export const hardReset = (window.hardReset = async () => {
await loadSave(newSave()); 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);
});