From 60333a4d57ef6bbc6ebf5373267fa9d908c5a241 Mon Sep 17 00:00:00 2001 From: Kim Mantas Date: Thu, 21 Mar 2024 20:48:32 +0000 Subject: [PATCH] Fix issue with aggregateDamageRolls mutating passed-in Roll. --- module/dice/aggregate-damage-rolls.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/dice/aggregate-damage-rolls.mjs b/module/dice/aggregate-damage-rolls.mjs index 8c739af8c0..8b97ca51d2 100644 --- a/module/dice/aggregate-damage-rolls.mjs +++ b/module/dice/aggregate-damage-rolls.mjs @@ -58,7 +58,7 @@ function chunkTerms(terms, type) { let currentChunk; let negative = false; - for ( const term of terms ) { + for ( let term of terms ) { // Plus or minus operators split chunks if ( (term instanceof OperatorTerm) && ["+", "-"].includes(term.operator) ) { if ( currentChunk ) pushChunk(); @@ -67,6 +67,7 @@ function chunkTerms(terms, type) { } // All other terms get added to the current chunk + term = RollTerm.fromData(foundry.utils.deepClone(term.toJSON())); currentChunk ??= { terms: [], negative, type: null }; currentChunk.terms.push(term); const flavor = term.flavor?.toLowerCase().trim();