Skip to content

Commit c50691c

Browse files
committed
🐛 trim allowed sources; fix opt feature lookup; tablegroup alias; shared monster shortname
1 parent cf68d57 commit c50691c

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

src/main/java/dev/ebullient/convert/config/CompendiumConfig.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ public boolean onlySources(List<String> sources) {
135135
return allowedSources.stream().allMatch(sources::contains);
136136
}
137137

138-
public String getAllowedSourcePattern() {
139-
return allSources ? "([^|]+)" : "(" + String.join("|", allowedSources) + ")";
140-
}
141-
142138
public boolean readSource(Path p, List<Fix> fixes, BiConsumer<String, JsonNode> callback) {
143139
return tui.readFile(p, fixes, callback);
144140
}
@@ -264,8 +260,13 @@ void allowSource(String source) {
264260
return;
265261
}
266262
String s = source.toLowerCase();
267-
allowedSources.add("all".equals(s) ? "*" : s);
268-
allSources = allowedSources.contains("*");
263+
if ("all".equals(s) || "*".equals(s)) {
264+
allSources = true;
265+
allowedSources.clear();
266+
allowedSources.add("*");
267+
} else if (!allSources) {
268+
allowedSources.add(s);
269+
}
269270

270271
if (!allSources) {
271272
// If this source maps to an abbreviation, include that, too

src/main/java/dev/ebullient/convert/tools/dnd5e/OptionalFeatureIndex.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ public OptionalFeatureType get(JsonNode node) {
112112
}
113113

114114
public OptionalFeatureType get(String featureType) {
115-
OptionalFeatureType type = optFeatureIndex.get(featureType.toLowerCase());
116-
if (type == null && unresolvedFeatureTypes.add(featureType)) {
117-
tui().logf(Msg.UNRESOLVED, "OptionalFeatureType %s not found", featureType);
115+
var lowerType = featureType.toLowerCase();
116+
OptionalFeatureType type = optFeatureIndex.get(lowerType);
117+
if (type == null && unresolvedFeatureTypes.add(lowerType)) {
118+
tui().logf(Msg.UNRESOLVED, "OptionalFeatureType %s not found", lowerType);
118119
}
119120
return type;
120121
}

src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eIndex.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ void addToIndex(Tools5eIndexType type, JsonNode node) {
280280
case table, tableGroup -> {
281281
SourceAndPage sp = new SourceAndPage(node);
282282
tableIndex.computeIfAbsent(sp, k -> new ArrayList<>()).add(node);
283+
if (type == Tools5eIndexType.tableGroup) {
284+
addAlias(key.replace("tablegroup", "table"), key);
285+
}
283286
}
284287
case language -> {
285288
if (HomebrewFields.fonts.existsIn(node)) {

src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eJsonSourceCopier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ void doAddSkills(String originKey, JsonNode modInfo, ObjectNode target) {
680680
}
681681
}
682682

683-
private String getShortName(JsonNode target, boolean isTitleCase) {
683+
public static String getShortName(JsonNode target, boolean isTitleCase) {
684684
String name = SourceField.name.getTextOrEmpty(target);
685685
JsonNode shortName = Tools5eFields.shortName.getFrom(target);
686686
boolean isNamedCreature = MonsterFields.isNamedCreature.booleanOrDefault(target, false);
@@ -705,7 +705,7 @@ private String getShortName(JsonNode target, boolean isTitleCase) {
705705
return prefix + getShortNameFromName(name, isNamedCreature);
706706
}
707707

708-
private String getShortNameFromName(String name, boolean isNamedCreature) {
708+
public static String getShortNameFromName(String name, boolean isNamedCreature) {
709709
String result = name.split(",")[0]
710710
.replaceAll("(?i)(?:adult|ancient|young) \\w+ (dragon|dracolich)", "$1");
711711

src/test/java/dev/ebullient/convert/config/ConfiguratorTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ public void testSources() throws Exception {
5858
assertThat(config.allSources()).isFalse();
5959
assertThat(config.sourceIncluded("phb")).isTrue();
6060
assertThat(config.sourceIncluded("scag")).isFalse();
61-
assertThat(config.getAllowedSourcePattern()).contains("phb");
62-
assertThat(config.getAllowedSourcePattern()).contains("dmg");
63-
assertThat(config.getAllowedSourcePattern()).contains("xge");
64-
assertThat(config.getAllowedSourcePattern()).contains("tce");
65-
assertThat(config.getAllowedSourcePattern()).contains("wbtw");
61+
assertThat(config.sourceIncluded("dmg")).isTrue();
62+
assertThat(config.sourceIncluded("xge")).isTrue();
63+
assertThat(config.sourceIncluded("tce")).isTrue();
64+
assertThat(config.sourceIncluded("wbtw")).isTrue();
6665
});
6766
}
6867

@@ -78,7 +77,6 @@ public void testFromAll() throws Exception {
7877
assertThat(config).isNotNull();
7978
assertThat(config.allSources()).isTrue();
8079
assertThat(config.sourceIncluded("scag")).isTrue();
81-
assertThat(config.getAllowedSourcePattern()).contains("([^|]+)");
8280
});
8381
}
8482

src/test/java/dev/ebullient/convert/tools/dnd5e/CommonDataTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public CommonDataTests(TestInput variant, String config, Path toolsData) throws
6868
configurator.readConfiguration(TestUtils.TEST_RESOURCES.resolve("5e/images-remote.json"));
6969

7070
index = new Tools5eIndex(TtrpgConfig.getConfig());
71+
Tools5eLinkifier.instance().reset();
7172

7273
if (dataPresent) {
7374
templates.setCustomTemplates(TtrpgConfig.getConfig());
@@ -396,9 +397,9 @@ public void testMonsterYamlBody(Path outputPath) {
396397
yaml = false; // end yaml block
397398
} else if (yaml) {
398399
statblock.add(l);
399-
if (l.contains("*")) {
400-
errors.add(String.format("Found '*' in %s: %s", p, l));
401-
}
400+
// if (l.contains("*")) {
401+
// errors.add(String.format("Found '*' in %s: %s", p, l));
402+
// }
402403
if (l.contains("\"desc\": \"\"")) {
403404
errors.add(String.format("Found empty description in %s: %s", p, l));
404405
}

src/test/java/dev/ebullient/convert/tools/dnd5e/FilterAllTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ public void testMonsterYamlBody() {
573573
@Test
574574
public void testMonster2024() {
575575
commonTests.testMonster2024(outputPath);
576+
577+
assertThat(commonTests.index.isIncluded("monster|archmage|xmm")).isTrue();
578+
assertThat(commonTests.index.isIncluded("item|wand|xphb")).isTrue();
576579
}
577580

578581
@Test

0 commit comments

Comments
 (0)