Am I approaching character data updates incorrectly?

In my system I've constructed a core and modules directory where core handles all of the critical functions of the base system and the modules are additional systems that can be included or excluded at the whim of the GM (things such as psionics, magic, super powers, future technology, etc). To handle how these things interact, I've created a PcDataCalculator service to which modules may register their data calculation steps and dependencies ( in 5E terms, this would be like the Magic module registering the formula for determining a Wizard's number of prepared spells and indicating it's dependent on class-levels and intelligence. This whole process is intended to run as part of the actor's PrepareData function. The challenge I think I will run into is ActiveEffects. If active effects are run before this process, then an active effect impacting intelligence will cause prepared spells to be calculated correctly, but one that increases prepared spells by a value dependent on the subtotal value of prepared spells (such as 'double the number of prepared spells you can cast') would not work correctly. If run afterwards, I'd have the opposite problem. In my calculator process, I've got the ability to pass in a key for when a specific attribute is updated and calculate everything directly or indirectly dependent on that key, so if I could do the same with active effects and process them only as part of the relevant stats calculations instead of all at once, that would be great. Is there a better way to go about this?
2 Replies
arbron
arbron12mo ago
You could always split the processor to run twice, so one method will be called during prepareBaseData for any calculations that need to be done before active effects are applied and another called in prepareDerivedData for any information that relies on the results of active effects
Tim
Tim12mo ago
Another approach is to have multiple attributes for the spell count e.g. base/bonus/multiplier. These can each be modified by Active Effects and then the final value is calculated from all these values in the Derived phase. There could even be a standard set for any attribute and your core code could automatically compute the final value based on any attributes that are present. There could be a fixed set e.g. base/base-mod/base-multiplier/bonus/bonus-mod/bonus-multiplier/total-mod/toal-multiplier. This allows flexibility for active effects to make the precise changes that are required.
Want results from more Discord servers?
Add your server