Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise relationship between Item5e#use and AbilityUseDialog.create #2387

Closed
Fyorl opened this issue Jul 26, 2023 · 1 comment
Closed

Revise relationship between Item5e#use and AbilityUseDialog.create #2387

Fyorl opened this issue Jul 26, 2023 · 1 comment
Labels
api breaking Breaking changes
Milestone

Comments

@Fyorl
Copy link
Contributor

Fyorl commented Jul 26, 2023

There is some duplicated logic between the two, and it is not clear which of them is ultimately responsible for configuring the resulting item use data. The proposed changes are as follows:

  • Refactor construction of the ItemUseConfiguration to a centralised location so that there is a single authoritative source for this logic, and it can be shared.
    • Item5e#use will use this method determine what the default configuration should be, and this can be overridden via the config parameter, or via the dnd5e.preUseItem hook.
    • AbilityUseDialog.create will use this method determine what values it needs to prompt the user for.
  • Refactor ability-use.hbs to allow for the checked states and default drop-down selections to be passed in via template data.
  • Item5e#use should pass its ItemUseConfiguration to AbilityUseDialog.create. This configuration will be used to determine the default state of the prompts that AbilityUseDialog will display to the user, per the changes to the template above.
  • When the user makes their final choices in AbilityUseDialog, this is fed back to Item5e#use, which updates the final ItemUseConfiguration.

Related:

@Fyorl Fyorl added api breaking Breaking changes labels Jul 26, 2023
@Fyorl
Copy link
Contributor Author

Fyorl commented Jul 26, 2023

Even though AbilityUseDialog.create is only ever called by Item5e#use within the system, it is public API so the change in behaviour here should be considered breaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api breaking Breaking changes
Projects
None yet
Development

No branches or pull requests

1 participant