From 64b5c49187e9ad5820bc83cbbc3d50cb07125245 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Fri, 9 Oct 2020 16:48:54 -0600 Subject: [PATCH] Add method to see if the game can start --- src/utils/Game.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/utils/Game.ts b/src/utils/Game.ts index 83e0f8d..6ca9fd8 100644 --- a/src/utils/Game.ts +++ b/src/utils/Game.ts @@ -47,6 +47,20 @@ export class Game { this.player_len--; }; + public start_error(): string { + /** + * This function gives the error as to why the game is not able to + * start to be able to send it to the client. If the return string is + * empty that means that the game is able to be started. + * + * @return The error that prevents the game from starting. + */ + if (this.player_len <= 4) { + return `Cannot start game with less than 4 players.`; + }; + return ``; + }; + public toString(): string { let player_count = Object.keys(this._players).length; return `Game(code=${this.code},players=${player_count})`;