From 9d66148e6cfdd49e6b3b26d98ed416ef420a2637 Mon Sep 17 00:00:00 2001 From: Eric Fredricksen Date: Mon, 28 Nov 2022 10:15:16 -0800 Subject: [PATCH] Patch around spell spelling correction mistake [sic] --- main.js | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index 6363560..6a101ca 100644 --- a/main.js +++ b/main.js @@ -1104,14 +1104,6 @@ function LoadGame(sheet) { game = sheet; - /* - if (!window.localStorage) { - // Cookies can't hold a whole game save - storage.removeItem("roster"); - storage = null; - } -*/ - if (document) { var title = "Progress Quest - " + GameSaveName(); $("#title").text(title); @@ -1119,7 +1111,6 @@ function LoadGame(sheet) { document.title = title; } - randseed(game.seed); $.each(AllBars.concat(AllLists), function (i, e) { e.load(game); }); if (Kill) @@ -1128,6 +1119,30 @@ function LoadGame(sheet) { $.each([Plots,Quests], function () { this.CheckAll(true); }); + + // Patch correctly spelled spells showing up as new spells when + // the incorretly spelled spell was there already. + function patch(from, to) { + function count(spell) { + let t = game.Spells.filter(a => a[0] == spell); + return t.length == 1 ? toArabic(t[0][1]) : 0; + } + let tf = count(from); + if (!tf) return; + let tt = count(to); + let total = tf + tt; + console.log('Patching ' + from + ' to ' + to); + game.Spells = game.Spells.filter(a => a[0] != to); + for (let spell of game.Spells) { + if (spell[0] == from) { + spell[0] = to; + spell[1] = toRoman(total); + } + } + } + patch('Innoculate', 'Inoculate'); + patch('Tonsilectomy', 'Tonsillectomy'); + Log('Loaded game: ' + game.Traits.Name); if (!game.elapsed) Brag('s');