foundryvtt / dnd5e

An implementation of the 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com).
MIT License
291 stars 201 forks source link

Request: Recognize flags for consumable attributes and resources #2412

Open JPMeehan opened 1 year ago

JPMeehan commented 1 year ago

As a module developer, I would like to be able to add module-defined consumable attributes (e.g. Power Points) as consumable resources for actions and resource bars.

Currently, everything is assumed to be a property of system; I would appreciate handling that changes the context if an attribute starts with flags

JPMeehan commented 9 months ago

It seems I might need to do this as my own PR

For the attribute bars

Sample typedef for the registration

/**
* @typedef {object} RegisteredAttributeFlag
* @param {boolean} isBar    - Bar or Single Value
* @param {string} label        - Unlocalized label that gets run through preLocalize
* @param {string} attribute - The full attribute path under `flags` - `["module-id"].myProp`
*                             If `isBar` is true, myProp is an object with a `value` and `max` field
*                             If `isBar` is false, myProp is numeric
*/
JPMeehan commented 9 months ago

The consumable resources are a related issue; I'm unsure if I should stick them in the existing Attributes space or add a new entry to CONFIG.DND5E.abilityConsumptionTypes; the latter is already doable on a module end and would mostly just exist to standardize the display but otherwise not add much.

Fyorl commented 9 months ago
  • I think the "fix" is that there needs to be a CONFIG registration that getTrackedAttributes() can call to insert extra bars or static properties.

This is exists as CONFIG.Actor.trackableAttributes, and we do use it in the dnd5e system. See here for information on the core API.

JPMeehan commented 6 months ago

Reviving this in the wake of 3.0's deprecation of resources

Right now, the item-oriented resource tracking works well for resources that are scaled to a specific class or are a function of level (e.g. something that's usable 2x proficiency). It is NOT useful for something that has scaling that interacts with multiclassing, such as Spell Points or some third party psionics systems that have Psi Points or other such systems.

It would be useful if there was a way to have that kind of information provided to items that would be pulling from those pools as well as have it tracked on a token bar.

JPMeehan commented 6 months ago

Hmm, looking I do see that flags are included in roll data. That does offer an option for making it show on the resource bar at least by setting up an item and having its max uses tied to @flags.moduleID..., although that still leaves some complications with "upcasting"