hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.2K
active users

b4ux1t3 :trek_ds9_sisko:#1️⃣

Taking a side quest to figure out if you can parse stat blocks with a simple parser.

I think the language is consistent enough to be modeled with a context-free grammar, though it may even be possible to build a regex for it (or some other regular language parser).

Taking attacks as an example, they come in a couple flavors:

1. a number, "weapon", a modifier and a die roll (this sometimes has an effect)
2. a number, "spell" and a modifier
3. a number and an ability

1/n

Since a monster/creature/whatever can have multiple attacks, you separate them with "or". So, an attack would be defined as follows. (alt text has the text from the image)

2/n

Sure, there's a bit of complexity here, but it's also just one of the more complex parts of the stat block (maybe THE most complex?)

AC is a number and a description, HP is a number, MV is one of near, double near, and far, with modifiers (fly, e.g.), and then each stat is just a modifier, alignment is one of [C,N,L], and lvl is a number