ebullient / ttrpg-convert-cli

Utility to convert JSON data (for content you own) from 5etools or pf2etools into Obsidian-friendly Markdown.
https://www.ebullient.dev/projects/ttrpg-convert-cli/
Apache License 2.0
179 stars 37 forks source link

[dnd5e] `get5eInitiativeYaml` and `get5eStatblockYaml` not returning proper yaml #183

Closed Stackclash closed 1 year ago

Stackclash commented 1 year ago

I'm trying to get the yaml for a statblock but both of these methods don't return valid yaml. I'm not sure if I'm using it correctly. Running both of the results through a yamllint gives errors. I am using v2.0.5 of the cli.

Template

--- {resource.get5eInitiativeYaml} ---

```statblock {resource.get5eStatblockYaml} ```

Result

--- name: Beholder ac: 18 hp: 180 hit_dice: 19d10 + 76 cr: '13' stats: [ 10, 14, 18, 17, 15, 17 ] source: [ MM, ToA, WDMM, GoS, ERLW, EGW, TCE, CM, JttRC, LoX, KftGV ] ---

"name": "Beholder"
"size": "Large"
"type": "aberration"
"alignment": "Lawful Evil"
"ac": !!int "18"
"hp": !!int "180"
"hit_dice": "19d10 + 76"
"stats":
- !!int "10"
- !!int "14"
- !!int "18"
- !!int "17"
- !!int "15"
- !!int "17"
"speed": "walk 0 ft., fly 20 ft. (hover)"
"saves":
  "Charisma": !!int "8"
  "Wisdom": !!int "7"
  "Intelligence": !!int "8"
"skillsaves":
  "Perception": !!int "12"
"condition_immunities": "prone"
"senses": "darkvision 120 ft., passive Perception 22"
"languages": "Deep Speech, Undercommon"
"cr": "13"
"traits":
- !!dev.ebullient.convert.tools.dnd5e.qute.Trait
  "desc": "The beholder's central eye creates an area of antimagic, as in the [antimagic\
    \ field](/compendium/spells/antimagic-field.md) spell, in a 150-foot cone. At\
    \ the start of each of its turns, the beholder decides which way the cone faces\
    \ and whether the cone is active. The area works against the beholder's own eye\
    \ rays."
  "name": "Antimagic Cone"
"actions":
- !!dev.ebullient.convert.tools.dnd5e.qute.Trait
  "desc": "Melee Weapon Attack: dice: d20+5 (+5 to hit), reach 5 ft., one target.\
    \ Hit: dice: 4d6|avg (4d6) piercing damage."
  "name": "Bite"
