Lavaeolous / PF1-StatBlock-Converter-Module

FoundryVTT Module to convert PF1 Statblocks into Foundry Actors (PC or NPC).
MIT License
14 stars 12 forks source link

Refactor #507

Closed mkahvi closed 2 years ago

mkahvi commented 2 years ago

This also adds basic .editorconfig to encourage at least minimally consistent style as it was really hard to do editing without massive inconsistent styling issues.

Also made object keys more uniform by removing a lot of string usage, but that shouldn't matter for most anything.

Note: This may introduce small problem with current health not being maxed, but that should be easy to fix by adding an update to set health to max around the time the conversion buff is created. Edit: This is now fixed.

Fixes #506 and #511

Lavaeolous commented 2 years ago

This breaks sometimes, i'll investigate.

But in general: Thank you very much for all the work you put into this!

How to reproduce error:

  1. Try to parse https://www.aonprd.com/NPCDisplay.aspx?ItemName=Savage%20Plant%20Sage
  2. Gets stuck in line 4012 of sbcParsers.js with game.pf1.documents.ItemPF.toConsumable(...).toObject is not a function
mkahvi commented 2 years ago

I was meaning to test it more, too, with extra creatures. I was working mostly with elder air elemental. More varied testing is obviously needed before it's merged.

Lavaeolous commented 2 years ago

The error happens with spell-based consumables, e.g. potions and stuff. The system wants me to use ItemSpellPF, as ItemPF.toConsumable() is deprecated. But ItemSpellPF is not found in game.pf1.documents. Maybe i'm a version behind, i'll check.

mkahvi commented 2 years ago

It's in CONFIG.Item.documentClasses.spell

Edit: The problem is it needs to be (await ...toConsumable()).toObject() The await was waiting on the toObject() instead which in turn was receiving a promise.

mkahvi commented 2 years ago

I'd like to point out that some errors in how this produces info might be caused by upstream bugs: https://gitlab.com/Furyspark/foundryvtt-pathfinder1/-/issues/1360

Spellbooks have for example slightly suspicious data with the per level slots, but it's functional at least.

mkahvi commented 2 years ago

Sound Warrior still breaks it but with different part. Namely subskill changes error out. And also comes with massive health boost.

Edit: Part of the problem seems to be that the actor, despite being created and awaited on, does not return correct data, until SBC is done with it. I don't understand why this is happening.

mkahvi commented 2 years ago

Okay, things seem to work out with the stated statblocks. The remaining bugs are not related to this PR that I can tell.

mkahvi commented 2 years ago

Unless there's other cases where this breaks, I believe I am done.

The SBC buff staggering is a bit unrelated to what most of this PR is about and I guess I could've posted as separate PR.

Lavaeolous commented 2 years ago

I'll check this again today and will merge if no other issues arise!