Skip to content

Commit

Permalink
🎨 5e: name + source in statblock yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Oct 20, 2023
1 parent 18b37ed commit d30b75d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import dev.ebullient.convert.qute.ImageRef;
import dev.ebullient.convert.qute.NamedText;
import dev.ebullient.convert.tools.Tags;
import dev.ebullient.convert.tools.dnd5e.Tools5eIndexType;
import dev.ebullient.convert.tools.dnd5e.Tools5eSources;
import io.quarkus.qute.TemplateData;
import io.quarkus.runtime.annotations.RegisterForReflection;
Expand Down Expand Up @@ -239,7 +240,7 @@ public Map<String, String> getSkillMap() {
*/
public String get5eInitiativeYaml() {
Map<String, Object> map = new LinkedHashMap<>();
addUnlessEmpty(map, "name", name);
addUnlessEmpty(map, "name", name + yamlMonsterName());
addIntegerUnlessEmpty(map, "ac", acHp.ac);
addIntegerUnlessEmpty(map, "hp", acHp.hp);
addUnlessEmpty(map, "hit_dice", acHp.hitDice);
Expand All @@ -256,7 +257,7 @@ public String get5eInitiativeYaml() {
*/
public String get5eStatblockYaml() {
Map<String, Object> map = new LinkedHashMap<>();
addUnlessEmpty(map, "name", name);
addUnlessEmpty(map, "name", name + yamlMonsterName());
addUnlessEmpty(map, "size", size);
addUnlessEmpty(map, "type", type);
addUnlessEmpty(map, "subtype", subtype);
Expand Down Expand Up @@ -306,6 +307,15 @@ public String get5eStatblockYaml() {
.replaceAll("\\*([^*]+)\\*", "$1"); // bold em
}

public String yamlMonsterName() {
String source = getBooks().get(0);
if (Tools5eIndexType.monster.defaultSourceString().equalsIgnoreCase(source)) {
return "";
} else {
return " (" + source + ")";
}
}

Collection<NamedText> spellcastingToTraits() {
if (spellcasting == null) {
return List.of();
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/other/monster-all.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
obsidianUIMode: preview
cssclass: json5e-monster
statblock: inline
{#if resource.tags }
tags:
{#for tag in resource.tags}
Expand Down

0 comments on commit d30b75d

Please sign in to comment.