Commit 8b5a3cef authored by 18신대성's avatar 18신대성

이제 로그에 시간도 표시됨 (날짜까지는 필요없을거같아서 안넣음)

parent 8aeab709
...@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId) ...@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId)
{ {
if (GameServer.playingRoom[i].roomId === roomId) return GameServer.playingRoom[i]; if (GameServer.playingRoom[i].roomId === roomId) return GameServer.playingRoom[i];
} }
console.log('[ERR] no room with num ' + roomId); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] no room with num ' + roomId);
} }
GameServer.findPlayerSocket = function(playerId) GameServer.findPlayerSocket = function(playerId)
{ {
...@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId) ...@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId)
if (idx != -1) return this.currentPlayer[idx]; if (idx != -1) return this.currentPlayer[idx];
else else
{ {
console.log('[ERR] wrong playerId('+ playerId +') to find'); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] wrong playerId('+ playerId +') to find');
return null; return null;
} }
} }
...@@ -115,7 +115,7 @@ class GameRoom ...@@ -115,7 +115,7 @@ class GameRoom
{ {
GameServer.playingRoom[this.roomIndex] = this; GameServer.playingRoom[this.roomIndex] = this;
} }
console.log('[LOG] new room #'+this.roomId+' made, roomCount: ' + GameServer.playingRoom.length); console.log(new Date().toLocaleTimeString('ko-KR') + ' [LOG] new room #'+this.roomId+' made, roomCount: ' + GameServer.playingRoom.length);
} }
checkHopae(newHopae) checkHopae(newHopae)
...@@ -136,7 +136,7 @@ class GameRoom ...@@ -136,7 +136,7 @@ class GameRoom
this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer); this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer);
this.currentPlayer.push(playerInst); this.currentPlayer.push(playerInst);
console.log('[' + playerInst.id + '] entered to room #' + this.roomId); console.log(new Date().toLocaleTimeString('ko-KR') + ' [' + playerInst.id + '] entered to room #' + this.roomId);
this.aliveCount++; this.aliveCount++;
if (this.currentPlayer.length >= this.startCount) if (this.currentPlayer.length >= this.startCount)
...@@ -202,7 +202,7 @@ class GameRoom ...@@ -202,7 +202,7 @@ class GameRoom
return; return;
} }
} }
console.log('[ERR] No player who have ' + playerId); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] No player who have ' + playerId);
return; return;
} }
...@@ -223,7 +223,7 @@ class GameRoom ...@@ -223,7 +223,7 @@ class GameRoom
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length, isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
isEnter: false, player: {id: -1} isEnter: false, player: {id: -1}
}); });
console.error('[ROOM#' + this.roomId + '] room Refreshed'); console.error(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#' + this.roomId + '] room Refreshed');
} }
else else
{ {
...@@ -238,7 +238,7 @@ class GameRoom ...@@ -238,7 +238,7 @@ class GameRoom
this.rateArrangePoint = 300; this.rateArrangePoint = 300;
this.maxTypingPlayer = null; this.maxTypingPlayer = null;
this.minTypingPlayer = null; this.minTypingPlayer = null;
console.log('[ROOM#' + this.roomId + '] room Refreshed with End of Game'); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#' + this.roomId + '] room Refreshed with End of Game');
} }
} }
...@@ -261,7 +261,7 @@ class GameRoom ...@@ -261,7 +261,7 @@ class GameRoom
}; };
this.announceToRoom('syncRoomData', toSync); this.announceToRoom('syncRoomData', toSync);
console.log('[ROOM#'+this.roomId+'] Game Start with ' + this.currentPlayer.length + ' players'); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#'+this.roomId+'] Game Start with ' + this.currentPlayer.length + ' players');
console.table(this.currentPlayer); console.table(this.currentPlayer);
this.announceToRoom('startGame'); this.announceToRoom('startGame');
this.startTime = Date.now(); this.startTime = Date.now();
...@@ -309,7 +309,7 @@ class GameRoom ...@@ -309,7 +309,7 @@ class GameRoom
{ {
if (this.aliveCount > 0) if (this.aliveCount > 0)
{ {
console.log('[ERR] can not destroy room#' + this.roomId + ', cause player left'); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] can not destroy room#' + this.roomId + ', cause player left');
} }
else else
{ {
...@@ -406,7 +406,7 @@ class Player ...@@ -406,7 +406,7 @@ class Player
} }
room.announceToRoom('defeat', this); room.announceToRoom('defeat', this);
console.log('[' + this.id + '] defeated, rank: ' + this.rank + ', ' + room.aliveCount + ' player left'); console.log(new Date().toLocaleTimeString('ko-KR') + ' [' + this.id + '] defeated, rank: ' + this.rank + ', ' + room.aliveCount + ' player left');
if (room.aliveCount === 1) if (room.aliveCount === 1)
{ {
...@@ -418,7 +418,7 @@ class Player ...@@ -418,7 +418,7 @@ class Player
room.announceToRoom('gameEnd', winner.id); room.announceToRoom('gameEnd', winner.id);
room.announceToTarget(winner.id, 'alert', 'gameWin'); room.announceToTarget(winner.id, 'alert', 'gameWin');
room.currentPhase = GameServer.Phase.GAMEEND; room.currentPhase = GameServer.Phase.GAMEEND;
console.log('['+winner.id+']' + ' winner! ' + winner.nickname); console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+winner.id+']' + ' winner! ' + winner.nickname);
} }
} }
} }
......
...@@ -14,9 +14,9 @@ app.get('/', function(req, res) { ...@@ -14,9 +14,9 @@ app.get('/', function(req, res) {
// http 기본 포트(80)에 서버 열기 // http 기본 포트(80)에 서버 열기
server.listen(80, function() { server.listen(80, function() {
console.log('[SERVER] Listening on port ' + server.address().port); console.log(new Date().toLocaleTimeString('ko-KR') + ' [SERVER] Listening on port ' + server.address().port);
GameServer.serverNumber = Math.floor(Math.random() * 1000 + 1); GameServer.serverNumber = Math.floor(Math.random() * 1000 + 1);
console.log('[SERVER] server number is ' + GameServer.serverNumber); console.log(new Date().toLocaleTimeString('ko-KR') + ' [SERVER] server number is ' + GameServer.serverNumber);
}); });
...@@ -34,7 +34,7 @@ io.on('connection', function(socket) ...@@ -34,7 +34,7 @@ io.on('connection', function(socket)
isReceivable: false isReceivable: false
}; };
GameServer.currentPlayer.push(socket); GameServer.currentPlayer.push(socket);
console.log('['+socket.playerData.id+'] client request'); console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+socket.playerData.id+'] client request');
socket.emit('setId', socket.emit('setId',
{ {
str: 'your number is ' + socket.playerData.id, str: 'your number is ' + socket.playerData.id,
...@@ -49,7 +49,7 @@ io.on('connection', function(socket) ...@@ -49,7 +49,7 @@ io.on('connection', function(socket)
else else
{ {
socket.playerData.nickname = msg; socket.playerData.nickname = msg;
console.log('['+socket.playerData.id+'] nickname set to ' + msg); console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+socket.playerData.id+'] nickname set to ' + msg);
GameServer.enterEmptyRoom(socket); GameServer.enterEmptyRoom(socket);
} }
}); });
...@@ -100,7 +100,7 @@ io.on('connection', function(socket) ...@@ -100,7 +100,7 @@ io.on('connection', function(socket)
}, 1000); }, 1000);
} }
catch (e) { catch (e) {
console.error('[ERR] error catched on setPlayerTyping (' + e + ')'); console.error(new Date().toLocaleTimeString('ko-KR') + ' [ERR] error catched on setPlayerTyping (' + e + ')');
socket.disconnect(); socket.disconnect();
} }
}); });
...@@ -123,7 +123,7 @@ io.on('connection', function(socket) ...@@ -123,7 +123,7 @@ io.on('connection', function(socket)
let deads = room.currentPlayer.filter(element => !element.isAlive); let deads = room.currentPlayer.filter(element => !element.isAlive);
if (room.aliveCount != 0 && room.currentPlayer.length - deads.length >= room.startCount) if (room.aliveCount != 0 && room.currentPlayer.length - deads.length >= room.startCount)
{ {
console.error('[ROOM#'+room.roomId+'] FORCE START!!!'); console.error(new Date().toLocaleTimeString('ko-KR') + ' [ROOM#'+room.roomId+'] FORCE START!!!');
room.startRoom(); room.startRoom();
deads.forEach(function(element) deads.forEach(function(element)
{ {
...@@ -202,7 +202,7 @@ io.on('connection', function(socket) ...@@ -202,7 +202,7 @@ io.on('connection', function(socket)
let data = socket.playerData; let data = socket.playerData;
if (data === undefined) if (data === undefined)
{ {
console.error('[ERROR] data is undefined'); console.error(new Date().toLocaleTimeString('ko-KR') + ' [ERROR] data is undefined');
console.table(GameServer.currentPlayer); console.table(GameServer.currentPlayer);
GameServer.disconnectCount--; GameServer.disconnectCount--;
} }
...@@ -223,7 +223,7 @@ io.on('connection', function(socket) ...@@ -223,7 +223,7 @@ io.on('connection', function(socket)
var disconnectUser = function(data, reason) var disconnectUser = function(data, reason)
{ {
console.log('['+ data.id +'] client disconnected, reason: ' + reason); console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+ data.id +'] client disconnected, reason: ' + reason);
let idxToDel = GameServer.currentPlayer.findIndex(function(element) let idxToDel = GameServer.currentPlayer.findIndex(function(element)
{ {
return element.playerData.id === data.id; return element.playerData.id === data.id;
...@@ -245,5 +245,5 @@ var disconnectUser = function(data, reason) ...@@ -245,5 +245,5 @@ var disconnectUser = function(data, reason)
} }
GameServer.currentPlayer.splice(idxToDel, 1); GameServer.currentPlayer.splice(idxToDel, 1);
} }
console.log('['+ data.id +'] disconnect complete'); //console.log('['+ data.id +'] disconnect complete');
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment