From 187596ae3a0c13b3cf3c3936e45661c54b5dc620 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 15 Mar 2021 19:00:06 -0600 Subject: [PATCH] Add removePlayers method to cleanly remove all players from the team. --- server/src/objects/Team.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/server/src/objects/Team.ts b/server/src/objects/Team.ts index 530cc57..30882a8 100644 --- a/server/src/objects/Team.ts +++ b/server/src/objects/Team.ts @@ -37,6 +37,27 @@ export class Team { }; + /** + * Removes all players from the team. + */ + public removePlayers() { + + // Reset the writer + if (this.writer) { + this.writer.team = null; + this.writer.role = null; + this.writer = null; + }; + + // Reset all the guessers + for (var player of this.guessers) { + player.team = null; + player.role = null; + } + this.guessers = []; + }; + + /** * Resets all the per-game data related to this team */ @@ -44,7 +65,7 @@ export class Team { this._hand.guesser = []; this._questions = []; this._answers = new Array(8).fill(``); - } + }; /**