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

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

parent 8aeab709
......@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId)
{
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)
{
......@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId)
if (idx != -1) return this.currentPlayer[idx];
else
{
console.log('[ERR] wrong playerId('+ playerId +') to find');
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] wrong playerId('+ playerId +') to find');
return null;
}
}
......@@ -115,7 +115,7 @@ class GameRoom
{
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)
......@@ -136,7 +136,7 @@ class GameRoom
this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer);
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++;
if (this.currentPlayer.length >= this.startCount)
......@@ -202,7 +202,7 @@ class GameRoom
return;
}
}
console.log('[ERR] No player who have ' + playerId);
console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] No player who have ' + playerId);
return;
}
......@@ -223,7 +223,7 @@ class GameRoom
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
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
{
......@@ -238,7 +238,7 @@ class GameRoom
this.rateArrangePoint = 300;
this.maxTypingPlayer = 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
};
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);
this.announceToRoom('startGame');
this.startTime = Date.now();
......@@ -309,7 +309,7 @@ class GameRoom
{
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
{
......@@ -406,7 +406,7 @@ class Player
}
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)
{
......@@ -418,7 +418,7 @@ class Player
room.announceToRoom('gameEnd', winner.id);
room.announceToTarget(winner.id, 'alert', 'gameWin');
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) {
// http 기본 포트(80)에 서버 열기
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);
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)
isReceivable: false
};
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',
{
str: 'your number is ' + socket.playerData.id,
......@@ -49,7 +49,7 @@ io.on('connection', function(socket)
else
{
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);
}
});
......@@ -100,7 +100,7 @@ io.on('connection', function(socket)
}, 1000);
}
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();
}
});
......@@ -123,7 +123,7 @@ io.on('connection', function(socket)
let deads = room.currentPlayer.filter(element => !element.isAlive);
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();
deads.forEach(function(element)
{
......@@ -202,7 +202,7 @@ io.on('connection', function(socket)
let data = socket.playerData;
if (data === undefined)
{
console.error('[ERROR] data is undefined');
console.error(new Date().toLocaleTimeString('ko-KR') + ' [ERROR] data is undefined');
console.table(GameServer.currentPlayer);
GameServer.disconnectCount--;
}
......@@ -223,7 +223,7 @@ io.on('connection', function(socket)
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)
{
return element.playerData.id === data.id;
......@@ -245,5 +245,5 @@ var disconnectUser = function(data, reason)
}
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