Add method to see if the game can start

This commit is contained in:
Oliver-Akins 2020-10-09 16:48:54 -06:00
parent 8dfea57a7c
commit 64b5c49187

View file

@ -47,6 +47,20 @@ export class Game {
this.player_len--; 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 { public toString(): string {
let player_count = Object.keys(this._players).length; let player_count = Object.keys(this._players).length;
return `Game(code=${this.code},players=${player_count})`; return `Game(code=${this.code},players=${player_count})`;