Add socket ID to player's information and remove host from initializer
This commit is contained in:
parent
efa7540404
commit
f43f36eb46
4 changed files with 8 additions and 5 deletions
|
|
@ -29,7 +29,8 @@ export const HostGame = (socket: Socket, data: HostGame) => {
|
|||
socket.join(game_code);
|
||||
|
||||
// Create the game
|
||||
let game = new Game(game_code, data.username)
|
||||
let game = new Game(game_code);
|
||||
game.add_player(data.username, socket.id, true);
|
||||
active_games[game_code] = game;
|
||||
log.info(`${data.username} created a game. (Gamecode: ${game_code})`);
|
||||
|
||||
|
|
@ -40,7 +41,6 @@ export const HostGame = (socket: Socket, data: HostGame) => {
|
|||
});
|
||||
} catch (err) {
|
||||
log.prettyError(err);
|
||||
// Let client know an error occured
|
||||
socket.emit(`HostInformation`, {
|
||||
success: false,
|
||||
error: `${err.name}: ${err.message}`
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ export const JoinGame = (socket: Socket, data: JoinGame) => {
|
|||
|
||||
game.add_player(data.username);
|
||||
|
||||
// Add the player
|
||||
game.add_player(data.username, socket.id);
|
||||
log.info(`${data.username} joined game ${game.code}`);
|
||||
|
||||
// Alert player who joined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue