Add player count attribute
This commit is contained in:
parent
7b8ade6f4c
commit
8dfea57a7c
1 changed files with 8 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue