diff --git a/Pendragon6thEdition/pendragon.html b/Pendragon6thEdition/pendragon.html index f69362805d..5c9c2556e2 100644 --- a/Pendragon6thEdition/pendragon.html +++ b/Pendragon6thEdition/pendragon.html @@ -1,4 +1,4 @@ -

p

p

/
/
/
/
/
/
/
/
/
/
/
/
/

p

p

p

p

p

ACCEPTING DROP FROM COMPENDIUM
{{#header}}{{header}}{{/header}}
{{#luck}}
{{luck}}
{{#calamity}}
{{calamity}}
{{/calamity}}
{{/luck}} +

p

p

/
/
/
/
/
/
/
/
/
/
/
/
/

p

p

p

p

p

ACCEPTING DROP FROM COMPENDIUM
{{#header}}{{header}}{{/header}}
{{#luck}}
{{luck}}
{{#calamity}}
{{calamity}}
{{/calamity}}
{{/luck}} {{#dice}}
{{dice}}
{{/dice}} {{#threshold}}
{{threshold}}
{{/threshold}} {{#dice}}
{{#rollGreater() threshold 19}} @@ -325,6 +325,26 @@ const versionTwoFiveTwo = () => { }); }; +const versionTwoFiveThree = () => { + const renameSectionAttrTargetValue = (section, attribute) => { + getSectionIDs(section, (ids) => { + const map = ids.map((id) => `${section}_${id}_${attribute}`); + + getAttrs(map, (v) => { + let update = {}; + map.forEach((e) => { + const rowId = getReprowid(e); + update[`${rowId}_name`] = v[`${e}`] ? v[`${e}`] : 0; + }); + setAttrs(update); + }); + }); + }; + + renameSectionAttrTargetValue("repeating_equipment", "equipment"); + renameSectionAttrTargetValue("repeating_arms", "equipment"); +}; + const versioning = async (version) => { const updateMessage = (v) => console.log( @@ -362,6 +382,11 @@ const versioning = async (version) => { versionTwoFiveTwo(); versioning(2.52); break; + case version < 2.53: + updateMessage(2.53); + versionTwoFiveThree(); + versioning(2.53); + break; default: console.log( `%c Pendragon 6th Edition is update to date.`, @@ -437,7 +462,10 @@ const handle_character = (page) => { }); }; - //const arms = processDataArrays(page.data.arms, getStaticUpdate); + const arms = processDataArrays(page.data.arms, (data) => + update_item(data, getRow("arms")) + ); + addEntries(arms); const attacks = processDataArrays(page.data.attacks, (data) => update_attack(data) @@ -456,7 +484,9 @@ const handle_character = (page) => { const dataSkills = parseJSON(page.data.skills); dataSkills.forEach(({ name, target_value }) => { - const isStaticSkill = skills.includes(name.toLowerCase()); + const isStaticSkill = [...skills, ...combatSkills].includes( + name.toLowerCase() + ); if (isStaticSkill) { update[attrName(name)] = target_value; } else { @@ -469,8 +499,7 @@ const handle_character = (page) => { }); const dataTraits = parseJSON(page.data.traits); - //TODO: Remove the rename when the rake task is updated - dataTraits.forEach(({ name, traits: target_value }) => { + dataTraits.forEach(({ name, target_value }) => { const isStaticTrait = traits.includes(name.toLowerCase()); if (isStaticTrait) { update[attrName(name)] = target_value; @@ -596,7 +625,7 @@ const getRepUpdate = (attrs, row, page) => { let update = {}; attrs.forEach((attr) => { - if (page[attr] ?? page.data[attr]) { + if (page?.[attr] ?? page?.data?.[attr]) { update[`${row}_${attr}`] = page[attr] ?? cleanAttr(attr, page.data[attr]); } }); @@ -620,7 +649,7 @@ const getStaticUpdate = (attrs, page) => { let update = {}; attrs.forEach((attr) => { - if (page[attr] ?? page.data[attr]) { + if (page?.[attr] ?? page?.data?.[attr]) { update[attr] = page[attr] ?? cleanAttr(attr, page.data[attr]); } }); @@ -668,12 +697,15 @@ const update_attack = (page) => { }; const update_item = (page, row) => { let update = getRepUpdate( - ["value", "notes", "period_restriction"], + ["name", "value", "notes", "period_restriction"], row, page ); - update[`${row}_equipment`] = page.name; - update[`${row}_category`] = page.data["subcategory"]; + + if (page?.data?.["subcategory"]) { + update[`${row}_category`] = page.data["subcategory"]; + } + return update; }; const update_section = (page, section) => { diff --git a/Pendragon6thEdition/src/js/drag_and_drop/helpers.js b/Pendragon6thEdition/src/js/drag_and_drop/helpers.js index f1243f1c65..dc5e32e197 100644 --- a/Pendragon6thEdition/src/js/drag_and_drop/helpers.js +++ b/Pendragon6thEdition/src/js/drag_and_drop/helpers.js @@ -19,7 +19,7 @@ const getRepUpdate = (attrs, row, page) => { let update = {}; attrs.forEach((attr) => { - if (page[attr] ?? page.data[attr]) { + if (page?.[attr] ?? page?.data?.[attr]) { update[`${row}_${attr}`] = page[attr] ?? cleanAttr(attr, page.data[attr]); } }); @@ -43,7 +43,7 @@ const getStaticUpdate = (attrs, page) => { let update = {}; attrs.forEach((attr) => { - if (page[attr] ?? page.data[attr]) { + if (page?.[attr] ?? page?.data?.[attr]) { update[attr] = page[attr] ?? cleanAttr(attr, page.data[attr]); } }); diff --git a/Pendragon6thEdition/src/js/drag_and_drop/update_item.js b/Pendragon6thEdition/src/js/drag_and_drop/update_item.js index 51b1fe6f54..02e19b5eea 100644 --- a/Pendragon6thEdition/src/js/drag_and_drop/update_item.js +++ b/Pendragon6thEdition/src/js/drag_and_drop/update_item.js @@ -1,10 +1,13 @@ const update_item = (page, row) => { let update = getRepUpdate( - ["value", "notes", "period_restriction"], + ["name", "value", "notes", "period_restriction"], row, page ); - update[`${row}_equipment`] = page.name; - update[`${row}_category`] = page.data["subcategory"]; + + if (page?.data?.["subcategory"]) { + update[`${row}_category`] = page.data["subcategory"]; + } + return update; }; diff --git a/Pendragon6thEdition/src/js/drop.js b/Pendragon6thEdition/src/js/drop.js index 1a9b75518f..f59fff0f66 100644 --- a/Pendragon6thEdition/src/js/drop.js +++ b/Pendragon6thEdition/src/js/drop.js @@ -65,7 +65,10 @@ const handle_character = (page) => { }); }; - //const arms = processDataArrays(page.data.arms, getStaticUpdate); + const arms = processDataArrays(page.data.arms, (data) => + update_item(data, getRow("arms")) + ); + addEntries(arms); const attacks = processDataArrays(page.data.attacks, (data) => update_attack(data) @@ -84,7 +87,9 @@ const handle_character = (page) => { const dataSkills = parseJSON(page.data.skills); dataSkills.forEach(({ name, target_value }) => { - const isStaticSkill = skills.includes(name.toLowerCase()); + const isStaticSkill = [...skills, ...combatSkills].includes( + name.toLowerCase() + ); if (isStaticSkill) { update[attrName(name)] = target_value; } else { @@ -97,8 +102,7 @@ const handle_character = (page) => { }); const dataTraits = parseJSON(page.data.traits); - //TODO: Remove the rename when the rake task is updated - dataTraits.forEach(({ name, traits: target_value }) => { + dataTraits.forEach(({ name, target_value }) => { const isStaticTrait = traits.includes(name.toLowerCase()); if (isStaticTrait) { update[attrName(name)] = target_value; diff --git a/Pendragon6thEdition/src/js/versioning.js b/Pendragon6thEdition/src/js/versioning.js index 4ca47f754e..97c5e866a6 100644 --- a/Pendragon6thEdition/src/js/versioning.js +++ b/Pendragon6thEdition/src/js/versioning.js @@ -72,6 +72,26 @@ const versionTwoFiveTwo = () => { }); }; +const versionTwoFiveThree = () => { + const renameSectionAttrTargetValue = (section, attribute) => { + getSectionIDs(section, (ids) => { + const map = ids.map((id) => `${section}_${id}_${attribute}`); + + getAttrs(map, (v) => { + let update = {}; + map.forEach((e) => { + const rowId = getReprowid(e); + update[`${rowId}_name`] = v[`${e}`] ? v[`${e}`] : 0; + }); + setAttrs(update); + }); + }); + }; + + renameSectionAttrTargetValue("repeating_equipment", "equipment"); + renameSectionAttrTargetValue("repeating_arms", "equipment"); +}; + const versioning = async (version) => { const updateMessage = (v) => console.log( @@ -109,6 +129,11 @@ const versioning = async (version) => { versionTwoFiveTwo(); versioning(2.52); break; + case version < 2.53: + updateMessage(2.53); + versionTwoFiveThree(); + versioning(2.53); + break; default: console.log( `%c Pendragon 6th Edition is update to date.`, diff --git a/Pendragon6thEdition/src/pages/components/equipment.pug b/Pendragon6thEdition/src/pages/components/equipment.pug index 898232bfa4..461168c0e3 100644 --- a/Pendragon6thEdition/src/pages/components/equipment.pug +++ b/Pendragon6thEdition/src/pages/components/equipment.pug @@ -8,8 +8,8 @@ mixin equipment(name) +repeatingFlags() .row.grid.2autocolumn +subHeader('name') - span.display.bottom-border(name=`attr_${attrName('equipment')}`) - +textInput('equipment') + span.display.bottom-border(name=`attr_${attrName('name')}`) + +textInput('name') .row.grid .grid.gap.category each val in ['category', 'value']