Skip to content

Commit

Permalink
fix bug in passions/versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
clevett committed Sep 22, 2024
1 parent 3ee4f96 commit 8c8b4ad
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Pendragon6thEdition/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pendragon6thedition",
"version": "3.2.0",
"version": "3.2.1",
"description": "You need to run npm start to get the compilers going.",
"dependencies": {
"20": "^3.1.9",
Expand Down
50 changes: 43 additions & 7 deletions Pendragon6thEdition/pendragon.html

Large diffs are not rendered by default.

45 changes: 43 additions & 2 deletions Pendragon6thEdition/src/js/versioning.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const versioningAttr = "latest_versioning_upgrade";

on("sheet:opened", () => {
//setAttrs({ latest_versioning_upgrade: 2.5 }); used for testing versioning
// setAttrs({ latest_versioning_upgrade: 3.2 }); //used for testing versioning
getAttrs([versioningAttr], (v) => {
versioning(parseFloat(v[versioningAttr]) || 1);
});
Expand All @@ -25,7 +25,10 @@ const renameSectionAttrTargetValue = (section, attribute) => {
let update = {};
map.forEach((e) => {
const rowId = getReprowid(e);
update[`${rowId}_target_value`] = v[`${e}`] ? v[`${e}`] : 0;

if (v[`${e}`]) {
update[`${rowId}_target_value`] = v[`${e}`];
}
});
setAttrs(update);
});
Expand Down Expand Up @@ -74,6 +77,39 @@ const versionTwoFiveThree = () => {
renameSectionAttr("repeating_arms", "equipment");
};

const versionThreeTwoOne = () => {
const section = "repeating_passions";
getSectionIDs(section, (ids) => {
const map = ids.map((id) =>
["name", "target_value"].map((e) => `${section}_${id}_${e}`)
);

map.forEach((e) => {
getAttrs(e, (v) => {
const name = v[`${e[0]}`];
const targetValue = v[`${e[1]}`];
if (targetValue === 0) {
getSectionIDs("repeating_passion", (oldIds) => {
const oldMap = oldIds.map((id) =>
["name", "passion"].map((e) => `repeating_passion_${id}_${e}`)
);

oldMap.forEach((oldE) => {
getAttrs(oldE, (oldV) => {
if (oldV[`${oldE[0]}`] === name) {
setAttrs({
[`${e[1]}`]: oldV[`${oldE[1]}`],
});
}
});
});
});
}
});
});
});
};

const versionThreeZero = () => {
const renameRepeatingSectionName = (section, newName, targetValue) => {
const attrs = ["name", "target_value", "check"];
Expand Down Expand Up @@ -184,6 +220,11 @@ const versioning = async (version) => {
versionThreeTwo();
versioning(3.2);
break;
case version < 3.21:
updateMessage(3.21);
versionThreeTwoOne();
versioning(3.21);
break;
default:
console.log(
`%c Pendragon 6th Edition is update to date.`,
Expand Down
2 changes: 1 addition & 1 deletion Pendragon6thEdition/src/pendragon.pug
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//- Semantic Versioning MAJOR.MINORPATCH
input(name='attr_version' type='hidden' value='3.2')
input(name='attr_version' type='hidden' value='3.21')

//- Do not manually change this. Hidden attribute used by versioning script
input(name='attr_latest_versioning_upgrade' type='hidden' value='3')
Expand Down

0 comments on commit 8c8b4ad

Please sign in to comment.