Skip to content

Commit

Permalink
Merge pull request #186 from ZikiHero/master
Browse files Browse the repository at this point in the history
fix parsing bonus stats
  • Loading branch information
jasperchua99 authored Mar 3, 2024
2 parents 7ae68a6 + 3453040 commit 6b14b1c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/ships/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,25 @@ function parseStatsBonus(cell: Element): Bonus {
cell.childElementCount === 0 ||
!cell.children[0] ||
cell.children[0].tagName === "I"
)
) {
return null;
}

if (cell.children[0].tagName !== "SPAN" || !cell.children[0].children[0]) {
console.log("undefined table tag");
return null;
}

cell = cell.children[0];

let i = 0;
let statsBonus: Bonus = { applicable: [], bonus: "", stat: undefined };
for (; cell.children[i] && cell.children[i].tagName === "A"; i++)
for (; cell.children[i] && cell.children[i].tagName === "A"; i++) {
statsBonus.applicable.push((<HTMLElement>cell.children[i]).title.replace(/\(\w+\)/, "").trim());
if (!cell.children[i]) return null;
}
if (!cell.children[i]) {
return null;
}
let stat = camelize((<HTMLElement>cell.children[i]).title.replace(/[^\w ]/g, ""));
if (!isStat(stat)) {
console.log("Irregular Stat ", stat);
Expand Down

0 comments on commit 6b14b1c

Please sign in to comment.