mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-24 19:39:54 +02:00
Fixed so that formula construction specific to DAMAGE is now only applied to damage.main rather than by applyTo=hitPoints
This commit is contained in:
parent
88754c5a80
commit
3562ba649f
8 changed files with 56 additions and 62 deletions
|
|
@ -24,7 +24,7 @@ import TokenManager from './module/documents/tokenManager.mjs';
|
||||||
CONFIG.DH = SYSTEM;
|
CONFIG.DH = SYSTEM;
|
||||||
CONFIG.TextEditor.enrichers.push(...enricherConfig);
|
CONFIG.TextEditor.enrichers.push(...enricherConfig);
|
||||||
|
|
||||||
CONFIG.Dice.rolls = [BaseRoll, Roll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll];
|
CONFIG.Dice.rolls = [Roll = BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll];
|
||||||
CONFIG.Dice.daggerheart = {
|
CONFIG.Dice.daggerheart = {
|
||||||
DHRoll: DHRoll,
|
DHRoll: DHRoll,
|
||||||
DualityRoll: DualityRoll,
|
DualityRoll: DualityRoll,
|
||||||
|
|
|
||||||
|
|
@ -188,8 +188,8 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
static migrateData(source) {
|
static migrateData(source) {
|
||||||
const { main, resources, ...flatDamageKeys } = source.damage;
|
const { main, resources, ...flatDamageKeys } = source.damage ?? {};
|
||||||
if (!main && !resources) {
|
if (source.damage && !main && !resources) {
|
||||||
source.damage.main = null;
|
source.damage.main = null;
|
||||||
source.damage.resources = {};
|
source.damage.resources = {};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,27 +150,8 @@ export default class DamageRoll extends DHRoll {
|
||||||
if (!formulaData) return null;
|
if (!formulaData) return null;
|
||||||
this.options.isCritical = config.isCritical;
|
this.options.isCritical = config.isCritical;
|
||||||
|
|
||||||
const isHitpointPart = formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id;
|
|
||||||
formulaData.roll = new Roll(Roll.replaceFormulaData(formulaData.formula, config.data));
|
formulaData.roll = new Roll(Roll.replaceFormulaData(formulaData.formula, config.data));
|
||||||
formulaData.roll.terms = Roll.parse(formulaData.roll.formula, config.data);
|
formulaData.roll.terms = Roll.parse(formulaData.roll.formula, config.data);
|
||||||
if (formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
|
||||||
formulaData.modifiers = this.applyBaseBonus(formulaData);
|
|
||||||
this.addModifiers(formulaData);
|
|
||||||
formulaData.modifiers?.forEach(m => {
|
|
||||||
formulaData.roll.terms.push(...this.formatModifier(m.value));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* To Remove When Reaction System */
|
|
||||||
if (isDamage && formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
|
||||||
for (const mod in config.modifiers) {
|
|
||||||
const modifier = config.modifiers[mod];
|
|
||||||
if (
|
|
||||||
modifier.beforeCrit === true &&
|
|
||||||
(modifier.enabled || modifier.value)
|
|
||||||
) modifier.callback(formulaData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formulaData.extraFormula) {
|
if (formulaData.extraFormula) {
|
||||||
formulaData.roll.terms.push(
|
formulaData.roll.terms.push(
|
||||||
|
|
@ -179,28 +160,43 @@ export default class DamageRoll extends DHRoll {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.damageOptions.groupAttack?.numAttackers > 1 && isHitpointPart) {
|
|
||||||
const damageTypes = [foundry.dice.terms.Die, foundry.dice.terms.NumericTerm];
|
|
||||||
for (const term of formulaData.roll.terms) {
|
|
||||||
if (damageTypes.some(type => term instanceof type)) {
|
|
||||||
term.number *= config.damageOptions.groupAttack.numAttackers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.isCritical && isHitpointPart) {
|
|
||||||
const total = formulaData.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0);
|
|
||||||
if (total > 0) {
|
|
||||||
formulaData.roll.terms.push(...this.formatModifier(total));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* To Remove When Reaction System */
|
|
||||||
if (isDamage && formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
if (isDamage && formulaData.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||||
|
formulaData.modifiers = this.applyBaseBonus(formulaData);
|
||||||
|
this.addModifiers(formulaData);
|
||||||
|
formulaData.modifiers?.forEach(m => {
|
||||||
|
formulaData.roll.terms.push(...this.formatModifier(m.value));
|
||||||
|
});
|
||||||
|
|
||||||
|
/* To Remove When Reaction System */
|
||||||
|
for (const mod in config.modifiers) {
|
||||||
|
const modifier = config.modifiers[mod];
|
||||||
|
if (
|
||||||
|
modifier.beforeCrit === true &&
|
||||||
|
(modifier.enabled || modifier.value)
|
||||||
|
) modifier.callback(formulaData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* To Remove When Reaction System */
|
||||||
for (const mod in config.modifiers) {
|
for (const mod in config.modifiers) {
|
||||||
const modifier = config.modifiers[mod];
|
const modifier = config.modifiers[mod];
|
||||||
if (!modifier.beforeCrit && (modifier.enabled || modifier.value)) modifier.callback(formulaData);
|
if (!modifier.beforeCrit && (modifier.enabled || modifier.value)) modifier.callback(formulaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.damageOptions.groupAttack?.numAttackers > 1) {
|
||||||
|
const damageTypes = [foundry.dice.terms.Die, foundry.dice.terms.NumericTerm];
|
||||||
|
for (const term of formulaData.roll.terms) {
|
||||||
|
if (damageTypes.some(type => term instanceof type)) {
|
||||||
|
term.number *= config.damageOptions.groupAttack.numAttackers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.isCritical) {
|
||||||
|
const total = formulaData.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0);
|
||||||
|
if (total > 0) {
|
||||||
|
formulaData.roll.terms.push(...this.formatModifier(total));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formulaData.roll._formula = this.constructor.getFormula(formulaData.roll.terms);
|
formulaData.roll._formula = this.constructor.getFormula(formulaData.roll.terms);
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,8 @@ export default class RegisterHandlebarsHelpers {
|
||||||
return formula;
|
return formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
static damageSymbols(damageParts) {
|
static damageSymbols(damageData) {
|
||||||
const allTypes = [...new Set([...damageParts].flatMap(x => Array.from(x.type)))];
|
const symbols = damageData.type.map(p => CONFIG.DH.GENERAL.damageTypes[p].icon);
|
||||||
const symbols = allTypes.map(p => CONFIG.DH.GENERAL.damageTypes[p].icon);
|
|
||||||
return new Handlebars.SafeString(Array.from(symbols).map(symbol => `<i class="fa-solid ${symbol}"></i>`));
|
return new Handlebars.SafeString(Array.from(symbols).map(symbol => `<i class="fa-solid ${symbol}"></i>`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
font-size: var(--font-size-20);
|
font-size: var(--font-size-20);
|
||||||
color: light-dark(@dark, @beige);
|
color: light-dark(@dark, @beige);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: -12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bonuses {
|
.bonuses {
|
||||||
|
|
|
||||||
|
|
@ -43,25 +43,23 @@
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class="flexcol">
|
{{#unless (empty @root.resourceFormulas)}}
|
||||||
{{#unless (empty @root.resourceFormulas)}}
|
<div class="section-header">{{localize "Resource Drain"}}</div>
|
||||||
<div class="section-header">{{localize "Resource Drain"}}</div>
|
{{/unless}}
|
||||||
{{/unless}}
|
|
||||||
|
|
||||||
{{#each @root.resourceFormulas}}
|
{{#each @root.resourceFormulas}}
|
||||||
<div class="damage-formula">
|
<div class="damage-formula">
|
||||||
<span class="damage-resource"><b>{{localize "DAGGERHEART.GENERAL.formula"}}:</b> {{roll.formula}}</span>
|
<span class="damage-resource"><b>{{localize "DAGGERHEART.GENERAL.formula"}}:</b> {{roll.formula}}</span>
|
||||||
<span class="damage-details">
|
<span class="damage-details">
|
||||||
{{#with (lookup @root.config.GENERAL.healingTypes applyTo)}}
|
{{#with (lookup @root.config.GENERAL.healingTypes applyTo)}}
|
||||||
{{localize label}}
|
{{localize label}}
|
||||||
{{/with}}
|
{{/with}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="bonuses form-group flexrow">
|
<div class="bonuses form-group flexrow">
|
||||||
<input type="text" value="{{extraFormula}}" name={{concat "resourceFormulas." @key ".extraFormula"}} placeholder="{{localize "DAGGERHEART.GENERAL.situationalBonus"}}">
|
<input type="text" value="{{extraFormula}}" name={{concat "resourceFormulas." @key ".extraFormula"}} placeholder="{{localize "DAGGERHEART.GENERAL.situationalBonus"}}">
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#if damageOptions.groupAttack}}
|
{{#if damageOptions.groupAttack}}
|
||||||
<fieldset class="group-attack-container">
|
<fieldset class="group-attack-container">
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="tag">
|
<div class="tag">
|
||||||
<span>{{{damageFormula attack}}} {{{damageSymbols attack.damage.parts}}}</span>
|
<span>{{{damageFormula attack}}} {{{damageSymbols attack.damage.main}}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{#if description}}
|
{{#if description}}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
{{/with}}
|
{{/with}}
|
||||||
</div>
|
</div>
|
||||||
<div class="tag">
|
<div class="tag">
|
||||||
<span>{{{damageFormula item.system.attack}}} {{{damageSymbols item.system.attack.damage.parts}}}</span>
|
<span>{{{damageFormula item.system.attack}}} {{{damageSymbols item.system.attack.damage.main}}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{#if description}}
|
{{#if description}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue