Skip to content

Commit

Permalink
Fix StatBlockParser when Characteristics is absent (#2319)
Browse files Browse the repository at this point in the history
* allow parser to import statblocks with '–' signs by changing NaN values to 0 for characteristics

* remove redundant `Number()` calls
  • Loading branch information
Forien authored Dec 3, 2024
1 parent 5da4e57 commit 635c2aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/apps/stat-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ export default class StatBlockParser extends FormApplication {
let characteristicValues = blockArray[tableIndex + 1].split(" ")

for (let i = 0; i < characteristicNames.length; i++) {
const value = Number(characteristicValues[i]) || 0;

if (characteristicNames[i] == "Agi")
characteristicNames[i] = "Ag"
if (characteristicNames[i].toLowerCase() == "m") {
model.details.move.value = Number(characteristicValues[i]);
model.details.move.value = value;
continue;
}
if (characteristicNames[i].toLowerCase() == "w")
continue;

try {
model.characteristics[characteristicNames[i].toLowerCase()].initial = Number(characteristicValues[i])
model.characteristics[characteristicNames[i].toLowerCase()].initial = value
}
catch { }
}
Expand Down

0 comments on commit 635c2aa

Please sign in to comment.