Commit 442fd515 authored by 18손재민's avatar 18손재민

Merge branch 'server'

parents 5af28e1d 8b5a3cef
...@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId) ...@@ -15,7 +15,7 @@ GameServer.findRoom = function(roomId)
{ {
if (GameServer.playingRoom[i].roomId === roomId) return GameServer.playingRoom[i]; 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) GameServer.findPlayerSocket = function(playerId)
{ {
...@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId) ...@@ -26,7 +26,7 @@ GameServer.findPlayerSocket = function(playerId)
if (idx != -1) return this.currentPlayer[idx]; if (idx != -1) return this.currentPlayer[idx];
else else
{ {
console.log('[ERR] wrong playerId('+ playerId +') to find'); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] wrong playerId('+ playerId +') to find');
return null; return null;
} }
} }
...@@ -115,7 +115,7 @@ class GameRoom ...@@ -115,7 +115,7 @@ class GameRoom
{ {
GameServer.playingRoom[this.roomIndex] = this; 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) checkHopae(newHopae)
...@@ -136,7 +136,7 @@ class GameRoom ...@@ -136,7 +136,7 @@ class GameRoom
this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer); this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer);
this.currentPlayer.push(playerInst); 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++; this.aliveCount++;
if (this.currentPlayer.length >= this.startCount) if (this.currentPlayer.length >= this.startCount)
...@@ -202,7 +202,7 @@ class GameRoom ...@@ -202,7 +202,7 @@ class GameRoom
return; return;
} }
} }
console.log('[ERR] No player who have ' + playerId); console.log(new Date().toLocaleTimeString('ko-KR') + ' [ERR] No player who have ' + playerId);
return; return;
} }
...@@ -223,7 +223,7 @@ class GameRoom ...@@ -223,7 +223,7 @@ class GameRoom
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length, isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
isEnter: false, player: {id: -1} 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 else
{ {
...@@ -238,7 +238,7 @@ class GameRoom ...@@ -238,7 +238,7 @@ class GameRoom
this.rateArrangePoint = 300; this.rateArrangePoint = 300;
this.maxTypingPlayer = null; this.maxTypingPlayer = null;
this.minTypingPlayer = 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 ...@@ -261,7 +261,7 @@ class GameRoom
}; };
this.announceToRoom('syncRoomData', toSync); 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); console.table(this.currentPlayer);
this.announceToRoom('startGame'); this.announceToRoom('startGame');
this.startTime = Date.now(); this.startTime = Date.now();
...@@ -309,7 +309,7 @@ class GameRoom ...@@ -309,7 +309,7 @@ class GameRoom
{ {
if (this.aliveCount > 0) 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 else
{ {
...@@ -406,7 +406,7 @@ class Player ...@@ -406,7 +406,7 @@ class Player
} }
room.announceToRoom('defeat', this); 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) if (room.aliveCount === 1)
{ {
...@@ -418,7 +418,7 @@ class Player ...@@ -418,7 +418,7 @@ class Player
room.announceToRoom('gameEnd', winner.id); room.announceToRoom('gameEnd', winner.id);
room.announceToTarget(winner.id, 'alert', 'gameWin'); room.announceToTarget(winner.id, 'alert', 'gameWin');
room.currentPhase = GameServer.Phase.GAMEEND; room.currentPhase = GameServer.Phase.GAMEEND;
console.log('['+winner.id+']' + ' winner! ' + winner.nickname); console.log(new Date().toLocaleTimeString('ko-KR') + ' ['+winner.id+']' + ' winner! ' + winner.nickname);
} }
} }
} }
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script src="js/phaser.js"></script> <script src="/js/phaser.js"></script>
<script src="js/ScenesData.js"></script> <script src="/js/ScenesData.js"></script>
<script src="js/Background.js"></script> <script src="/js/Background.js"></script>
<script src="js/Input.js"></script> <script src="/js/Input.js"></script>
<script src="js/WordSpace.js"></script> <script src="/js/WordSpace.js"></script>
<script src="js/GameCycle.js"></script> <script src="/js/GameCycle.js"></script>
<script src="js/WordObject.js"></script> <script src="/js/WordObject.js"></script>
<script src="js/WordReader.js"></script> <script src="/js/WordReader.js"></script>
<script src="js/CSVParsing.js"></script> <script src="/js/CSVParsing.js"></script>
<script src="js/SelectWord.js"></script> <script src="/js/SelectWord.js"></script>
<script src="js/BGMsound.js"></script> <script src="/js/BGMsound.js"></script>
<script src="js/Enums.js"></script> <script src="/js/Enums.js"></script>
<script src="js/ResourceLoader.js"></script> <script src="/js/ResourceLoader.js"></script>
<script src="js/UIObject.js"></script> <script src="/js/UIObject.js"></script>
<style media='screen' type='text/css'> <style media='screen' type='text/css'>
@font-face { @font-face {
font-family: sejongFont; font-family: sejongFont;
...@@ -31,18 +31,20 @@ ...@@ -31,18 +31,20 @@
<style> <style>
img { position: relative; width: 100%; height: 100%; z-index: 0;} img { position: relative; width: 100%; height: 100%; z-index: 0;}
#dvLogin { position: absolute; left: 65%; top: 35%; width: 30%; height: 30%; padding: 10px; background: black; z-index: 1;} #dvLogin { position: absolute; left: 65%; top: 35%; width: 30%; height: 30%; padding: 10px; background: black; z-index: 1;}
#notSupport { position: absolute; left: 25%; top: 25%; background: white; z-index: 1; width: 50%; height: 50%; display: none;}
</style> </style>
</head> </head>
<body> <body>
<div id="mainTitle"> <div id="mainTitle">
<img id="titleImg" src="assets/image/background/title.png" alt="title"> <img id="titleImg" src="/assets/image/background/title.png" alt="title">
<div id="dvLogin"> <div id="dvLogin">
<input id="userEmail" type="email" placeholder="email" style="width: 100%; height: 10%;"></br> <input id="userEmail" type="email" placeholder="email" style="width: 100%; height: 10%;"></br>
<input id="userPassword" type="password" placeholder="password" maxlength="17" style="width: 100%; height: 10%;"></br> <input id="userPassword" type="password" placeholder="password" maxlength="17" style="width: 100%; height: 10%;"></br>
<button id="joinBtn" style="width: 100%; height: 10%;">이메일로 가입하기</button></br> <button id="joinBtn" style="width: 100%; height: 10%;">이메일로 가입하기</button></br>
<button id="emailBtn" style="width: 100%; height: 10%;">이메일로 로그인</button></br> <button id="emailBtn" style="width: 100%; height: 10%;">이메일로 로그인</button></br>
<button id="googleBtn" style="width: 10%; height: 10%;"><img src="assets/title/googleBtn.png" style="object-fit: contain"></button></br> <button id="googleBtn" style="width: 10%; height: 10%;"><img src="/assets/title/googleBtn.png" style="object-fit: contain"></button></br>
</div> </div>
<p id="notSupport">해당하는 환경에서는 지원되지 않습니다. PC에서 이용 부탁드립니다.</p>
</div> </div>
<script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"></script>
...@@ -64,8 +66,8 @@ ...@@ -64,8 +66,8 @@
firebase.initializeApp(firebaseConfig); firebase.initializeApp(firebaseConfig);
</script> </script>
<script src="js/Client.js"></script> <script src="/js/Client.js"></script>
<script src="js/Main.js"></script> <script src="/js/main.js"></script>
<script src="js/FirebaseClient.js"></script> <script src="/js/FirebaseClient.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -243,12 +243,23 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = ...@@ -243,12 +243,23 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
document.addEventListener('DOMContentLoaded', function() document.addEventListener('DOMContentLoaded', function()
{ {
window.fbClient = new FirebaseClient(); var filter = "win16|win32|win64|mac|macintel";
document.onkeydown = function(e) if ( navigator.platform ){
{ if ( filter.indexOf(navigator.platform.toLowerCase())<0 ){
if (!fbClient.isGameStarted && e.keyCode === 13) document.getElementById('dvLogin').style.display = 'none';
document.getElementById('notSupport').style.display = 'block';
}
else
{ {
fbClient.onEmailBtnClick(); window.fbClient = new FirebaseClient();
document.onkeydown = function(e)
{
if (!fbClient.isGameStarted && e.keyCode === 13)
{
fbClient.onEmailBtnClick();
}
}
} }
} }
console.log('done load'); console.log('done load');
......
...@@ -13,10 +13,10 @@ app.get('/', function(req, res) { ...@@ -13,10 +13,10 @@ app.get('/', function(req, res) {
}); });
// http 기본 포트(80)에 서버 열기 // http 기본 포트(80)에 서버 열기
server.listen(8080, function() { 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); 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) ...@@ -34,7 +34,7 @@ io.on('connection', function(socket)
isReceivable: false isReceivable: false
}; };
GameServer.currentPlayer.push(socket); 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', socket.emit('setId',
{ {
str: 'your number is ' + socket.playerData.id, str: 'your number is ' + socket.playerData.id,
...@@ -49,7 +49,7 @@ io.on('connection', function(socket) ...@@ -49,7 +49,7 @@ io.on('connection', function(socket)
else else
{ {
socket.playerData.nickname = msg; 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); GameServer.enterEmptyRoom(socket);
} }
}); });
...@@ -100,7 +100,7 @@ io.on('connection', function(socket) ...@@ -100,7 +100,7 @@ io.on('connection', function(socket)
}, 1000); }, 1000);
} }
catch (e) { 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(); socket.disconnect();
} }
}); });
...@@ -123,7 +123,7 @@ io.on('connection', function(socket) ...@@ -123,7 +123,7 @@ io.on('connection', function(socket)
let deads = room.currentPlayer.filter(element => !element.isAlive); let deads = room.currentPlayer.filter(element => !element.isAlive);
if (room.aliveCount != 0 && room.currentPlayer.length - deads.length >= room.startCount) 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(); room.startRoom();
deads.forEach(function(element) deads.forEach(function(element)
{ {
...@@ -202,7 +202,7 @@ io.on('connection', function(socket) ...@@ -202,7 +202,7 @@ io.on('connection', function(socket)
let data = socket.playerData; let data = socket.playerData;
if (data === undefined) if (data === undefined)
{ {
console.error('[ERROR] data is undefined'); console.error(new Date().toLocaleTimeString('ko-KR') + ' [ERROR] data is undefined');
console.table(GameServer.currentPlayer); console.table(GameServer.currentPlayer);
GameServer.disconnectCount--; GameServer.disconnectCount--;
} }
...@@ -223,7 +223,7 @@ io.on('connection', function(socket) ...@@ -223,7 +223,7 @@ io.on('connection', function(socket)
var disconnectUser = function(data, reason) 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) let idxToDel = GameServer.currentPlayer.findIndex(function(element)
{ {
return element.playerData.id === data.id; return element.playerData.id === data.id;
...@@ -245,5 +245,5 @@ var disconnectUser = function(data, reason) ...@@ -245,5 +245,5 @@ var disconnectUser = function(data, reason)
} }
GameServer.currentPlayer.splice(idxToDel, 1); 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