From 87770dd4390ffdeaee629f99f840745390d40008 Mon Sep 17 00:00:00 2001 From: Stophles <71789013+Stophles@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:59:29 -0500 Subject: [PATCH] Update removeTag to allow BOTH to be removed Create handling for removal of either a specific side, or both sides. --- src/field/arena.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/field/arena.ts b/src/field/arena.ts index 329c81861c4..550509a9771 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -518,13 +518,22 @@ export class Arena { } removeTag(tagType: ArenaTagType, side: ArenaTagSide = ArenaTagSide.BOTH): boolean { - const tags = this.tags; - const tag = tags.find(t => t.tagType === tagType && t.side === side); - if (tag) { - tag.onRemove(this); - tags.splice(tags.indexOf(tag), 1); - } - return !!tag; + const tags = this.tags + if(side == ArenaTagSide.BOTH){ + tags.filter(t => (t.tagType == tagType)).forEach(t => { + t.onRemove(this); + tags.splice(tags.indexOf(t), 1); + }) + return true; + } + else { + const tag = tags.find(t => t.tagType === tagType && t.side === side); + if (tag) { + tag.onRemove(this); + tags.splice(tags.indexOf(tag), 1); + } + return !!tag; + } } removeAllTags(): void {