From 56afa417216c17bf60e371fa6b48c3d6e44a930b Mon Sep 17 00:00:00 2001 From: Lee Rhodes Date: Thu, 8 Apr 2021 15:13:32 +0100 Subject: [PATCH] [Ironsworn] Migrating Legacy Vows (#8657) * added migration for legacy vows * added new changelog explainer * added html for explainer * removed console.log --- Ironsworn/Ironsworn.html | 2394 +++++++++-------- Ironsworn/src/app/pages/character/summary.pug | 5 +- Ironsworn/src/app/pages/common/vows.pug | 5 +- Ironsworn/src/app/pages/index.pug | 6 +- .../src/app/workers/scripts/legacy-vows.js | 17 +- Ironsworn/src/app/workers/scripts/pages.js | 2 +- Ironsworn/src/app/workers/scripts/progress.js | 17 +- Ironsworn/src/app/workers/scripts/vows.js | 86 +- Ironsworn/src/package.json | 2 +- 9 files changed, 1337 insertions(+), 1197 deletions(-) diff --git a/Ironsworn/Ironsworn.html b/Ironsworn/Ironsworn.html index f87a661c84..df0249a710 100644 --- a/Ironsworn/Ironsworn.html +++ b/Ironsworn/Ironsworn.html @@ -1,9 +1,9 @@ - +
-

Version 2 Release

-
As part of the version 2 release, a new landing page was added for selecting either the character sheet, or the new shared sheet. If this was previously a character sheet, you can just select the "CHARACTER" option.
+

Version 2.2 Release

+
The old static vows have now been migrated to the repeating vows (all the data should be there). If there are any issues, all of the old vow information is still available from the Abilities / Attributes section.
(All your data will be retained)

 VOWS 

- - -
-
-
- - -
- -
- - - - - - - - - - +
+ + +
+
+
+ + +
+ +
+ + + + + + + + + + +
-
-
- - - - - -
-
-
-
- - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- -
- +
+ + + + +
-
- - -
-
-
- - -
- -
- - - - - - - - - - +
+
+
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ +
+
-
-
- - - - - -
-
-
-
- - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- -
- -
-
- - -
-
-
- - -
- -
- - - - - - - - - - + + +
+
+
+ + +
+ +
+ + + + + + + + + + +
-
-
- - - - - -
-
-
-
- - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- -
- +
+ + + + +
-
- - -
-
-
- - -
- -
- - - - - - - - - - +
+
+
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ +
+
-
-
- - - - - -
-
-
-
- - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- -
- -
-
- - -
-
-
- - -
- -
- - - - - - - - - - + + +
+
+
+ + +
+ +
+ + + + + + + + + + +
-
-
- - - - - -
-
-
-
- - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- - - - - -
-
- -
- +
+ + + + +
-
+
+
+
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ +
+ +
+
+ + +
+
+
+ + +
+ +
+ + + + + + + + + + +
+
+
+
+ + + + + +
+
+
+
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ +
+ +
+
+ + +
+
+
+ + +
+ +
+ + + + + + + + + + +
+
+
+
+ + + + + +
+
+
+
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ +
+ +
+
+
@@ -27635,7 +27637,7 @@ on('change:stat_mode_button', function(eventinfo) { on('change:close_changelog', function() { setAttrs({ - 'changelog_2.0.0': 'on', + 'changelog_2.2.0': 'on', }); }); const progressStrings = [ @@ -27679,22 +27681,17 @@ function updateProgress (mark, progressArray) { function chosenDifficulty (rank) { switch (rank) { case 1: - return 12 - break; + return 12; case 2: - return 8 - break; + return 8; case 3: - return 4 - break; + return 4; case 4: - return 2 - break; + return 2; case 5: - return 1 - break; + return 1; default: - return null + return null; } } @@ -27872,14 +27869,92 @@ on('change:supply', function(eventinfo) { }); if (parseInt(eventinfo.newValue) === 0) setAttrs({debilUnprepared: "on"}); }); - on('remove:repeating_vow remove:repeating_bonds remove:repeating_progress remove:repeating_sites remove:repeating_assets', function() { - const timestamp = Number(new Date()) + on("remove:repeating_vow remove:repeating_bonds remove:repeating_progress remove:repeating_sites remove:repeating_assets", function() { + const timestamp = Number(new Date()); setAttrs({ repeat_delete: timestamp }); }); -on('change:repeating_vow:menace-show-button', function(eventinfo) { +on("change:repeating_vow:menace-show-button", function(eventinfo) { setAttrs({ - 'repeating_vow_menace-show': eventinfo.newValue + "repeating_vow_menace-show": eventinfo.newValue + }); +}); + +function fillRepeatingVow (vowNumber) { + const repeatingAttrs = [ + "vow_name", + "threat-name", + `menace-show-button`, + "menace-show", + "menace-1", + "menace-2", + "menace-3", + "menace-4", + "menace-5", + "menace-6", + "menace-7", + "menace-8", + "menace-9", + "menace-10", + "rank", + "progress_0", + "progress_1", + "progress_2", + "progress_3", + "progress_4", + "progress_5", + "progress_6", + "progress_7", + "progress_8", + "progress_9" + ]; + const legacyAttrs = [ + `vow${vowNumber}_name`, + `vow${vowNumber}_threat-name`, + `vow${vowNumber}_menace-show-button`, + `vow${vowNumber}_menace-show`, + `vow${vowNumber}-1-threat`, + `vow${vowNumber}-2-threat`, + `vow${vowNumber}-3-threat`, + `vow${vowNumber}-4-threat`, + `vow${vowNumber}-5-threat`, + `vow${vowNumber}-6-threat`, + `vow${vowNumber}-7-threat`, + `vow${vowNumber}-8-threat`, + `vow${vowNumber}-9-threat`, + `vow${vowNumber}-10-threat`, + `vow${vowNumber}_rank`, + `vow${vowNumber}-0`, + `vow${vowNumber}-1`, + `vow${vowNumber}-2`, + `vow${vowNumber}-3`, + `vow${vowNumber}-4`, + `vow${vowNumber}-5`, + `vow${vowNumber}-6`, + `vow${vowNumber}-7`, + `vow${vowNumber}-8`, + `vow${vowNumber}-9` + ]; + getAttrs(legacyAttrs, function(vow) { + const newrowid = generateRowID(); + var newAttrs = {}; + repeatingAttrs.forEach(function (attr, index) { + newAttrs[`repeating_vow_${newrowid}_${attr}`] = vow[legacyAttrs[index]]; + }) + setAttrs(newAttrs); + }); +} + +on("sheet:opened", function() { + getAttrs(["vows_migrated"], function(migrationCheck) { + if (migrationCheck.vows_migrated == true) { + return true + } else { + for (currentVow = 1; currentVow <= 5; currentVow++) { + fillRepeatingVow(currentVow); + } + setAttrs({vows_migrated: true}); + }; }); });function getCurrentVow (VowValues) { let total = 0 @@ -27908,22 +27983,17 @@ function updateVow (mark, vowArray, number) { function chosenDifficulty (rank) { switch (rank) { case 1: - return 12 - break; + return 12; case 2: - return 8 - break; + return 8; case 3: - return 4 - break; + return 4; case 4: - return 2 - break; + return 2; case 5: - return 1 - break; + return 1; default: - return null + return null; } } diff --git a/Ironsworn/src/app/pages/character/summary.pug b/Ironsworn/src/app/pages/character/summary.pug index 39465bf148..dbae9e8df3 100644 --- a/Ironsworn/src/app/pages/character/summary.pug +++ b/Ironsworn/src/app/pages/character/summary.pug @@ -13,8 +13,9 @@ mixin summaryPage fieldset.repeating_vow +repeatingVow() else - each vow in legacyVows - +vowLegacy(vow) + div.hide-element + each vow in legacyVows + +vowLegacy(vow) fieldset.repeating_vow +repeatingVow() h3.divide(data-i18n='page-summary-debilities')=locals['page-summary-debilities'] diff --git a/Ironsworn/src/app/pages/common/vows.pug b/Ironsworn/src/app/pages/common/vows.pug index 60c84eb82c..a7affc9c64 100644 --- a/Ironsworn/src/app/pages/common/vows.pug +++ b/Ironsworn/src/app/pages/common/vows.pug @@ -13,7 +13,8 @@ mixin vowsPage(sheetType) fieldset.repeating_vow +repeatingVow() else - each vow in legacyVows - +vowLegacy(vow) + div.hide-element + each vow in legacyVows + +vowLegacy(vow) fieldset.repeating_vow +repeatingVow() \ No newline at end of file diff --git a/Ironsworn/src/app/pages/index.pug b/Ironsworn/src/app/pages/index.pug index 523034bed1..39ee9155ff 100644 --- a/Ironsworn/src/app/pages/index.pug +++ b/Ironsworn/src/app/pages/index.pug @@ -1,8 +1,8 @@ -input.changelog.hide-element(type='checkbox' name='attr_changelog_2.0.0') +input.changelog.hide-element(type='checkbox' name='attr_changelog_2.2.0') .changelog .copy - h3 Version 2 Release - div As part of the version 2 release, a new landing page was added for selecting either the character sheet, or the new shared sheet. If this was previously a character sheet, you can just select the "CHARACTER" option. + h3 Version 2.2 Release + div The old static vows have now been migrated to the repeating vows (all the data should be there). If there are any issues, all of the old vow information is still available from the Abilities / Attributes section. div.center (All your data will be retained) label.close-changelog input(type='checkbox' name=`attr_close_changelog` class='hide-element') diff --git a/Ironsworn/src/app/workers/scripts/legacy-vows.js b/Ironsworn/src/app/workers/scripts/legacy-vows.js index 66bec3c441..b092ce7118 100644 --- a/Ironsworn/src/app/workers/scripts/legacy-vows.js +++ b/Ironsworn/src/app/workers/scripts/legacy-vows.js @@ -25,22 +25,17 @@ function updateVow (mark, vowArray, number) { function chosenDifficulty (rank) { switch (rank) { case 1: - return 12 - break; + return 12; case 2: - return 8 - break; + return 8; case 3: - return 4 - break; + return 4; case 4: - return 2 - break; + return 2; case 5: - return 1 - break; + return 1; default: - return null + return null; } } diff --git a/Ironsworn/src/app/workers/scripts/pages.js b/Ironsworn/src/app/workers/scripts/pages.js index 2905008031..c133c9fab1 100644 --- a/Ironsworn/src/app/workers/scripts/pages.js +++ b/Ironsworn/src/app/workers/scripts/pages.js @@ -25,6 +25,6 @@ on('change:stat_mode_button', function(eventinfo) { on('change:close_changelog', function() { setAttrs({ - 'changelog_2.0.0': 'on', + 'changelog_2.2.0': 'on', }); }); diff --git a/Ironsworn/src/app/workers/scripts/progress.js b/Ironsworn/src/app/workers/scripts/progress.js index bc957761cc..ba589cbd82 100644 --- a/Ironsworn/src/app/workers/scripts/progress.js +++ b/Ironsworn/src/app/workers/scripts/progress.js @@ -39,22 +39,17 @@ function updateProgress (mark, progressArray) { function chosenDifficulty (rank) { switch (rank) { case 1: - return 12 - break; + return 12; case 2: - return 8 - break; + return 8; case 3: - return 4 - break; + return 4; case 4: - return 2 - break; + return 2; case 5: - return 1 - break; + return 1; default: - return null + return null; } } diff --git a/Ironsworn/src/app/workers/scripts/vows.js b/Ironsworn/src/app/workers/scripts/vows.js index 215a1886fb..b85de45d51 100644 --- a/Ironsworn/src/app/workers/scripts/vows.js +++ b/Ironsworn/src/app/workers/scripts/vows.js @@ -1,10 +1,88 @@ -on('remove:repeating_vow remove:repeating_bonds remove:repeating_progress remove:repeating_sites remove:repeating_assets', function() { - const timestamp = Number(new Date()) +on("remove:repeating_vow remove:repeating_bonds remove:repeating_progress remove:repeating_sites remove:repeating_assets", function() { + const timestamp = Number(new Date()); setAttrs({ repeat_delete: timestamp }); }); -on('change:repeating_vow:menace-show-button', function(eventinfo) { +on("change:repeating_vow:menace-show-button", function(eventinfo) { setAttrs({ - 'repeating_vow_menace-show': eventinfo.newValue + "repeating_vow_menace-show": eventinfo.newValue + }); +}); + +function fillRepeatingVow (vowNumber) { + const repeatingAttrs = [ + "vow_name", + "threat-name", + `menace-show-button`, + "menace-show", + "menace-1", + "menace-2", + "menace-3", + "menace-4", + "menace-5", + "menace-6", + "menace-7", + "menace-8", + "menace-9", + "menace-10", + "rank", + "progress_0", + "progress_1", + "progress_2", + "progress_3", + "progress_4", + "progress_5", + "progress_6", + "progress_7", + "progress_8", + "progress_9" + ]; + const legacyAttrs = [ + `vow${vowNumber}_name`, + `vow${vowNumber}_threat-name`, + `vow${vowNumber}_menace-show-button`, + `vow${vowNumber}_menace-show`, + `vow${vowNumber}-1-threat`, + `vow${vowNumber}-2-threat`, + `vow${vowNumber}-3-threat`, + `vow${vowNumber}-4-threat`, + `vow${vowNumber}-5-threat`, + `vow${vowNumber}-6-threat`, + `vow${vowNumber}-7-threat`, + `vow${vowNumber}-8-threat`, + `vow${vowNumber}-9-threat`, + `vow${vowNumber}-10-threat`, + `vow${vowNumber}_rank`, + `vow${vowNumber}-0`, + `vow${vowNumber}-1`, + `vow${vowNumber}-2`, + `vow${vowNumber}-3`, + `vow${vowNumber}-4`, + `vow${vowNumber}-5`, + `vow${vowNumber}-6`, + `vow${vowNumber}-7`, + `vow${vowNumber}-8`, + `vow${vowNumber}-9` + ]; + getAttrs(legacyAttrs, function(vow) { + const newrowid = generateRowID(); + var newAttrs = {}; + repeatingAttrs.forEach(function (attr, index) { + newAttrs[`repeating_vow_${newrowid}_${attr}`] = vow[legacyAttrs[index]]; + }) + setAttrs(newAttrs); + }); +} + +on("sheet:opened", function() { + getAttrs(["vows_migrated"], function(migrationCheck) { + if (migrationCheck.vows_migrated == true) { + return true + } else { + for (currentVow = 1; currentVow <= 5; currentVow++) { + fillRepeatingVow(currentVow); + } + setAttrs({vows_migrated: true}); + }; }); }); \ No newline at end of file diff --git a/Ironsworn/src/package.json b/Ironsworn/src/package.json index 92eb53da3b..854984ee01 100644 --- a/Ironsworn/src/package.json +++ b/Ironsworn/src/package.json @@ -1,6 +1,6 @@ { "name": "ironsworn", - "version": "2.1.0", + "version": "2.2.0", "description": "Roll20 character sheet for the RPG ironsworn", "main": "Ironsworn.html", "scripts": {