add spectatorIds to game
This commit is contained in:
parent
9f9160eaf6
commit
7a88eb4f54
@ -12,4 +12,6 @@ export interface GameStore {
|
|||||||
setGameByUser(userId: string, game: Game): void;
|
setGameByUser(userId: string, game: Game): void;
|
||||||
getGameByUser(userId: string): Game | undefined;
|
getGameByUser(userId: string): Game | undefined;
|
||||||
removeGameByPlayer(userId: string): void;
|
removeGameByPlayer(userId: string): void;
|
||||||
|
|
||||||
|
getSpeactatingGameIdsByUser(userId: string): string[]
|
||||||
}
|
}
|
||||||
@ -35,4 +35,14 @@ export class GameStoreImpl implements GameStore {
|
|||||||
removeGameByPlayer(userId: string): void {
|
removeGameByPlayer(userId: string): void {
|
||||||
this.removeGameIdByPlayer(userId);
|
this.removeGameIdByPlayer(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSpeactatingGameIdsByUser(userId: string): string[] {
|
||||||
|
const speactatingGameIds = [];
|
||||||
|
for (const gameId in this.gameStore.keys()) {
|
||||||
|
const game = this.gameStore.get(gameId) as Game;
|
||||||
|
const isSpectator = game.spectatorIds.find((value) => value === userId);
|
||||||
|
isSpectator && speactatingGameIds.push(game.id);
|
||||||
|
}
|
||||||
|
return speactatingGameIds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -5,6 +5,7 @@ export interface Game {
|
|||||||
id: string;
|
id: string;
|
||||||
mancalaGame: MancalaGame;
|
mancalaGame: MancalaGame;
|
||||||
gameUsersConnectionInfo: GameUsersConnectionInfo;
|
gameUsersConnectionInfo: GameUsersConnectionInfo;
|
||||||
|
spectatorIds: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GameUsersConnectionInfo {
|
export interface GameUsersConnectionInfo {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user