diff --git a/module/applications/roll.mjs b/module/applications/roll.mjs index 9940ca90..a78c6e04 100644 --- a/module/applications/roll.mjs +++ b/module/applications/roll.mjs @@ -1,4 +1,10 @@ import D20RollDialog from '../dialogs/d20RollDialog.mjs'; +import DamageDialog from '../dialogs/damageDialog.mjs'; + +/* + - Damage & other resources roll + - Close dialog => don't roll +*/ export class DHRoll extends Roll { constructor(formula, data, options) { @@ -31,7 +37,7 @@ export class DHRoll extends Roll { config = await DialogClass.configure(config, message); } console.log(config) - let roll = new this('', config.actor, 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 []; @@ -381,13 +387,9 @@ export class DamageRoll extends DHRoll { static messageType = 'damageRoll'; - static DefaultDialog = D20RollDialog; - - get messageType() { - return 'damageRoll'; - } + static DefaultDialog = DamageDialog; get messageTemplate() { - return ''; + return 'systems/daggerheart/templates/chat/damage-roll.hbs'; } } \ No newline at end of file diff --git a/module/data/action/action.mjs b/module/data/action/action.mjs index a8ea72ca..e6dd3f01 100644 --- a/module/data/action/action.mjs +++ b/module/data/action/action.mjs @@ -7,10 +7,11 @@ const fields = foundry.data.fields; /* ToDo + - Add setting for Hope/Fear result on Damage, Heal, Resource (Handle Roll result as part of formula if needed) + - Add setting and/or checkbox for cost and damage like - Target Check / Target Picker - Range Check - Area of effect and measurement placement - - Handle Roll result as part of formula if needed - Summon Action create method - Create classes form Target, Cost, etc ? @@ -390,7 +391,18 @@ export class DHDamageAction extends DHBaseAction { let roll = { formula: formula, total: formula }, bonusDamage = []; - if (!event.shiftKey) { + const config = { + title: game.i18n.format('DAGGERHEART.Chat.DamageRoll.Title', { damage: this.name }), + formula, + chatMessage: { + template: 'systems/daggerheart/templates/chat/damage-roll.hbs' + }, + targets: (data.system?.targets ?? data.targets).map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })) + } + + roll = CONFIG.Dice.daggerheart.DamageRoll.build(config) + + /* if (!event.shiftKey) { const dialogClosed = new Promise((resolve, _) => { new DamageSelectionDialog(formula, bonusDamage, resolve).render(true); }); @@ -444,7 +456,7 @@ export class DHDamageAction extends DHBaseAction { rolls: [roll] }); - cls.create(msg.toObject()); + cls.create(msg.toObject()); */ } get chatTemplate() { diff --git a/module/dialogs/damageDialog.mjs b/module/dialogs/damageDialog.mjs new file mode 100644 index 00000000..f6f6f2f6 --- /dev/null +++ b/module/dialogs/damageDialog.mjs @@ -0,0 +1,47 @@ +const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api; + +export default class DamageDialog extends HandlebarsApplicationMixin(ApplicationV2) { + constructor(config={}, options={}) { + super(options); + + this.config = config; + } + + static DEFAULT_OPTIONS = { + tag: 'form', + id: 'roll-selection', + classes: ['daggerheart', 'views', 'damage-selection'], + position: { + width: 400, + height: 'auto' + }, + actions: {}, + form: { + handler: this.updateRollConfiguration, + submitOnChange: true, + submitOnClose: false + } + }; + + /** @override */ + static PARTS = { + damageSelection: { + id: 'damageSelection', + template: 'systems/daggerheart/templates/views/damageSelection.hbs' + } + }; + + async _prepareContext(_options) { + const context = await super._prepareContext(_options); + context.formula = this.config.formula; + return context; + } + + static async configure(config={}) { + return new Promise(resolve => { + const app = new this(config); + app.addEventListener("close", () => resolve(app.config), { once: true }); + app.render({ force: true }); + }); + } +} \ No newline at end of file diff --git a/templates/views/damageSelection.hbs b/templates/views/damageSelection.hbs index a86f42d5..69aef025 100644 --- a/templates/views/damageSelection.hbs +++ b/templates/views/damageSelection.hbs @@ -2,10 +2,10 @@
- +
- {{#each bonusDamage as |damage index|}} + {{!-- {{#each bonusDamage as |damage index|}}
@@ -22,8 +22,8 @@ {{/if}}
- {{/each}} + {{/each}} --}} \ No newline at end of file