Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Pathfinder 2e YAML statblocks #497

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

miscoined
Copy link
Collaborator

This is done using a new Pathfinder 2e Bestiary layout which currently has an open PR here. This is part of an overall plan to add this statblock layout natively to the Fantasy Statblocks plugin (javalent/fantasy-statblocks#436)

Opening this as a draft PR for now until the base layout PR is done. I haven't added any documentation for this yet either - I'm currently planning to leave that til I do a full check over the documentation after all the changes I've made to the PF2e side of things so I can also catch any other documentation errors, as well as hopefully add auto-generation of documentation for the template extension methods.

The main structural change here is the addition of a new template resource boolean: asYamlStatblock, which is defined for embedded templates only and is used to determine whether it's being rendered within a YAML statblock. I specifically wanted a way for template authors to customize the YAML output themselves and this seemed like the best tradeoff between functionality and not totally reworking how parsing and rendering works.

Allows template authors to more easily access the components of a note
reference rather than just the markdown link text.
- Don't embed the "**AC**" within the AC string
- Rename StringUtil.format to formatIfPresent
- Remove joinWithPrefix in favour of formatIfPresent
- Add some helper template strings for later use in YAML statblocks
- Move the enum into QuteDataActivity directly so that we don't have
  to pass the rule, glyph, and name in every time when it'll be staying
  the same for a given action.
- Make QuteDataActivity store a QuteDataRef to centralize some of the
  link formatting
- Allows template authors to compare the activity itself and
  theoretically choose what kind of rendering they want
Replace with renderEmbeddedTemplate. This will make the next changes
easier.
miscoined added 10 commits July 13, 2024 10:40
Generally pull things up into the main class rather than methods of the
JsonNodeReader.
- Move entries, traits, and tags into Json2QuteBase
- Incidentally fix a few cases where tags aren't populated correctly
Comparison was done with ==, not .equals, so it never triggered.
Fits better with the other methods defined in that class rather than the
recursive parse methods in JsonSource
- 🚸 Allows template authors to access trait reference data directly rather
than just the markdown doc.
- 🚸 Incidentally fixes trait ordering so that it's alphabetically by trait
  name, rather than by whether or not there's a link.
- 🔥 Remove alignment field handling for creature nodes - it was never
  used in the data
Replace with linkifyListFrom. It's unnecessary now that we're no longer
using it for creatures (which have their alignments defined directly
within the trait field anyway). This also means that alignment
formatting is easier to understand as it's all centralized within the
linkifier now.
The implementation was the same in both trees. This makes debugging
easier.
These are all read in as traits anyway, so store them as references.
@miscoined miscoined force-pushed the statblock branch 2 times, most recently from da94349 to 29a3253 Compare July 14, 2024 02:53
- Add helpers for filtering creature traits
- Strip dice roller syntax from embedded yaml templates
- Fix an embarrassing regex backreferencing bug where I
  was accidentally turning all costs into a single 0x01
  unicode character
- Remove trailing newlines for ability triggers as well
- 💥 Remove, rename, and change QuteAbility methods to better suit the
  data
- 🚸 Add an asYamlStatblock section to the default template for
  YAML ability statblock rendering
- Add a method to unfold newlines for use with specific YAML multiline
  string syntax
- Add a method to quote YAML strings only when necessary
- Change tests to be more specific about which asterisks are disallowed
- Add some workarounds for specific statblocks
- Use ** rather than __ for bold formatting. This is primarily for
  consistency - we can't reliably change all instances of asterisk
  formatting within embedded text without risking changing asterisks
  which aren't formatting related, so we may as well double down on
  using asterisks for formatting since they're only reserved in specific
  contexts.
- Use {#with defenses} for the big defenses block
- Add a QuteDataTraits - dedicated class to hold traits so we can have
  easier bare linking
- Rename collectTraitsFrom to getTraits, and pull Tag adding into
  QuteDataTraits
- Fix creature statblock so it doesn't generate traits property when we
  don't have any generic traits
- Fix some items being incorrectly tagged with their source (e.g. tagged
  as "trait/preparation-sog2" rather than "trait/preparation")
- Fix some incorrectly formatted markdown links when the trait is
  surrounded in square brackets (e.g. for classes and magical traditions)

Fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant