diff --git a/lang/en.json b/lang/en.json index 41c31dcc..9f929c77 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1259,6 +1259,7 @@ }, "fear": "Fear", "features": "Features", + "healing": "Healing", "hitPoints": { "single": "Hit Point", "plural": "Hit Points", diff --git a/module/applications/dialogs/damageReductionDialog.mjs b/module/applications/dialogs/damageReductionDialog.mjs index d5d73e28..658cef96 100644 --- a/module/applications/dialogs/damageReductionDialog.mjs +++ b/module/applications/dialogs/damageReductionDialog.mjs @@ -10,7 +10,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap this.reject = reject; this.actor = actor; this.damage = damage; -console.log(damageType) + const canApplyArmor = damageType.every(t => actor.system.armorApplicableDamageTypes[t] === true); const maxArmorMarks = canApplyArmor ? Math.min( diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 74e62b59..29a0f46e 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -208,7 +208,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo } if (targets.length === 0) - ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); + return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); for (let target of targets) { let damages = message.system.damage; @@ -222,7 +222,6 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo }) }) } - // damage = Math.ceil(damage * (CONFIG.DH.ACTIONS.damageOnSave[message.system.onSave]?.mod ?? 1)); target.actor.takeDamage(damages.roll); } @@ -233,10 +232,10 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo const targets = Array.from(game.user.targets); if (targets.length === 0) - ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); - + return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); + for (var target of targets) { - target.actor.takeHealing([{ value: message.system.roll.total, type: message.system.roll.type }]); + target.actor.takeHealing(message.system.roll); } }; diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index a1acd3f6..f0176d78 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -142,7 +142,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel { static getSourceConfig(parent) { const updateSource = {}; updateSource.img ??= parent?.img ?? parent?.system?.img; - if (parent?.type === 'weapon') { + if (parent?.type === 'weapon' && this === game.system.api.models.actions.actionsTypes.attack) { updateSource['damage'] = { includeBase: true }; updateSource['range'] = parent?.system?.attack?.range; updateSource['roll'] = { @@ -216,7 +216,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel { if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return; // Display configuration window if necessary - // if (config.dialog?.configure && this.requireConfigurationDialog(config)) { if (this.requireConfigurationDialog(config)) { config = await D20RollDialog.configure(null, config); if (!config) return; diff --git a/module/data/action/healingAction.mjs b/module/data/action/healingAction.mjs index ddae314a..e0a74f27 100644 --- a/module/data/action/healingAction.mjs +++ b/module/data/action/healingAction.mjs @@ -15,25 +15,25 @@ export default class DHHealingAction extends DHBaseAction { } async rollHealing(event, data) { - let formulaValue = this.getFormulaValue(data), - formula = formulaValue.getFormula(this.actor); - - if (!formula || formula == '') return; - let roll = { formula: formula, total: formula }; - + const systemData = data.system ?? data; + let formulas = [{ + formula: this.getFormulaValue(data).getFormula(this.actor), + applyTo: this.healing.applyTo + }]; + const config = { title: game.i18n.format('DAGGERHEART.UI.Chat.healingRoll.title', { - healing: game.i18n.localize(CONFIG.DH.GENERAL.healingTypes[this.healing.type].label) + healing: game.i18n.localize(CONFIG.DH.GENERAL.healingTypes[this.healing.applyTo].label) }), - // roll: { formula }, - roll: [ formula ], + roll: formulas, targets: (data.system?.targets ?? data.targets).filter(t => t.hit), messageType: 'healing', - type: this.healing.type, + source: systemData.source, + data: this.getRollData(), event }; - roll = CONFIG.Dice.daggerheart.DamageRoll.build(config); + return CONFIG.Dice.daggerheart.DamageRoll.build(config); } get chatTemplate() { diff --git a/module/dice/damageRoll.mjs b/module/dice/damageRoll.mjs index 9a3abc3d..aa1c4c86 100644 --- a/module/dice/damageRoll.mjs +++ b/module/dice/damageRoll.mjs @@ -10,10 +10,11 @@ export default class DamageRoll extends DHRoll { static DefaultDialog = DamageDialog; - static async buildEvaluate(rolls, config = {}, message = {}) { + static async buildEvaluate(roll, config = {}, message = {}) { if ( config.evaluate !== false ) { for ( const roll of config.roll ) await roll.roll.evaluate(); } + roll._evaluated = true; const parts = config.roll.map(r => this.postEvaluate(r)); config.roll = this.unifyDamageRoll(parts); } @@ -22,7 +23,7 @@ export default class DamageRoll extends DHRoll { return { ...roll, ...super.postEvaluate(roll.roll, config), - damageTypes: [...roll.damageTypes], + damageTypes: [...(roll.damageTypes ?? [])], roll: roll.roll, type: config.type, modifierTotal: this.calculateTotalModifiers(roll.roll) diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index 60b7244d..57161b84 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -57,13 +57,13 @@ export default class DHRoll extends Roll { // Create Chat Message if (config.source?.message) { - console.log(config) - if(Array.isArray(config.roll?.parts)) { - const pool = foundry.dice.terms.PoolTerm.fromRolls(config.roll.parts.map(r => r.roll)); + if(Object.values(config.roll)?.length) { + const pool = foundry.dice.terms.PoolTerm.fromRolls(Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll))); roll = Roll.fromTerms([pool]); } if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true); } else { + console.log(roll, config) config.message = await this.toMessage(roll, config); } } diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 458b68d7..e6ae781a 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -401,15 +401,15 @@ export default class DhpActor extends Actor { const updates = []; - Object.entries(damages).forEach(([type, damage]) => { + Object.entries(damages).forEach(([key, damage]) => { damage.parts.forEach(part => { if(part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) part.total = this.calculateDamage(part.total, part.damageTypes); - const update = updates.find(u => u.type === type); + const update = updates.find(u => u.key === key); if(update) { update.value += part.total; update.damageTypes.add(...new Set(part.damageTypes)); - } else updates.push({ value: part.total, type, damageTypes: new Set(part.damageTypes) }) + } else updates.push({ value: part.total, key, damageTypes: new Set(part.damageTypes) }) }) }); @@ -417,7 +417,7 @@ export default class DhpActor extends Actor { if(!updates.length) return; - const hpDamage = updates.find(u => u.type === CONFIG.DH.GENERAL.healingTypes.hitPoints.id); + const hpDamage = updates.find(u => u.key === CONFIG.DH.GENERAL.healingTypes.hitPoints.id); if(hpDamage) { hpDamage.value = this.convertDamageToThreshold(hpDamage.value); if (this.type === 'character' && this.system.armor && this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes)) { @@ -428,7 +428,7 @@ export default class DhpActor extends Actor { }); if (armorStackResult) { const { modifiedDamage, armorSpent, stressSpent } = armorStackResult; - updates.find(u => u.type === 'hitPoints').value = modifiedDamage; + updates.find(u => u.key === 'hitPoints').value = modifiedDamage; updates.push( ...(armorSpent ? [{ value: armorSpent, key: 'armorStack' }] : []), ...(stressSpent ? [{ value: stressSpent, key: 'stress' }] : []) @@ -436,7 +436,11 @@ export default class DhpActor extends Actor { } } } - + + updates.forEach( u => + u.value = u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false ? u.value * -1 : u.value + ); + await this.modifyResource(updates); if (Hooks.call(`${CONFIG.DH.id}.postTakeDamage`, this, damages) === false) return null; @@ -449,7 +453,6 @@ export default class DhpActor extends Actor { const flatReduction = this.getDamageTypeReduction(type); const damage = Math.max(baseDamage - (flatReduction ?? 0), 0); - // const hpDamage = this.convertDamageToThreshold(damage); return damage; } @@ -469,8 +472,13 @@ export default class DhpActor extends Actor { } async takeHealing(resources) { - resources.forEach(r => (r.value *= -1)); - await this.modifyResource(resources); + const updates = Object.entries(resources).map(([key, value]) => ( + { + key: key, + value: !(key === 'fear' || this.system?.resources?.[key]?.isReversed === false) ? value.total * -1 : value.total + } + )) + await this.modifyResource(updates); } async modifyResource(resources) { diff --git a/templates/actionTypes/healing.hbs b/templates/actionTypes/healing.hbs index 5bf46f7a..4b095174 100644 --- a/templates/actionTypes/healing.hbs +++ b/templates/actionTypes/healing.hbs @@ -1,43 +1,41 @@ -