Add method to see if the game can start
This commit is contained in:
parent
8dfea57a7c
commit
64b5c49187
1 changed files with 14 additions and 0 deletions
|
|
@ -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})`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue