Skip to content

Add "postAbilities" phase, prepare item UsesField data in that phase, prepare @item.uses.value-using changes' phase to "postAbilities" - #7368

Draft
roth-michael wants to merge 2 commits into
foundryvtt:6.0.xfrom
roth-michael:post-abilities-phase
Draft

Add "postAbilities" phase, prepare item UsesField data in that phase, prepare @item.uses.value-using changes' phase to "postAbilities"#7368
roth-michael wants to merge 2 commits into
foundryvtt:6.0.xfrom
roth-michael:post-abilities-phase

Conversation

@roth-michael

Copy link
Copy Markdown
Contributor

Further enables #3011 by allowing use of @item.uses.value specifically, which currently wouldn't be prepared in time for use in a change value. Builds on #7366.
Changes:

  • Moved preparation of Item Uses in ActivitiesTemplate to its own method, ActivitiesTemplate#prepareUsesData. ActivitiesTemplate#prepareFinalActivityData now no longer requires roll data passed to it (as such, removed various getRollData calls in all mixing item subtypes' calls to that method)
  • Added a new AE change phase, postAbilities, which is fired at the end of CommonTemplate#prepareAbilities
  • Prior to application of any changes with this phase, all item uses data is prepared
  • During base data prep for base AE subtype, if any change's value includes @item.uses.value in it, set its phase to the new phase

Effectively, the only not-present-at-"initial"-phase item data that might reasonably be used in an AE is uses.value, because previously it was prepared after (or immediately before, after #7366) the final stage. Ideally, it would be accessible as early as possible. There are certainly first party items which have limited uses depending on ability modifier, and so it must at earliest be after those are calculated.

Questions/potential issues:

  • Gating @item.uses.value-valued changes to be only after ability prep means you cannot, for instance, modify your strength value based on remaining uses of a given item. Since these items presumably would not be referencing ability mod in their max uses field, this could be worked around by prepping Uses data during "initial" for non-ability-mod-referencing items, and in "postAbilities" for ability-mod-referencing items. This then would also need to be considered when setting change phase during prep.
  • Moving Uses data prep to be pre-final for items means there may be some cases where we aren't able to evaluate max uses properly. Max uses equal to max HP, for instance. We may need to consider preparation across multiple phases based on the contents of uses.max.
  • There is absolutely room to further modify phase during data prep. It would now, for instance, be possible to increase system.spell.spell1.max during "final" phase, and so we should consider how to coerce phase to the "appropriate" value for such changes.

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