Commit 3fe7e321 authored by 18신대성's avatar 18신대성

대기실 카운터 구현완료

parent d7bf6857
......@@ -34,12 +34,13 @@ GameServer.makeRoom = function()
var roomOption =
{
roomNum: GameServer.nextRoomNumber++,
maxPlayer: 5,
nextRank: 0,
maxPlayer: 100,
nextRank: 100,
currentPlayer: [],
aliveCount: 0,
currentSocket: [],
currentPhase: GameServer.Phase.READY,
endTime: 0,
rateArrangePoint: 300,
maxTypingPlayer: null,
......@@ -86,16 +87,16 @@ GameServer.enterRoom = function(roomIdx, playerData)
console.log('[' + playerData.id + '] entered to room #' + room.roomNum);
playerData.socketId.emit('enterRoom');
let endTimeToAnnounce = Date.now() + 6000;
room.endTime = Date.now() + 6000; // 테스트로 6초로 남겨둠
if (room.currentPlayer.length >= this.startCount)
{
if (room.currentPhase === this.Phase.READY) // start count
{
this.announceToRoom(room.roomNum, 'setCount', {isEnable: true, endTime: endTimeToAnnounce});
this.announceToRoom(room.roomNum, 'setCount', {isEnable: true, endTime: room.endTime});
}
else if (room.currentPhase === this.Phase.COUNT) // countinue count
{
playerData.socketId.emit('setCount', {isEnable: true, endTime: endTimeToAnnounce});
playerData.socketId.emit('setCount', {isEnable: true, endTime: room.endTime});
}
}
else // stop count
......
......@@ -72,14 +72,14 @@ io.on('connection', function(socket)
socket.emit('setPlayerTypingRate', playerTypingRate);
});
socket.on('endCount')
socket.on('endCount', function()
{
socket.currentRoom.aliveCount--;
if (socket.currentRoom.aliveCount === 0)
socket.playerData.currentRoom.aliveCount--;
if (socket.playerData.currentRoom.aliveCount === 0)
{
GameServer.startRoom(GameServer.findRoomIndex(socket.currentRoom.roomNum));
GameServer.startRoom(GameServer.findRoomIndex(socket.playerData.currentRoom.roomNum));
}
}
});
socket.on('attack', function(msg)
{
......@@ -118,7 +118,6 @@ io.on('connection', function(socket)
socket.on('disconnect', function(reason)
{
let data = socket.playerData;
console.log('['+ data.id +'] client disconnected, reason: ' + reason);
if (typeof data.id === undefined)
{
console.log('[ERROR] data.id is undefined');
......@@ -126,6 +125,7 @@ io.on('connection', function(socket)
}
else // data.id is not undefined
{
console.log('['+ data.id +'] client disconnected, reason: ' + reason);
let idxToDel = GameServer.currentPlayer.findIndex(function(element)
{
return element.id === data.id;
......
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