Commit 7d51dbda authored by 18신대성's avatar 18신대성 Committed by 18손재민

1등이 정해진 이후로는 통신을 안하도록 바꿈

parent bd3b9a82
......@@ -2,7 +2,7 @@ var GameServer = GameServer || {};
GameServer.serverNumber = -1;
GameServer.Phase = {READY: 0, COUNT: -1, START: 1, MAIN: 2, MUSIC: 3};
GameServer.Phase = {READY: 0, COUNT: -1, START: 1, MAIN: 2, MUSIC: 3, GAMEEND: 4};
GameServer.connectCount = 0;
GameServer.disconnectCount = 0;
......@@ -215,6 +215,8 @@ class GameRoom
clearTimeout(this.startTimer);
this.startTimer = undefined;
}
if (this.currentPhase != GameServer.Phase.GAMEEND)
{
this.announceToRoom('enterRoom');
this.announceToRoom('syncRoomScene', this.currentPlayer);
this.announceToRoom('setRoomCount', {
......@@ -223,6 +225,22 @@ class GameRoom
});
console.error('[ROOM#' + this.roomId + '] room Refreshed');
}
else
{
this.startTime = 0;
this.currentPlayer = [];
this.aliveCount = 0;
this.currentSocket = [];
this.currentPhase = GameServer.Phase.READY;
this.phaseChanger = -1;
this.countEndTime = 0;
this.rateArrangePoint = 300;
this.maxTypingPlayer = null;
this.minTypingPlayer = null;
console.log('[ROOM#' + this.roomId + '] room Refreshed with End of Game');
}
}
startRoom()
{
......@@ -307,14 +325,19 @@ class GameRoom
}
announceToRoom(_message, _data = null)
{
if (this.currentPhase != GameServer.Phase.GAMEEND)
{
this.currentSocket.forEach(function(element)
{
if(element.playerData.playingData.isInThisRoom) element.emit(_message, _data);
});
}
}
announceToTarget(targetId, _message, _data = null)
{
if (this.currentPhase != GameServer.Phase.GAMEEND)
{
let targetSocketIndex = this.currentSocket.findIndex(function(element)
{
......@@ -323,6 +346,7 @@ class GameRoom
//console.log('send to ' + targetSocketIndex + ', receivable? ' + this.currentSocket[targetSocketIndex].playerData.isReceivable);
if (targetSocketIndex != -1 && this.currentSocket[targetSocketIndex].playerData.isReceivable) this.currentSocket[targetSocketIndex].emit(_message, _data);
}
}
}
class Player
......@@ -391,6 +415,7 @@ class Player
});
room.announceToRoom('gameEnd', winner);
room.announceToTarget(winner.id, 'alert', 'gameWin');
room.currentPhase = GameServer.Phase.GAMEEND;
console.log('['+winner.id+']' + ' winner! ' + winner.nickname);
}
}
......
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