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,13 +215,31 @@ class GameRoom
clearTimeout(this.startTimer);
this.startTimer = undefined;
}
this.announceToRoom('enterRoom');
this.announceToRoom('syncRoomScene', this.currentPlayer);
this.announceToRoom('setRoomCount', {
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
isEnter: false, player: {id: -1}
});
console.error('[ROOM#' + this.roomId + '] room Refreshed');
if (this.currentPhase != GameServer.Phase.GAMEEND)
{
this.announceToRoom('enterRoom');
this.announceToRoom('syncRoomScene', this.currentPlayer);
this.announceToRoom('setRoomCount', {
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
isEnter: false, player: {id: -1}
});
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()
......@@ -308,20 +326,26 @@ class GameRoom
announceToRoom(_message, _data = null)
{
this.currentSocket.forEach(function(element)
if (this.currentPhase != GameServer.Phase.GAMEEND)
{
if(element.playerData.playingData.isInThisRoom) element.emit(_message, _data);
});
this.currentSocket.forEach(function(element)
{
if(element.playerData.playingData.isInThisRoom) element.emit(_message, _data);
});
}
}
announceToTarget(targetId, _message, _data = null)
{
let targetSocketIndex = this.currentSocket.findIndex(function(element)
if (this.currentPhase != GameServer.Phase.GAMEEND)
{
return element.playerData.id === targetId;
});
//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);
let targetSocketIndex = this.currentSocket.findIndex(function(element)
{
return element.playerData.id === targetId;
});
//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);
}
}
}
......@@ -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