Commit 276169f8 authored by 18신대성's avatar 18신대성 Committed by 18류지석

왜였는지 모를 에러 수정

parent 13860f74
var GameServer = GameServer || {}; var GameServer = GameServer || {};
GameServer.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3}; GameServer.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3};
GameServer.startCount = 4; GameServer.startCount = 2;
GameServer.currentPlayer = []; GameServer.currentPlayer = [];
GameServer.playingRoom = []; GameServer.playingRoom = [];
...@@ -98,10 +98,10 @@ GameServer.startRoom = function(roomIdx) ...@@ -98,10 +98,10 @@ GameServer.startRoom = function(roomIdx)
roomNum: room.roomNum, roomNum: room.roomNum,
players: room.currentPlayer players: room.currentPlayer
}; };
console.log(toSync); //console.log(toSync);
this.announceToRoom(roomIdx, 'syncRoomData', toSync); this.announceToRoom(roomIdx, 'syncRoomData', toSync);
console.log('[ROOM#'+room.roomNum+'] Game Start'); console.log('[ROOM#'+room.roomNum+'] Game Start with ' + room.currentPlayer.length + ' players');
this.announceToRoom(roomIdx, 'changePhase', this.Phase.START); this.announceToRoom(roomIdx, 'changePhase', this.Phase.START);
this.announceToRoom(roomIdx, 'startGame'); this.announceToRoom(roomIdx, 'startGame');
} }
......
...@@ -14,7 +14,7 @@ class WordObject ...@@ -14,7 +14,7 @@ class WordObject
instantiate(scene, lenRate) instantiate(scene, lenRate)
{ {
let p = [{x : 3, y : 0.7}, {x : 20, y : 1.8}]; let p = [{x : 3, y : 0.7}, {x : 20, y : 1.2}];
let scale = ((p[1].y - p[0].y) / (p[1].x - p[0].x)) * (this.wordWeight - p[0].x) + p[0].y; let scale = ((p[1].y - p[0].y) / (p[1].x - p[0].x)) * (this.wordWeight - p[0].x) + p[0].y;
let fontscale = 25; let fontscale = 25;
var random = WordSpace.getSpawnPoint(lenRate); var random = WordSpace.getSpawnPoint(lenRate);
......
...@@ -78,23 +78,33 @@ io.on('connection', function(socket) ...@@ -78,23 +78,33 @@ io.on('connection', function(socket)
}); });
socket.on('disconnect', function(reason) socket.on('disconnect', function(reason)
{
let data = socket.playerData;
console.log('['+ data.id +'] client disconnected, reason: ' + reason);
if (data.id === undefined)
{
console.log('[ERROR] data.id is undefined');
console.log(GameServer.currentPlayer);
}
else // data.id is not undefined
{ {
let idxToDel = GameServer.currentPlayer.findIndex(function(element) let idxToDel = GameServer.currentPlayer.findIndex(function(element)
{ {
return element.id === socket.playerData.id; return element.id === data.id;
}); });
if (idxToDel != -1) if (idxToDel != -1)
{ {
console.log('['+ socket.playerData.id +'] client disconnected, reason: ' + reason);
GameServer.currentPlayer.splice(idxToDel, 1); GameServer.currentPlayer.splice(idxToDel, 1);
// 룸에서도 제거 // 룸에서도 제거
if (socket.playerData.currentRoom != null) if (data.currentRoom != null)
{ {
socket.playerData.playingData.isAlive = false; data.playingData.isAlive = false;
if (socket.playerData.playingData.rank === -1) socket.playerData.playingData.rank = socket.playerData.currentRoom.nextRank--; if (data.playingData.rank === -1) data.playingData.rank = data.currentRoom.nextRank--;
socket.playerData.currentRoom.currentSocket.splice(socket.playerData.playingData.index, 1); data.currentRoom.currentSocket.splice(data.playingData.index, 1);
GameServer.announceToRoom(GameServer.findRoomIndex(socket.playerData.currentRoom.roomNum), 'userDisconnect', socket.playerData.playingData); GameServer.announceToRoom(GameServer.findRoomIndex(data.currentRoom.roomNum), 'userDisconnect', data.playingData);
}
} }
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