Merge branch '14-item-rolls'

This commit is contained in:
Andrew 2020-08-09 20:51:49 -07:00
commit 9bb368d9e2
5 changed files with 69 additions and 2 deletions

View file

@ -25,6 +25,7 @@ export class SimpleActorSheet extends ActorSheet {
for ( let attr of Object.values(data.data.attributes) ) {
attr.isCheckbox = attr.dtype === "Boolean";
}
data.shorthand = !!game.settings.get("worldbuilding", "macroShorthand");
return data;
}
@ -34,6 +35,19 @@ export class SimpleActorSheet extends ActorSheet {
activateListeners(html) {
super.activateListeners(html);
// Handle rollable attributes.
html.find('.items .rollable').click(ev => {
let button = $(ev.currentTarget);
let r = new Roll(button.data('roll'), this.actor.getRollData());
const li = button.parents(".item");
const item = this.actor.getOwnedItem(li.data("itemId"));
r.roll().toMessage({
user: game.user._id,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: `<h2>${item.name}</h2><h3>${button.text()}</h3>`
});
});
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;

View file

@ -82,4 +82,11 @@ Hooks.once("init", async function() {
}
}
/**
* Slugify a string.
*/
Handlebars.registerHelper('slugify', function(value) {
return value.slugify({strict: true});
});
});