Skip to content

Commit

Permalink
🐛 fail gracefully: bad progression tables; bad tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Jan 19, 2024
1 parent 53b17c0 commit 3e8d6b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,20 @@ void buildClassProgression(JsonNode node, List<String> progression, String field
ArrayNode rows = table.withArray("rows");
for (int i = 0; i < rows.size(); i++) {
int level = i + 1;
if (level >= row_levels.size()) {
tui().errorf("Badly formed class-progression table in %s: %s", sources, table.toString());
break;
}
rows.get(i).forEach(c -> row_levels.get(level).add(columnValue(c)));
}
} else if (table.has("rowsSpellProgression")) {
ArrayNode rows = table.withArray("rowsSpellProgression");
for (int i = 0; i < rows.size(); i++) {
int level = i + 1;
if (level >= row_levels.size()) {
tui().errorf("Badly formed spell-progression table in %s: %s", sources, table.toString());
break;
}
rows.get(i).forEach(c -> row_levels.get(level).add(columnValue(c)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,10 @@ default String linkifyClassFeature(String match) {
// {@classFeature Rage|Barbarian||1||optional display text}.
String[] parts = match.split("\\|");
String linkText = parts[0];
if (parts.length < 4) {
tui().errorf("Bad Class Feature Link {@classFeature %s} in %s", match, getSources());
return linkText;
}
String className = parts[1];
String classSource = parts[2].isBlank() ? "phb" : parts[2];
String level = parts[3];
Expand Down Expand Up @@ -642,9 +646,12 @@ default String linkifySubclassFeature(String match) {
// Class source is assumed to be PHB.
// Subclass source is assumed to be PHB.
// Subclass feature source is assumed to be the same as subclass source.",

String[] parts = match.split("\\|");
String linkText = parts[0];
if (parts.length < 6) {
tui().errorf("Bad Subclass Feature Link {@subclassFeature %s} in %s", match, getSources());
return linkText;
}
String className = parts[1];
String classSource = parts[2].isBlank() ? "phb" : parts[2];
String subclass = parts[3];
Expand Down

0 comments on commit 3e8d6b2

Please sign in to comment.