fix(07-15): restore modifier bookkeeping when cloning an attribute

- clone() now binds each cloned modifier to the clone, records its modifierName, mirrors the source save flag and recomputes the attribute, matching addModifier's bookkeeping
- a cloned attribute can enumerate, index and persist its modifiers, and a cloned modifier's setValue notifies the clone
- add the bookkeeping and save-ability regression cases
This commit is contained in:
AncTe committed 2026-09-17 20:55:58 +08:00
1 parent 49116c0784
commit bb1986508a
2 files changed
+49 -2

No files matched your search

@@ -306,7 +306,15 @@ export class HeroAttribute<THero> implements IHeroAttribute<THero> {
}
if (!cloneModifier) return cloned;
for (const [name, modifiers] of this.modifier) {
const arr: IHeroModifier[] = modifiers.map(v => v.clone());
const arr: IHeroModifier[] = modifiers.map(v => {
const copy = v.clone();
copy.bindAttribute(cloned);
cloned.modifierName.set(copy, name);
if (!this.getModifierSaveEnabled(v)) {
cloned.modifierNosave.add(copy);
}
return copy;
});
cloned.modifier.set(name, arr);
cloned.recalculateAttribute(name);
}