Skip to content

Commit

Permalink
fix: template deployment for non-spells
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez committed May 20, 2021
1 parent 7bc0d48 commit 5196216
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions betterrolls5e/scripts/custom-roll.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,32 +591,35 @@ export class CustomItemRoll {

Hooks.call("preRollItemBetterRolls", this);

const { params, item } = this;
const consume = this.params.consume;
let placeTemplate = false;
const item = this.item;

// Pre-update item configurations
// Pre-update item configurations which updates the params
if (item) {
await ItemUtils.ensureFlags(item, { commit: true });

// Set up preset but only if there aren't fields
if (!this.fields || this.fields.length === 0) {
params.preset = params.preset ?? 0;
if (Number.isInteger(params.preset)) {
this.params.preset = this.params.preset ?? 0;
if (Number.isInteger(this.params.preset)) {
this.updateForPreset();
}
}
}

// Determine spell level and configuration settings
if (item.data.type === "spell" && consume && !params.slotLevel) {
const config = await this.configureSpell();
if (config === "error") {
this.error = true;
return;
}
// Get Params
const params = this.params;
const consume = params.consume;
let placeTemplate = params.useTemplate;

placeTemplate = config.placeTemplate;
// Determine spell level and configuration settings
if (item?.data.type === "spell" && consume && !params.slotLevel) {
const config = await this.configureSpell();
if (config === "error") {
this.error = true;
return;
}

placeTemplate = config.placeTemplate;
}

// Show Advantage/Normal/Disadvantage dialog if enabled
Expand Down Expand Up @@ -681,7 +684,7 @@ export class CustomItemRoll {
}

// Place the template if applicable
if (placeTemplate || (params.useTemplate && (item.data.type == "feat" || item.data.data.level == 0))) {
if (placeTemplate) {
ItemUtils.placeTemplate(item);
}
}
Expand Down

0 comments on commit 5196216

Please sign in to comment.