RC-51 | Roll Abilities

This commit is contained in:
Oliver-Akins 2024-12-29 21:28:13 -07:00
parent 23cad8fcc3
commit 0319841a01
14 changed files with 327 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import { Logger } from "../../utils/Logger.mjs";
const { HandlebarsApplicationMixin } = foundry.applications.api;
const { ActorSheetV2 } = foundry.applications.sheets;
const { Roll } = foundry.dice;
export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2) {
@ -23,7 +24,9 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2)
window: {
resizable: false,
},
actions: {},
actions: {
roll: this.rollDice,
},
form: {
submitOnChange: true,
closeOnSubmit: false,
@ -131,5 +134,24 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2)
// #endregion
// #region Actions
static async rollDice(_$e, el) {
const data = el.dataset;
const formula = data.formula;
Logger.debug(`Attempting to roll formula: ${formula}`);
let flavor;
if (data.flavor) {
flavor = localizer(
data.flavor,
);
}
const roll = new Roll(formula);
await roll.evaluate();
await roll.toMessage({
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor,
});
};
// #endregion
};