From bcb3121650070e9ec086a00eecdf1f0aee15db35 Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Tue, 21 May 2024 08:05:46 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20SRD=20value=20for=20some?= =?UTF-8?q?=20base=20races?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convert/tools/dnd5e/JsonSourceCopier.java | 5 ++++- .../ebullient/convert/tools/dnd5e/Tools5eIndex.java | 10 +++++++--- .../dev/ebullient/convert/Tools5eDataConvertTest.java | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/ebullient/convert/tools/dnd5e/JsonSourceCopier.java b/src/main/java/dev/ebullient/convert/tools/dnd5e/JsonSourceCopier.java index ad54b2f4..0329fb52 100644 --- a/src/main/java/dev/ebullient/convert/tools/dnd5e/JsonSourceCopier.java +++ b/src/main/java/dev/ebullient/convert/tools/dnd5e/JsonSourceCopier.java @@ -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 @@ -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, diff --git a/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eIndex.java b/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eIndex.java index 09c76bbf..88e8587c 100644 --- a/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eIndex.java +++ b/src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eIndex.java @@ -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()) { @@ -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) { @@ -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} diff --git a/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java b/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java index c83b2bda..32f84010 100644 --- a/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java +++ b/src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java @@ -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(),