mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
[Fix] 1325 - Weapon Tooltip Damage Formula (#1355)
* Fixed so the damage calculation is correct. Fixed so the right tooltip is shown for attacks * Moved the damageFormula function to damageAction
This commit is contained in:
parent
b57e98071f
commit
6d8d773a26
8 changed files with 45 additions and 32 deletions
|
|
@ -2,4 +2,17 @@ import DHBaseAction from './baseAction.mjs';
|
||||||
|
|
||||||
export default class DHDamageAction extends DHBaseAction {
|
export default class DHDamageAction extends DHBaseAction {
|
||||||
static extraSchemas = [...super.extraSchemas, 'damage', 'target', 'effects'];
|
static extraSchemas = [...super.extraSchemas, 'damage', 'target', 'effects'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a display ready damage formula string
|
||||||
|
* @returns Formula string
|
||||||
|
*/
|
||||||
|
getDamageFormula() {
|
||||||
|
const strings = [];
|
||||||
|
for (const { value } of this.damage.parts) {
|
||||||
|
strings.push(Roll.replaceFormulaData(value.getFormula(), this.actor?.getRollData() ?? {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.join(' + ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,8 @@ export default class RegisterHandlebarsHelpers {
|
||||||
return accum;
|
return accum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static damageFormula(attack, actor) {
|
static damageFormula(attack) {
|
||||||
const traitTotal = actor.system.traits?.[attack.roll.trait]?.value;
|
return attack.getDamageFormula();
|
||||||
const instances = [
|
|
||||||
attack.damage.parts.map(x => Roll.replaceFormulaData(x.value.getFormula(), actor)).join(' + '),
|
|
||||||
traitTotal
|
|
||||||
].filter(x => x);
|
|
||||||
|
|
||||||
return instances.join(traitTotal > 0 ? ' + ' : ' - ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static formulaValue(formula, item) {
|
static formulaValue(formula, item) {
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@
|
||||||
</div>
|
</div>
|
||||||
<ul class="items-sidebar-list">
|
<ul class="items-sidebar-list">
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
item=document.system.attack
|
item=document.system.attack
|
||||||
type='action'
|
type='attack'
|
||||||
noCompendiumEdit=true
|
noCompendiumEdit=true
|
||||||
}}
|
}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -104,16 +104,16 @@
|
||||||
</div>
|
</div>
|
||||||
<ul class="items-sidebar-list">
|
<ul class="items-sidebar-list">
|
||||||
{{#if document.system.usedUnarmed}}
|
{{#if document.system.usedUnarmed}}
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
item=document.system.usedUnarmed
|
item=document.system.usedUnarmed
|
||||||
type='action'
|
type='attack'
|
||||||
}}
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#each document.items as |item|}}
|
{{#each document.items as |item|}}
|
||||||
{{#if item.system.equipped}}
|
{{#if item.system.equipped}}
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
item=item
|
item=item
|
||||||
type=item.type
|
type=item.type
|
||||||
}}
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
<ul class="items-list">
|
<ul class="items-list">
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
item=document.system.attack
|
item=document.system.attack
|
||||||
type='action'
|
type='attack'
|
||||||
hideTooltip=true
|
hideTooltip=true
|
||||||
}}
|
}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tooltip-information">
|
<div class="tooltip-information">
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
|
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
|
||||||
<div>{{damageFormula item.system.attack item}}</div>
|
<div>{{damageFormula item.system.attack}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,22 +4,28 @@
|
||||||
<div class="tooltip-description">{{{description}}}</div>
|
<div class="tooltip-description">{{{description}}}</div>
|
||||||
|
|
||||||
<div class="tooltip-information-section spaced">
|
<div class="tooltip-information-section spaced">
|
||||||
<div class="tooltip-information">
|
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.Trait.single"}}</label>
|
{{#if (lookup config.ACTOR.abilities attack.roll.trait)}}
|
||||||
{{#with (lookup config.ACTOR.abilities attack.roll.trait) as | trait |}}
|
<div class="tooltip-information">
|
||||||
<div>{{localize trait.label}}</div>
|
<label>{{localize "DAGGERHEART.GENERAL.Trait.single"}}</label>
|
||||||
{{/with}}
|
{{#with (lookup config.ACTOR.abilities attack.roll.trait) as | trait |}}
|
||||||
</div>
|
<div>{{localize trait.label}}</div>
|
||||||
<div class="tooltip-information">
|
{{/with}}
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.range"}}</label>
|
</div>
|
||||||
{{#with (lookup config.GENERAL.range attack.range) as | range |}}
|
{{/if}}
|
||||||
<div>{{localize range.label}}</div>
|
|
||||||
{{/with}}
|
{{#if (lookup config.GENERAL.range attack.range)}}
|
||||||
</div>
|
<div class="tooltip-information">
|
||||||
|
<label>{{localize "DAGGERHEART.GENERAL.range"}}</label>
|
||||||
|
{{#with (lookup config.GENERAL.range attack.range) as | range |}}
|
||||||
|
<div>{{localize range.label}}</div>
|
||||||
|
{{/with}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<div class="tooltip-information">
|
<div class="tooltip-information">
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
|
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
|
||||||
<div>{{{damageFormula attack parent}}}</div>
|
<div>{{{damageFormula attack}}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tooltip-information">
|
<div class="tooltip-information">
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.damageType"}}</label>
|
<label>{{localize "DAGGERHEART.GENERAL.damageType"}}</label>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tooltip-information">
|
<div class="tooltip-information">
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
|
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
|
||||||
<div>{{{damageFormula item.system.attack item.parent}}}</div>
|
<div>{{{damageFormula item.system.attack}}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tooltip-information">
|
<div class="tooltip-information">
|
||||||
<label>{{localize "DAGGERHEART.GENERAL.damageType"}}</label>
|
<label>{{localize "DAGGERHEART.GENERAL.damageType"}}</label>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue