RedReign / FoundryVTT-BetterRolls5e

A module for modifying certain sheet functions on Foundry VTT Character sheets for D&D 5th Edition.
GNU General Public License v3.0
37 stars 67 forks source link

Unable to modify chatData.whisper to hide Dice So Nice rolls from other players #296

Open cs96and opened 3 years ago

cs96and commented 3 years ago

Hi, I'm the current maintainer of the Cautious Gamemaster's Pack. One of the features of that module is the ability to hide rolls made by hidden tokens. This mostly works fine (apart from #295), but when Better Rolls is enabled, the Dice So Nice animations still display on other players' screens.

I tried catching the messageBetterRolls hook to modify the whisper data, but this whisper data is not passed to the Dice So Nice's showForRoll() call

CustomItemRoll.toMessage() (custom-roll.js line 837)...

await Hooks.callAll("messageBetterRolls", this, chatData);
await this.dicePool.flush(hasMaestroSound);

My hook callback is modifying the chatData.whisper property, but this is not passed to dicePool.flush().

DiceCollection.flush() (dice-collection.js line 52)...

const hasDice = pool.dice.length > 0;
if (game.dice3d && hasDice) {
    const wd = Utils.getWhisperData();
    await game.dice3d.showForRoll(pool, game.user, true, wd.whisper, wd.blind || false);
}

It just calls Utils.getWhisperData() to get the whisper data from the roll mode drop down. However the whisper data was already calculated in CustomItemRoll.toMessage() and then possibly modified.

TL;DR - it would be nice if DiceCollection.flush() optionally used the already calculated whisper data, rather then calculating it again from scratch.

CarlosFdez commented 3 years ago

Makes sense to me for it to do so. I'll add whisper data as an optional parameter to flush and it should work out just fine.