Skip to content

Commit

Permalink
Added logging for game events and slight cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
vck3000 committed Jan 7, 2024
1 parent d669f32 commit 56e57f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/gameplay/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ class Room {
if (this.gameStarted && this.gameStarted === true) {
this.addToChatHistory(data);
}

console.log(`[Room Chat] [Room ${this.roomId}] ${incString}`);
}

updateRoomPlayers() {
Expand Down Expand Up @@ -678,7 +680,7 @@ class Room {
if (playerSocket.isBotSocket) {
playerSocket.handleReadyNotReady(
thisGame,
function (botReady, reason) {
function(botReady, reason) {
if (botReady) {
thisGame.playerReady(playerSocket.request.user.username);
} else {
Expand Down
15 changes: 1 addition & 14 deletions src/sockets/sockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1362,24 +1362,14 @@ export const server = function (io: SocketServer): void {

socket.on('disconnect', disconnect);

//=======================================
// COMMANDS
//=======================================

socket.on('messageCommand', messageCommand);
socket.on('interactUserPlayed', interactUserPlayed);
// when a user tries to send a message to all chat
socket.on('allChatFromClient', allChatFromClient);
// when a user tries to send a message to room
socket.on('roomChatFromClient', roomChatFromClient);
// when a new room is created
socket.on('newRoom', newRoom);
// when a player joins a room
socket.on('join-room', joinRoom);
socket.on('join-game', joinGame);
socket.on('standUpFromGame', standUpFromGame);

// when a player leaves a room
socket.on('leave-room', leaveRoom);
socket.on('player-ready', playerReady);
socket.on('player-not-ready', playerNotReady);
Expand All @@ -1391,9 +1381,6 @@ export const server = function (io: SocketServer): void {
socket.on('update-room-muteSpectators', updateRoomMuteSpectators);
socket.on('update-room-disableVoteHistory', updateRoomDisableVoteHistory);

//************************
// game data stuff
//************************
socket.on('gameMove', gameMove);
socket.on('setClaim', setClaim);
});
Expand Down Expand Up @@ -2243,9 +2230,9 @@ function setClaim(data) {
}

function gameMove(data) {
// console.log(data);
if (rooms[this.request.user.inRoomId]) {
rooms[this.request.user.inRoomId].gameMove(this, data);

if (rooms[this.request.user.inRoomId]) {
if (rooms[this.request.user.inRoomId].finished === true) {
deleteSaveGameFromDb(rooms[this.request.user.inRoomId]);
Expand Down

0 comments on commit 56e57f8

Please sign in to comment.