[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

@ -164,7 +164,7 @@ export default class DamageRoll extends DHRoll {
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',
@ -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
}
} }
}); });
} }