- !!dev.ebullient.convert.tools.dnd5e.qute.Trait
  "desc": "The beholder shoots three of the following magical eye rays at random (reroll\
    \ duplicates), choosing one to three targets it can see within 120 feet of it:\n\
    \n- 1. Charm Ray. The targeted creature must succeed on a DC 16 Wisdom saving\
    \ throw or be [charmed](compendium/rules/conditions.md#charmed) by the beholder\
    \ for 1 hour, or until the beholder harms the creature.  \n- 2. Paralyzing Ray.\
    \ The targeted creature must succeed on a DC 16 Constitution saving throw or be\
    \ [paralyzed](compendium/rules/conditions.md#paralyzed) for 1 minute. The target\
    \ can repeat the saving throw at the end of each of its turns, ending the effect\
    \ on itself on a success.  \n- 3. Fear Ray. The targeted creature must succeed\
    \ on a DC 16 Wisdom saving throw or be [frightened](compendium/rules/conditions.md#frightened)\
    \ for 1 minute. The target can repeat the saving throw at the end of each of its\
    \ turns, ending the effect on itself on a success.  \n- 4. Slowing Ray. The\
    \ targeted creature must succeed on a DC 16 Dexterity saving throw. On a failed\
    \ save, the target's speed is halved for 1 minute. In addition, the creature can't\
    \ take reactions, and it can take either an action or a bonus action on its turn,\
    \ not both. The creature can repeat the saving throw at the end of each of its\
    \ turns, ending the effect on itself on a success.  \n- 5. Enervation Ray.\
    \ The targeted creature must make a DC 16 Constitution saving throw, taking 36\
    \ (dice: 8d8|avg (8d8)) necrotic damage on a failed save, or half as much\
    \ damage on a successful one.  \n- 6. Telekinetic Ray. If the target is a\
    \ creature, it must succeed on a DC 16 Strength saving throw or the beholder moves\
    \ it up to 30 feet in any direction. It is [restrained](compendium/rules/conditions.md#restrained)\
    \ by the ray's telekinetic grip until the start of the beholder's next turn or\
    \ until the beholder is [incapacitated](compendium/rules/conditions.md#incapacitated).\
    \  \n\n    If the target is an object weighing 300 pounds or less that isn't being\
    \ worn or carried, it is moved up to 30 feet in any direction. The beholder can\
    \ also exert fine control on objects with this ray, such as manipulating a simple\
    \ tool or opening a door or a container.  \n- 7. Sleep Ray. The targeted creature\
    \ must succeed on a DC 16 Wisdom saving throw or fall asleep and remain [unconscious](compendium/rules/conditions.md#unconscious)\
    \ for 1 minute. The target awakens if it takes damage or another creature takes\
    \ an action to wake it. This ray has no effect on constructs and undead.  \n-\
    \ 8. Petrification Ray. The targeted creature must make a DC 16 Dexterity\
    \ saving throw. On a failed save, the creature begins to turn to stone and is\
    \ [restrained](compendium/rules/conditions.md#restrained). It must repeat the\
    \ saving throw at the end of its next turn. On a success, the effect ends. On\
    \ a failure, the creature is [petrified](compendium/rules/conditions.md#petrified)\
    \ until freed by the  [greater restoration](/compendium/spells/greater-restoration.md)\
    \ spell or other magic.  \n- 9. Disintegration Ray. If the target is a creature,\
    \ it must succeed on a DC 16 Dexterity saving throw or take dice: 10d8|avg (10d8)\
    \ force damage. If this damage reduces the creature to 0 hit points, its body\
    \ becomes a pile of fine gray dust.  \n\n    If the target is a Large or smaller\
    \ nonmagical object or creation of magical force, it is disintegrated without\
    \ a saving throw. If the target is a Huge or larger object or creation of magical\
    \ force, this ray disintegrates a 10-foot cube of it.  \n- 10. Death Ray.\
    \ The targeted creature must succeed on a DC 16 Dexterity saving throw or take\
    \ dice: 10d10|avg (10d10) necrotic damage. The target dies if the ray reduces\
    \ it to 0 hit points.  "
  "name": "Eye Rays"
"legendary_actions":
- !!dev.ebullient.convert.tools.dnd5e.qute.Trait
  "desc": "The beholder uses one random eye ray."
  "name": "Eye Ray"
"source":
- "MM"
- "ToA"
- "WDMM"
- "GoS"
- "ERLW"
- "EGW"
- "TCE"
- "CM"
- "JttRC"
- "LoX"
- "KftGV"
"image": "/compendium/bestiary/aberration/token/beholder.png"
ebullient commented 1 year ago

You should only need this (the get is a bean thing and can be removed):

---
{resource.5eInitiativeYaml}
---
```statblock
{resource.5eStatblockYaml}


I do not hand-tend/hand-create the YAML. It is generated by [SnakeYAML](https://github.com/snakeyaml/snakeyaml), which will produce spec-valid YAML that your linter may not like (but that doesn't mean it isn't valid YAML).

The full 5e statblock body is double quoted YAML syntax because the trait descriptions contain all kinds of characters that can make YAML upset. There is optional type information (I have pending changes that will suppress most of those), but they are valid.. 

Can you let me know which linter you're using, and what it is complaining about exactly?
Stackclash commented 1 year ago

I was using https://yamllint.com, but it seems that might not be a good website to use, because I tried https://jsonformatter.org/yaml-validator and it validated it just fine.

ebullient commented 1 year ago

I've heard mixed things about yamllint.com, so I would agree that isn't the best website. The similarly named python command line tool is a different thing, and should also be fine (IIUC, they are not related: https://stackoverflow.com/questions/38454142/yamllint-validation).

Is anything else not working right? In other words, do you have more questions or is there something that needs fixing or can we close this? 😁

Stackclash commented 1 year ago

I was trying to use the 5estatblock in the frontmatter, but it seems that it wasn't created for that. If that's the case we can close this.

ebullient commented 1 year ago

There are two examples of using generated yaml in the document header:

https://github.com/ebullient/ttrpg-convert-cli/blob/main/examples/templates/tools5e/monster2md-yamlStatblock-body.txt

https://github.com/ebullient/ttrpg-convert-cli/blob/main/examples/templates/tools5e/monster2md-yamlStatblock-header.txt

Are you having issues with either of these?

Stackclash commented 1 year ago

The header template wasn't putting actions and other information into initiative tracker. I ended up going with the body template and giving it the frontmatter of statblock: inline so that it was picked up by initiative tracker. Thanks for your help. We can close this.