Skip to content

Commit

Permalink
🐛 Fix SRD value for some base races
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed May 24, 2024
1 parent d9a7887 commit bcb3121
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public JsonNode mergeSubrace(JsonNode subraceNode, JsonNode raceNode) {
}
SourceField.name.removeFrom(copyFrom);
SourceField.name.setIn(subraceOut, Json2QuteRace.getSubraceName(raceName, subraceName));
} else {
Tools5eFields.srd.copy(raceNode, subraceOut);
Tools5eFields.basicRules.copy(raceNode, subraceOut);
}

// merge abilities
Expand All @@ -148,7 +151,7 @@ public JsonNode mergeSubrace(JsonNode subraceNode, JsonNode raceNode) {
ArrayNode outAbility = (ArrayNode) RaceFields.ability.getFrom(subraceOut);
// If the base race doesn't have any ability scores, make a set of empty records
if (RaceFields.ability.existsIn(overwrite) || outAbility == null) {
subraceOut.set("ability", RaceFields.ability.getFrom(copyFrom));
RaceFields.ability.copy(copyFrom, subraceOut);
} else if (cpySrAbility.size() != outAbility.size()) {
// if (cpy.ability.length !== cpySr.ability.length) throw new Error(`Race and subrace ability array lengths did not match!`);
tui().errorf("Error (%s): Unable to merge abilities (different lengths). CopyTo: %s, CopyFrom: %s", subraceOut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@ void addToIndex(Tools5eIndexType type, JsonNode node) {
TtrpgConfig.sourceToIdMapping(source, id);
}
}
addSrdEntry(key, node);
if (node.has("familiar")) {
familiarKeys.add(key);
}
}

void addSrdEntry(String key, JsonNode node) {
if (node.has("srd")) {
JsonNode srd = node.get("srd");
if (srd.isTextual()) {
Expand All @@ -357,9 +363,6 @@ void addToIndex(Tools5eIndexType type, JsonNode node) {
srdKeys.add(key);
}
}
if (node.has("familiar")) {
familiarKeys.add(key);
}
}

void addAlias(String key, String alias) {
Expand Down Expand Up @@ -507,6 +510,7 @@ public void findRaceVariants() {
TtrpgValue.indexKey.setIn(sr, srKey);

nodeIndex.put(srKey, sr);
addSrdEntry(srKey, sr);
subraces.add(sr);

// Add expected alias: {@race Aasimar (Fallen)|VGM}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void testLiveData_5e(QuarkusMainLauncher launcher) {
final Path srd_index = testOutput.resolve("srd-index");
TestUtils.deleteDir(srd_index);

LaunchResult result = launcher.launch("--index",
LaunchResult result = launcher.launch("--index", "--debug",
"-o", srd_index.toString(),
TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString(),
TestUtils.TEST_RESOURCES.resolve("dice-roller.json").toString(),
Expand Down

0 comments on commit bcb3121

Please sign in to comment.