pafvel / dragonbane

Other
11 stars 6 forks source link

Add manualBanes/manualBoons to test rolls #42

Closed rayners closed 4 months ago

rayners commented 4 months ago

Add an option to manually specify additional banes/boons to a test roll (via manualBanes and manualBoons).

The specific use case I have in mind is making a self-rally roll, which calls for a WIL roll with a bane, but I couldn't spot a way to do that without the player having to manually add the bane to the roll. And manually adding the bane isn't straightforward either because the rollAttribute method exposed on game.dragonbane skips the dialog entirely.

This would allow me to use this code inside the Argon HUD module:

game.dragonbane.rollAttribute(this.actor, 'WIL', { manualBanes: 1 });

From my local testing (console and chat message for the result):

Screen Shot 2024-03-06 at 12 29 02 AM Screen Shot 2024-03-06 at 12 18 43 AM

The tooltip output isn't as good as I was aiming for, but it's late and I didn't manage to work out a way to compress ['Manual', 'Manual'] to ['Manual (x2)'] without a bunch more changes to parts of the code I'm less familiar with.

Happy to make any changes you feel are appropriate.

pafvel commented 4 months ago

It should have been possible already, but there were a couple of missing links. I addressed this in https://github.com/pafvel/dragonbane/commit/bde7d4db3e8feda96ef49a4b01410af65d1845f4

It is now possible to do like this:

let options = {};
options.boons = [{source: "Manual", value: true}];

for (const token of canvas.tokens.controlled) {
  game.dragonbane.rollAttribute(token.actor, "con", options);
}

The source parameter should be the localized text that will be shown in the dice result (and in the roll dialog if options.defaultBanesBoons = false).

rayners commented 4 months ago

@pafvel Even better! No idea why that approach didn't occur to me in the first place. 🤦‍♂️