mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/683 damage dialog options (#735)
* Temp solution for specific weapon feature * Add Serrated & Self-Correcting * Remove comments
This commit is contained in:
parent
1c000c7cfe
commit
585601c134
18 changed files with 177 additions and 118 deletions
|
|
@ -102,14 +102,14 @@ export default class DamageRoll extends DHRoll {
|
|||
}
|
||||
|
||||
constructFormula(config) {
|
||||
this.options.roll.forEach(part => {
|
||||
this.options.roll.forEach((part, index) => {
|
||||
part.roll = new Roll(Roll.replaceFormulaData(part.formula, config.data));
|
||||
this.constructFormulaPart(config, part);
|
||||
this.constructFormulaPart(config, part, index);
|
||||
});
|
||||
return this.options.roll;
|
||||
}
|
||||
|
||||
constructFormulaPart(config, part) {
|
||||
constructFormulaPart(config, part, index) {
|
||||
part.roll.terms = Roll.parse(part.roll.formula, config.data);
|
||||
|
||||
if (part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||
|
|
@ -120,6 +120,15 @@ export default class DamageRoll extends DHRoll {
|
|||
});
|
||||
}
|
||||
|
||||
/* To Remove When Reaction System */
|
||||
if(index === 0 && part.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(part);
|
||||
}
|
||||
}
|
||||
|
||||
if (part.extraFormula) {
|
||||
part.roll.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
|
|
@ -132,6 +141,102 @@ export default class DamageRoll extends DHRoll {
|
|||
criticalBonus = tmpRoll.total - this.constructor.calculateTotalModifiers(tmpRoll);
|
||||
part.roll.terms.push(...this.formatModifier(criticalBonus));
|
||||
}
|
||||
|
||||
/* To Remove When Reaction System */
|
||||
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||
for(const mod in config.modifiers) {
|
||||
const modifier = config.modifiers[mod];
|
||||
if(!modifier.beforeCrit && (modifier.enabled || modifier.value))
|
||||
modifier.callback(part);
|
||||
}
|
||||
}
|
||||
|
||||
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
||||
}
|
||||
|
||||
/* To Remove When Reaction System */
|
||||
static temporaryModifierBuilder(config) {
|
||||
const mods = {};
|
||||
if(config.data?.parent) {
|
||||
if(config.data.parent.appliedEffects) {
|
||||
// Bardic Rally
|
||||
mods.rally = {
|
||||
label: "DAGGERHEART.CLASS.Feature.rallyDice",
|
||||
values: config.data?.parent?.appliedEffects.reduce((a, c) => {
|
||||
const change = c.changes.find(ch => ch.key === 'system.bonuses.rally');
|
||||
if (change) a.push({ value: c.id, label: change.value });
|
||||
return a;
|
||||
}, []),
|
||||
value: null,
|
||||
beforeCrit: true,
|
||||
callback: (part) => {
|
||||
const rallyFaces = config.modifiers.rally.values.find(r => r.value === config.modifiers.rally.value)?.label;
|
||||
part.roll.terms.push(
|
||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...this.parse(`1${rallyFaces}`)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const item = config.data.parent.items?.get(config.source.item);
|
||||
if(item) {
|
||||
// Massive (Weapon Feature)
|
||||
if(item.system.itemFeatures.find(f => f.value === "massive"))
|
||||
mods.massive = {
|
||||
label: CONFIG.DH.ITEM.weaponFeatures.massive.label,
|
||||
enabled: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
||||
part.roll.terms[0].number += 1;
|
||||
}
|
||||
};
|
||||
|
||||
// Powerful (Weapon Feature)
|
||||
if(item.system.itemFeatures.find(f => f.value === "powerful"))
|
||||
mods.powerful = {
|
||||
label: CONFIG.DH.ITEM.weaponFeatures.powerful.label,
|
||||
enabled: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
||||
part.roll.terms[0].number += 1;
|
||||
}
|
||||
};
|
||||
|
||||
// Brutal (Weapon Feature)
|
||||
if(item.system.itemFeatures.find(f => f.value === "brutal"))
|
||||
mods.brutal = {
|
||||
label: CONFIG.DH.ITEM.weaponFeatures.brutal.label,
|
||||
enabled: true,
|
||||
beforeCrit: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`x${part.roll.terms[0].faces}`);
|
||||
}
|
||||
};
|
||||
|
||||
// Serrated (Weapon Feature)
|
||||
if(item.system.itemFeatures.find(f => f.value === "serrated"))
|
||||
mods.serrated = {
|
||||
label: CONFIG.DH.ITEM.weaponFeatures.serrated.label,
|
||||
enabled: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`sc8`);
|
||||
}
|
||||
};
|
||||
|
||||
// Self-Correcting (Weapon Feature)
|
||||
if(item.system.itemFeatures.find(f => f.value === "selfCorrecting"))
|
||||
mods.selfCorrecting = {
|
||||
label: CONFIG.DH.ITEM.weaponFeatures.selfCorrecting.label,
|
||||
enabled: true,
|
||||
callback: (part) => {
|
||||
part.roll.terms[0].modifiers.push(`sc6`);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
config.modifiers = mods;
|
||||
return mods;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue