Fix costs object being updated during getRealCosts

This commit is contained in:
Dapoolp 2025-09-04 15:57:34 +02:00
parent e3859c5fea
commit fa7196d5d2

View file

@ -94,7 +94,8 @@ export default class CostField extends fields.ArrayField {
} }
static getRealCosts(costs) { static getRealCosts(costs) {
const realCosts = costs?.length ? costs.filter(c => c.enabled) : []; const cloneCosts = foundry.utils.deepClone(costs),
realCosts = cloneCosts?.length ? cloneCosts.filter(c => c.enabled) : [];
let mergedCosts = []; let mergedCosts = [];
realCosts.forEach(c => { realCosts.forEach(c => {
const getCost = Object.values(mergedCosts).find(gc => gc.key === c.key); const getCost = Object.values(mergedCosts).find(gc => gc.key === c.key);