mirror of
https://github.com/Nighthawk42/roll20-character-sheets.git
synced 2026-08-31 04:02:29 +00:00
get warms working
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.`,
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user