From fda3f02d73dba27034128c9be5e810a51e475e38 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 19 May 2022 01:34:36 -0400 Subject: [PATCH] Fix stanek leaking classes --- src/CotMG/ActiveFragment.ts | 8 +------- src/CotMG/Fragment.ts | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/CotMG/ActiveFragment.ts b/src/CotMG/ActiveFragment.ts index 0a7d7e44b..b09483c55 100644 --- a/src/CotMG/ActiveFragment.ts +++ b/src/CotMG/ActiveFragment.ts @@ -68,13 +68,7 @@ export class ActiveFragment { } copy(): ActiveFragment { - // We have to do a round trip because the constructor. - const fragment = FragmentById(this.id); - if (fragment === null) throw new Error("ActiveFragment id refers to unknown Fragment."); - const c = new ActiveFragment({ x: this.x, y: this.y, rotation: this.rotation, fragment: fragment }); - c.highestCharge = this.highestCharge; - c.numCharge = this.numCharge; - return c; + return Object.assign({}, this); } /** diff --git a/src/CotMG/Fragment.ts b/src/CotMG/Fragment.ts index a066b4dbb..9e6c54648 100644 --- a/src/CotMG/Fragment.ts +++ b/src/CotMG/Fragment.ts @@ -76,13 +76,7 @@ export class Fragment { } copy(): Fragment { - return new Fragment( - this.id, - this.shape.map((a) => a.slice()), - this.type, - this.power, - this.limit, - ); + return Object.assign({}, this); } }