diff --git a/module/applications/roll.mjs b/module/applications/roll.mjs index 0fddc8a0..c9e0ee5e 100644 --- a/module/applications/roll.mjs +++ b/module/applications/roll.mjs @@ -13,6 +13,7 @@ export class DHRoll extends Roll { static async build(config={}, message={}) { const roll = await this.buildConfigure(config, message); + if(!roll) return; await this.buildEvaluate(roll, config, message={}); await this.buildPost(roll, config, message={}); return roll; @@ -35,14 +36,13 @@ export class DHRoll extends Roll { // Open Roll Dialog const DialogClass = config.dialog?.class ?? this.DefaultDialog; config = await DialogClass.configure(config, message); + if(!config) return; } - console.log(config) let roll = new this(config.formula, config.actor, config); for ( const hook of config.hooks ) { if ( Hooks.call(`${SYSTEM.id}.post${hook.capitalize()}RollConfiguration`, roll, config, message) === false ) return []; } - console.log(roll); return roll; } diff --git a/module/data/action/action.mjs b/module/data/action/action.mjs index 27d3cab6..3be1904c 100644 --- a/module/data/action/action.mjs +++ b/module/data/action/action.mjs @@ -220,6 +220,7 @@ export class DHBaseAction extends foundry.abstract.DataModel { // Proceed with Roll config = await this.proceedRoll(config); + if(!config) return; // Update Actor resources based on Action Cost configuration this.spendCost(config.costs.values); diff --git a/module/dialogs/d20RollDialog.mjs b/module/dialogs/d20RollDialog.mjs index 814630cd..d2e43e5e 100644 --- a/module/dialogs/d20RollDialog.mjs +++ b/module/dialogs/d20RollDialog.mjs @@ -22,7 +22,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio actions: { updateIsAdvantage: this.updateIsAdvantage, selectExperience: this.selectExperience, - // finish: this.finish + submitRoll: this.submitRoll }, form: { handler: this.updateRollConfiguration, @@ -80,6 +80,15 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio this.render(); } + static async submitRoll() { + await this.close({ submitted: true }); + } + + /** @override */ + _onClose(options={}) { + if ( !options.submitted ) this.config = false; + } + static async configure(config={}) { return new Promise(resolve => { const app = new this(config); diff --git a/module/dialogs/damageDialog.mjs b/module/dialogs/damageDialog.mjs index 832375be..5915f6e2 100644 --- a/module/dialogs/damageDialog.mjs +++ b/module/dialogs/damageDialog.mjs @@ -15,7 +15,9 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application width: 400, height: 'auto' }, - actions: {}, + actions: { + submitRoll: this.submitRoll + }, form: { handler: this.updateRollConfiguration, submitOnChange: true, @@ -38,6 +40,15 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application return context; } + static async submitRoll() { + await this.close({ submitted: true }); + } + + /** @override */ + _onClose(options={}) { + if ( !options.submitted ) this.config = false; + } + static async configure(config={}) { return new Promise(resolve => { const app = new this(config); diff --git a/templates/views/damageSelection.hbs b/templates/views/damageSelection.hbs index d6116c98..b7c61443 100644 --- a/templates/views/damageSelection.hbs +++ b/templates/views/damageSelection.hbs @@ -24,6 +24,6 @@ {{/each}} --}} \ No newline at end of file diff --git a/templates/views/rollSelection.hbs b/templates/views/rollSelection.hbs index da848ff8..679ef0a9 100644 --- a/templates/views/rollSelection.hbs +++ b/templates/views/rollSelection.hbs @@ -35,7 +35,7 @@ {{!-- {{/if}} --}} \ No newline at end of file