Skip to content

Commit

Permalink
Fix error when opening a new sheet
Browse files Browse the repository at this point in the history
Split was failing for null abilityModifiers/savingThrows.
  • Loading branch information
giffyglyph committed Apr 16, 2021
1 parent d2686be commit d6c65bc
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions scripts/classes/MonsterFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,16 @@ const MonsterFactory = (function() {
ams[x] = derivedAttributes.abilityModifiers[ranking];
});

const modifiers = abilityModifiers.modifiers.split(",").map(x => x.split("="));
modifiers.forEach(function(modifier) {
const ability = modifier[0].trim().toLowerCase();
const value = Number(modifier[1]);
if (DEFAULT_ABILITIES.includes(ability)) {
ams[ability].applyModifier(value, abilityModifiers.override);
}
});
if (abilityModifiers.modifiers) {
const modifiers = abilityModifiers.modifiers.split(",").map(x => x.split("="));
modifiers.forEach(function(modifier) {
const ability = modifier[0].trim().toLowerCase();
const value = Number(modifier[1]);
if (DEFAULT_ABILITIES.includes(ability)) {
ams[ability].applyModifier(value, abilityModifiers.override);
}
});
}

return ams;
}
Expand All @@ -194,14 +196,16 @@ const MonsterFactory = (function() {
sts[x] = derivedAttributes.savingThrows[ranking];
});

const modifiers = savingThrows.modifiers.split(",").map(x => x.split("="));
modifiers.forEach(function(modifier) {
const ability = modifier[0].trim().toLowerCase();
const value = Number(modifier[1]);
if (DEFAULT_ABILITIES.includes(ability)) {
sts[ability].applyModifier(value, savingThrows.override);
}
});
if (savingThrows.modifiers) {
const modifiers = savingThrows.modifiers.split(",").map(x => x.split("="));
modifiers.forEach(function(modifier) {
const ability = modifier[0].trim().toLowerCase();
const value = Number(modifier[1]);
if (DEFAULT_ABILITIES.includes(ability)) {
sts[ability].applyModifier(value, savingThrows.override);
}
});
}

return sts;
}
Expand Down

0 comments on commit d6c65bc

Please sign in to comment.