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

item/activity rollRecharge ignores message.create set to false in dnd5e.preRollRechargeV2 but honors it when set via dnd5e.preRollRecharge #4751

Open
tposney opened this issue Nov 19, 2024 · 0 comments · May be fixed by #4757
Assignees
Labels
bug Functionality which is not working as intended
Milestone

Comments

@tposney
Copy link

tposney commented Nov 19, 2024

Due to the roll refactor rollRecharge ignores changing message.create to false preRollRechargeV2.
In the code createMessage (which determines display the chat card or not) is recorded before calling BasicRoll.build, but after the preRollRecharge hook fires, so that changes made in preRollRechargeV2 are ignored, but changes made in preRollRecharge are honored.

I could not see any simple way to resolve the issue but wanted to understand if this is a wont fix and will work around it.,

    if ( "dnd5e.preRollRecharge" in Hooks.events ) {
      foundry.utils.logCompatibilityWarning(
        "The `dnd5e.preRollRecharge` hook has been deprecated and replaced with `dnd5e.preRollRechargeV2`.",
        { since: "DnD5e 4.0", until: "DnD5e 4.4" }
      );
      const hookData = {
        formula: rollConfig.rolls[0].parts[0], data: rollConfig.rolls[0].data,
        target: rollConfig.rolls[0].options.target, chatMessage: messageConfig.create
      };
      if ( Hooks.call("dnd5e.preRollRecharge", this, hookData) === false ) return;
      rollConfig.rolls[0].parts[0] = hookData.formula;
      rollConfig.rolls[0].data = hookData.data;
      rollConfig.rolls[0].options.target = hookData.target;
      messageConfig.create = hookData.chatMessage;
    }

    const createMessage = messageConfig.create !== false;
    messageConfig.create = false;
    const rolls = await CONFIG.Dice.BasicRoll.build(rollConfig, dialogConfig, messageConfig);
    ```js
@Fyorl Fyorl added the bug Functionality which is not working as intended label Nov 20, 2024
@Fyorl Fyorl self-assigned this Nov 20, 2024
@Fyorl Fyorl added this to the D&D5E 4.1.2 milestone Nov 20, 2024
@Fyorl Fyorl modified the milestones: D&D5E 4.1.2, D&D5E 4.2.0 Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality which is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants