Add more log events to the JoinGame function.
This commit is contained in:
parent
0fe1008196
commit
dbd6aefbd2
1 changed files with 3 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ export const JoinGame = (socket: Socket, data: JoinGame) => {
|
||||||
|
|
||||||
// Ensure username is not already taken
|
// Ensure username is not already taken
|
||||||
if (Object.keys(game.players).includes(data.username)) {
|
if (Object.keys(game.players).includes(data.username)) {
|
||||||
|
log.debug(`${data.username} tried joining game ${game.code} but the name is already taken.`);
|
||||||
socket.emit(`GameJoined`, {
|
socket.emit(`GameJoined`, {
|
||||||
success: false,
|
success: false,
|
||||||
message: `That username is already taken, please try another.`,
|
message: `That username is already taken, please try another.`,
|
||||||
|
|
@ -44,6 +45,8 @@ export const JoinGame = (socket: Socket, data: JoinGame) => {
|
||||||
|
|
||||||
game.add_player(data.username);
|
game.add_player(data.username);
|
||||||
|
|
||||||
|
log.info(`${data.username} joined game ${game.code}`);
|
||||||
|
|
||||||
// Alert player who joined
|
// Alert player who joined
|
||||||
socket.emit(`GameJoined`, {
|
socket.emit(`GameJoined`, {
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue