Add player count attribute

This commit is contained in:
Oliver-Akins 2020-10-09 16:34:24 -06:00
parent 7b8ade6f4c
commit 8dfea57a7c

View file

@ -1,6 +1,7 @@
export class Game {
readonly code: string;
public status: game_states;
private player_len: number = 0;
private banned_players: string[];
private _players: players;
@ -22,7 +23,11 @@ export class Game {
};
};
return null;
}
};
get player_count(): number {
return this.player_len;
};
public add_player(player: string, id: string, is_host:boolean=false): void {
this._players[player] = {
@ -31,6 +36,7 @@ export class Game {
host: is_host,
socket: id,
};
this.player_len++;
};
public remove_player(player: string, ban: boolean): void {
@ -38,6 +44,7 @@ export class Game {
if (ban) {
this.banned_players.push(player);
};
this.player_len--;
};
public toString(): string {