From e52d9e4d8cac6ac2c6861985591a0e74bc0bdad1 Mon Sep 17 00:00:00 2001 From: Dapoolp Date: Sun, 22 Jun 2025 22:18:30 +0200 Subject: [PATCH] before main merge --- module/data/action/action.mjs | 100 +++------------------------- module/dialogs/d20RollDialog.mjs | 3 +- module/dialogs/damageDialog.mjs | 1 + templates/chat/duality-roll.hbs | 2 +- templates/views/damageSelection.hbs | 2 +- 5 files changed, 14 insertions(+), 94 deletions(-) diff --git a/module/data/action/action.mjs b/module/data/action/action.mjs index c05fcd30..27d3cab6 100644 --- a/module/data/action/action.mjs +++ b/module/data/action/action.mjs @@ -240,7 +240,6 @@ export class DHBaseAction extends foundry.abstract.DataModel { config = { ...config, roll: { - // modifier: modifierValue, modifiers: [], trait: this.roll?.trait, label: game.i18n.localize(abilities[this.roll.trait].label), @@ -290,6 +289,14 @@ export class DHBaseAction extends foundry.abstract.DataModel { } /* COST */ + /* USES */ + async spendUses(config) { + if(!this.uses.max) return; + + } + /* USES */ + + /* TARGET */ async getTarget(config) { if(this.target?.type === SYSTEM.ACTIONS.targetTypes.self.id) return this.formatTarget(this.actor.token ?? this.actor.prototypeToken); @@ -397,62 +404,6 @@ export class DHDamageAction extends DHBaseAction { } roll = CONFIG.Dice.daggerheart.DamageRoll.build(config) - - /* if (!event.shiftKey) { - const dialogClosed = new Promise((resolve, _) => { - new DamageSelectionDialog(formula, bonusDamage, resolve).render(true); - }); - const result = await dialogClosed; - bonusDamage = result.bonusDamage; - formula = result.rollString; - } - - if (isNaN(formula)) { - roll = await new Roll(formula, this.getRollData()).evaluate(); - } - if(!roll) return; - const dice = [], - modifiers = []; - for (var i = 0; i < roll.terms.length; i++) { - const term = roll.terms[i]; - if (term.faces) { - dice.push({ - type: `d${term.faces}`, - rolls: term.results.map(x => x.result), - total: term.results.reduce((acc, x) => acc + x.result, 0) - }); - } else if (term.operator) { - } else if (term.number) { - const operator = i === 0 ? '' : roll.terms[i - 1].operator; - modifiers.push({ value: term.number, operator: operator }); - } - } - - const cls = getDocumentClass('ChatMessage'), - systemData = { - title: game.i18n.format('DAGGERHEART.Chat.DamageRoll.Title', { damage: this.name }), - roll: formula, - damage: { - total: roll.total, - type: this.damage.parts[0].type // Handle multiple type damage - }, - dice: dice, - modifiers: modifiers, - targets: (data.system?.targets ?? data.targets).map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })) - }, - msg = new cls({ - type: 'damageRoll', - user: game.user.id, - sound: CONFIG.sounds.dice, - system: systemData, - content: await foundry.applications.handlebars.renderTemplate( - 'systems/daggerheart/templates/chat/damage-roll.hbs', - systemData - ), - rolls: [roll] - }); - - cls.create(msg.toObject()); */ } } @@ -502,25 +453,6 @@ export class DHHealingAction extends DHBaseAction { return await this.rollHealing(event, config); } - /* async use(event, ...args) { - const config = await super.use(event, args); - if(['error', 'warning'].includes(config.type)) return; - const roll = await this.rollHealing(), - cls = getDocumentClass('ChatMessage'), - msg = new cls({ - user: game.user.id, - content: await foundry.applications.handlebars.renderTemplate( - this.chatTemplate, - { - ...roll, - ...config - } - ) - }); - - cls.create(msg.toObject()); - } */ - async rollHealing(event, data) { console.log(event, data) let formula = this.healing.value.getFormula(this.actor); @@ -536,20 +468,7 @@ export class DHHealingAction extends DHBaseAction { messageTemplate: 'systems/daggerheart/templates/chat/healing-roll.hbs' } - roll = CONFIG.Dice.daggerheart.DamageRoll.build(config) - /* const formula = this.healing.value.getFormula(this.actor); - if (!formula || formula == '') return; - - let roll = { formula: formula, total: formula }; - if (isNaN(formula)) { - roll = await new Roll(formula, this.getRollData()).evaluate(); - } - return { - roll: roll.formula, - total: roll.total, - dice: roll.dice, - type: this.healing.type - } */ + roll = CONFIG.Dice.daggerheart.DamageRoll.build(config); } get chatTemplate() { @@ -586,7 +505,6 @@ export class DHEffectAction extends DHBaseAction { } async chatApplyEffects(event, data) { - // console.log(data, this.effects, this.effectsDetails) const cls = getDocumentClass('ChatMessage'), systemData = { title: game.i18n.format('DAGGERHEART.Chat.ApplyEffect.Title', { name: this.name }), diff --git a/module/dialogs/d20RollDialog.mjs b/module/dialogs/d20RollDialog.mjs index 42feab97..af7c215a 100644 --- a/module/dialogs/d20RollDialog.mjs +++ b/module/dialogs/d20RollDialog.mjs @@ -50,11 +50,12 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio context.selectedExperiences = this.config.experiences; context.advantage = this.config.advantage; /* context.diceOptions = this.diceOptions; */ + context.canRoll = true; if(this.config.costs?.length) { const updatedCosts = this.config.action.calcCosts(this.config.costs); context.costs = updatedCosts context.canRoll = this.config.action.getRealCosts(updatedCosts)?.hasCost; - } else context.canRoll = true; + } return context; } diff --git a/module/dialogs/damageDialog.mjs b/module/dialogs/damageDialog.mjs index f6f6f2f6..832375be 100644 --- a/module/dialogs/damageDialog.mjs +++ b/module/dialogs/damageDialog.mjs @@ -33,6 +33,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application async _prepareContext(_options) { const context = await super._prepareContext(_options); + context.title = this.config.title; context.formula = this.config.formula; return context; } diff --git a/templates/chat/duality-roll.hbs b/templates/chat/duality-roll.hbs index dbc1715f..f13a7a40 100644 --- a/templates/chat/duality-roll.hbs +++ b/templates/chat/duality-roll.hbs @@ -104,7 +104,7 @@ {{/each}} {{/if}} -
+
{{#if hasDamage}} {{else}} diff --git a/templates/views/damageSelection.hbs b/templates/views/damageSelection.hbs index 69aef025..d6116c98 100644 --- a/templates/views/damageSelection.hbs +++ b/templates/views/damageSelection.hbs @@ -1,6 +1,6 @@
- +