From 494a001afd1c49916fffd413c39afb1f894ede9a Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Fri, 2 Oct 2020 16:50:09 -0600 Subject: [PATCH] Update GetPlayerList to use the game objects. --- src/events/GetPlayerList.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/events/GetPlayerList.ts b/src/events/GetPlayerList.ts index 2ee3ea4..6394d25 100644 --- a/src/events/GetPlayerList.ts +++ b/src/events/GetPlayerList.ts @@ -1,27 +1,27 @@ /* -Get's the current player list. This is only really used by the host. This is -almost never called by the client itself +Get's the current player list for a game. Emissions: PlayerListResponse->sender - Sends the list of players to the client */ -import * as db from '../utils/db'; import { Socket } from 'socket.io'; +import { Game } from '../utils/Game'; +import { active_games } from '../main'; export const GetPlayerList = (socket: Socket, data: GetPlayerList) => { try { - if (!db.exists(data.game_code)) { + if (!Object.keys(active_games).includes(data.game_code)) { socket.emit(`PlayerListResponse`, { success: false, - message: `Error: ${data.game_code} does not have an active database.`, + message: `Error: ${data.game_code} does not have an active game object.`, }); } else { - let game: database = db.read(data.game_code); + let game: Game = active_games[data.game_code]; // Respond to client socket.emit(`PlayerListResponse`, { success: true, - players: [Object.keys(game.players)], + players: Object.keys(game.players), }); }; } catch (err) {