Skip to content

Commit

Permalink
fix(item sheet): fixed a bug with invalid data on items other than we…
Browse files Browse the repository at this point in the history
…apons
  • Loading branch information
SouOWendel committed Jan 17, 2024
1 parent ea64285 commit 20bbdb9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions module/sheets/item-sheet.mjs
Expand Up @@ -68,20 +68,19 @@ export class OrdemItemSheet extends ItemSheet {
});

// TODO: Fix the incompatibilities (Temporary)
console.log(itemData);
if (itemData.system.types.damageType) {
if (itemData.system.types?.damageType) {
itemData.system.formulas.damage.type = itemData.system.types.damageType;
delete itemData.system.types.damageType;
}
// TODO: Fix the incompatibilities (Temporary)
if (itemData.system.formulas.attackFormula) {
if (itemData.system.formulas?.attackFormula) {
itemData.system.formulas.damage.formula = itemData.system.formulas.attackFormula.formula;
itemData.system.formulas.damage.attr = itemData.system.formulas.attackFormula.attr;
itemData.system.formulas.damage.bonus = itemData.system.formulas.attackFormula.bonus;
delete itemData.system.formulas.attackFormula;
}
// TODO: Fix the incompatibilities (Temporary)
if (itemData.system.formulas.damageFormula) {
if (itemData.system.formulas?.damageFormula) {
itemData.system.formulas.damage.formula = itemData.system.formulas.damageFormula.formula;
itemData.system.formulas.damage.attr = itemData.system.formulas.damageFormula.attr;
itemData.system.formulas.damage.bonus = itemData.system.formulas.damageFormula.bonus;
Expand Down Expand Up @@ -129,7 +128,7 @@ export class OrdemItemSheet extends ItemSheet {
const formData = foundry.utils.expandObject(super._getSubmitData(updateData));

// Handle Damage array
const damage = formData.system.formulas?.damage;
const damage = formData.system?.formulas?.damage;
if ( damage ) damage.parts = Object.values(damage?.parts || {}).map(d => [d[0] || '', d[1] || '']);

// Return the flattened submission data
Expand Down

0 comments on commit 20bbdb9

Please sign in to comment.