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;
|
||||
getGameByUser(userId: string): Game | undefined;
|
||||
removeGameByPlayer(userId: string): void;
|
||||
|
||||
getSpeactatingGameIdsByUser(userId: string): string[]
|
||||
}
|
||||
@ -35,4 +35,14 @@ export class GameStoreImpl implements GameStore {
|
||||
removeGameByPlayer(userId: string): void {
|
||||
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;
|
||||
mancalaGame: MancalaGame;
|
||||
gameUsersConnectionInfo: GameUsersConnectionInfo;
|
||||
spectatorIds: string[];
|
||||
}
|
||||
|
||||
export interface GameUsersConnectionInfo {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user