Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,25 @@ public Set<String> findSubclasses(String classKey) {
return subclassMap.getOrDefault(classKey, Set.of());
}

/**
* Resolve the effective class source through reprints.
* If the class identified by className+classSource was reprinted
* (e.g., PHB Druid → XPHB Druid), return the reprint target's source.
*/
public String resolveClassSource(String className, String classSource) {
String classKey = String.join("|",
Tools5eIndexType.classtype.name(),
className, classSource).toLowerCase();
String reprint = reprints.get(classKey);
if (reprint != null) {
Tools5eSources reprintSources = Tools5eSources.findSources(reprint);
if (reprintSources != null && reprintSources.includedByConfig()) {
return reprintSources.primarySource();
}
}
return classSource;
}

public Set<String> findClassFeatures(String classOrSubclassKey) {
return classFeatures.getOrDefault(classOrSubclassKey, Set.of());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ public String getSubclassResource(String subclassKey) {
}

public String getSubclassResource(String subclass, String parentClass, String classSource, String subclassSource) {
// Resolve classSource through reprints (e.g., PHB → XPHB when PHB class is reprinted)
classSource = index.resolveClassSource(parentClass, classSource);
String parentFile = Tui.slugify(parentClass);
String defaultSource = Tools5eIndexType.classtype.defaultOutputSource();
if (!classSource.equalsIgnoreCase(defaultSource) &&
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/5e/sources-homebrew.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"MM",
"EGW",
"FTD",
"PHB"
"PHB",
"XPHB"
]
},
"include": [
Expand Down
Loading