Update removeTag to allow BOTH to be removed

Create handling for removal of either a specific side, or both sides.
This commit is contained in:
Stophles 2024-04-12 19:59:29 -05:00 committed by GitHub
parent 81f2d150a6
commit 87770dd439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -518,13 +518,22 @@ export class Arena {
} }
removeTag(tagType: ArenaTagType, side: ArenaTagSide = ArenaTagSide.BOTH): boolean { removeTag(tagType: ArenaTagType, side: ArenaTagSide = ArenaTagSide.BOTH): boolean {
const tags = this.tags; const tags = this.tags
const tag = tags.find(t => t.tagType === tagType && t.side === side); if(side == ArenaTagSide.BOTH){
if (tag) { tags.filter(t => (t.tagType == tagType)).forEach(t => {
tag.onRemove(this); t.onRemove(this);
tags.splice(tags.indexOf(tag), 1); tags.splice(tags.indexOf(t), 1);
} })
return !!tag; 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 { removeAllTags(): void {