Skip to content

Commit

Permalink
Fix issue with aggregateDamageRolls mutating passed-in Roll.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyorl committed Mar 21, 2024
1 parent 4fdc6b9 commit 60333a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/dice/aggregate-damage-rolls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 60333a4

Please sign in to comment.