Make weapons rollable from the character sheet

This commit is contained in:
Johannes Loher 2021-03-04 00:14:16 +01:00
parent c1c0f41743
commit 3d272f2b92
13 changed files with 173 additions and 66 deletions

View file

@ -124,8 +124,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Data<DS4Actor>> {
html.find(".item-change").on("change", this._onItemChange.bind(this));
// Rollable abilities.
html.find(".rollable").click(this._onRoll.bind(this));
html.find(".rollable-item").on("click", this._onRoll.bind(this));
}
/**
@ -239,17 +238,9 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Data<DS4Actor>> {
*/
protected _onRoll(event: JQuery.ClickEvent): void {
event.preventDefault();
const element = event.currentTarget;
const dataset = element.dataset;
if (dataset.roll) {
const roll = new Roll(dataset.roll, this.actor.data.data);
const label = dataset.label ? `Rolling ${dataset.label}` : "";
roll.roll().toMessage({
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: label,
});
}
const id = $(event.currentTarget).parents(".item").data("itemId");
const item = this.actor.getOwnedItem(id);
item.roll();
}
/** @override */