[Fix] 948 - Damage Reroll Parts (#965)

* Fixed so rerolling damage doesn't make damageParts an object

* Improved to properly handle theoretical additional damage parts
This commit is contained in:
WBHarry 2025-08-16 01:35:04 +02:00 committed by GitHub
parent 88be4c953d
commit 0e43bf197d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,7 +137,7 @@ export default class DamageRoll extends DHRoll {
} }
if (config.isCritical && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) { if (config.isCritical && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
const total = part.roll.dice.reduce((acc, term) => acc + term._faces*term._number, 0); const total = part.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0);
if (total > 0) { if (total > 0) {
part.roll.terms.push(...this.formatModifier(total)); part.roll.terms.push(...this.formatModifier(total));
} }
@ -161,11 +161,11 @@ export default class DamageRoll extends DHRoll {
if (config.data.parent.appliedEffects) { if (config.data.parent.appliedEffects) {
// Bardic Rally // Bardic Rally
const rallyChoices = config.data?.parent?.appliedEffects.reduce((a, c) => { const rallyChoices = config.data?.parent?.appliedEffects.reduce((a, c) => {
const change = c.changes.find(ch => ch.key === 'system.bonuses.rally'); const change = c.changes.find(ch => ch.key === 'system.bonuses.rally');
if (change) a.push({ value: c.id, label: change.value }); if (change) a.push({ value: c.id, label: change.value });
return a; return a;
}, []) }, []);
if(rallyChoices.length) { if (rallyChoices.length) {
mods.rally = { mods.rally = {
label: 'DAGGERHEART.CLASS.Feature.rallyDice', label: 'DAGGERHEART.CLASS.Feature.rallyDice',
values: rallyChoices, values: rallyChoices,
@ -318,15 +318,19 @@ export default class DamageRoll extends DHRoll {
}); });
const updateMessage = game.messages.get(message._id); const updateMessage = game.messages.get(message._id);
const damageParts = updateMessage.system.damage[damageType].parts.map((damagePart, index) => {
if (index !== Number(part)) return damagePart;
return {
...rollPart,
total: parsedRoll.total,
dice: rerolledDice
};
});
await updateMessage.update({ await updateMessage.update({
[`system.damage.${damageType}`]: { [`system.damage.${damageType}`]: {
...updateMessage, ...updateMessage,
total: parsedRoll.total, total: parsedRoll.total,
[`parts.${part}`]: { parts: damageParts
...rollPart,
total: parsedRoll.total,
dice: rerolledDice
}
} }
}); });
} }