Skip to content

Commit 3453040

Browse files
author
Daniel Varnuska
committed
fix parsing bonus stats
1 parent 7ae68a6 commit 3453040

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/ships/parser.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,25 @@ function parseStatsBonus(cell: Element): Bonus {
369369
cell.childElementCount === 0 ||
370370
!cell.children[0] ||
371371
cell.children[0].tagName === "I"
372-
)
372+
) {
373373
return null;
374+
}
375+
376+
if (cell.children[0].tagName !== "SPAN" || !cell.children[0].children[0]) {
377+
console.log("undefined table tag");
378+
return null;
379+
}
380+
381+
cell = cell.children[0];
382+
374383
let i = 0;
375384
let statsBonus: Bonus = { applicable: [], bonus: "", stat: undefined };
376-
for (; cell.children[i] && cell.children[i].tagName === "A"; i++)
385+
for (; cell.children[i] && cell.children[i].tagName === "A"; i++) {
377386
statsBonus.applicable.push((<HTMLElement>cell.children[i]).title.replace(/\(\w+\)/, "").trim());
378-
if (!cell.children[i]) return null;
387+
}
388+
if (!cell.children[i]) {
389+
return null;
390+
}
379391
let stat = camelize((<HTMLElement>cell.children[i]).title.replace(/[^\w ]/g, ""));
380392
if (!isStat(stat)) {
381393
console.log("Irregular Stat ", stat);

0 commit comments

Comments
 (0)