Commit dfc0f826 authored by 18손재민's avatar 18손재민

Merge branch 'wordspace' into release

parents 22c3f8fa 9c3f21f8
var GameServer = GameServer || {}; 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};
GameServer.connectCount = 0;
GameServer.disconnectCount = 0;
GameServer.currentPlayer = []; GameServer.currentPlayer = [];
GameServer.playingRoom = []; GameServer.playingRoom = [];
...@@ -70,14 +74,13 @@ GameServer.getRoomNumber = function() ...@@ -70,14 +74,13 @@ GameServer.getRoomNumber = function()
} while (true) } while (true)
} }
class GameRoom class GameRoom
{ {
constructor() constructor()
{ {
this.roomId = GameServer.getRoomNumber(); this.roomId = GameServer.getRoomNumber();
this.roomIndex = -1; this.roomIndex = -1;
this.startCount = 2; this.startCount = 5;
this.maxPlayer = 100; this.maxPlayer = 100;
this.nextRank = 100; this.nextRank = 100;
...@@ -133,7 +136,7 @@ class GameRoom ...@@ -133,7 +136,7 @@ class GameRoom
{ {
if (this.currentPhase === GameServer.Phase.READY) if (this.currentPhase === GameServer.Phase.READY)
{ {
this.endTime = Date.now() + 5000; // 테스트용 10초 this.endTime = Date.now() + 1000; // 테스트용 10초
this.announceToRoom('setRoomCount', this.announceToRoom('setRoomCount',
{ {
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length, isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
...@@ -201,7 +204,6 @@ class GameRoom ...@@ -201,7 +204,6 @@ class GameRoom
this.announceToRoom('syncRoomData', toSync); this.announceToRoom('syncRoomData', toSync);
console.log('[ROOM#'+this.roomId+'] Game Start with ' + this.currentPlayer.length + ' players'); console.log('[ROOM#'+this.roomId+'] Game Start with ' + this.currentPlayer.length + ' players');
this.announceToRoom('changePhase', GameServer.Phase.START);
this.announceToRoom('startGame'); this.announceToRoom('startGame');
this.startTime = Date.now(); this.startTime = Date.now();
} }
...@@ -210,9 +212,10 @@ class GameRoom ...@@ -210,9 +212,10 @@ class GameRoom
{ {
if (this.currentPhase === GameServer.Phase.START) if (this.currentPhase === GameServer.Phase.START)
{ {
if (this.phaseChanger < 0 && checkTime - this.startTime > 60000) if (this.phaseChanger < 0 && checkTime - this.startTime > 6000)
{ {
this.currentPhase = GameServer.Phase.MAIN; this.currentPhase = GameServer.Phase.MAIN;
this.rateArrangePoint = 150;
this.announceToRoom('changePhase', GameServer.Phase.MAIN); this.announceToRoom('changePhase', GameServer.Phase.MAIN);
} }
else if (this.phaseChanger < 0) else if (this.phaseChanger < 0)
...@@ -220,6 +223,7 @@ class GameRoom ...@@ -220,6 +223,7 @@ class GameRoom
this.phaseChanger = setTimeout(function(room) this.phaseChanger = setTimeout(function(room)
{ {
room.currentPhase = GameServer.Phase.MAIN; room.currentPhase = GameServer.Phase.MAIN;
room.rateArrangePoint = 150;
room.announceToRoom('changePhase', GameServer.Phase.MAIN); room.announceToRoom('changePhase', GameServer.Phase.MAIN);
room.phaseChanger = -1; room.phaseChanger = -1;
}, 60000 - (checkTime - this.startTime), this); }, 60000 - (checkTime - this.startTime), this);
...@@ -227,10 +231,11 @@ class GameRoom ...@@ -227,10 +231,11 @@ class GameRoom
} }
else if (this.currentPhase === GameServer.Phase.MAIN) else if (this.currentPhase === GameServer.Phase.MAIN)
{ {
let playerLimit = Math.max(this.currentPlayer.length / 10, 3); let playerLimit = Math.min(Math.round(this.currentPlayer.length / 5), 3);
if (this.aliveCount <= playerLimit) if (this.aliveCount <= playerLimit)
{ {
this.currentPhase = GameServer.Phase.MUSIC; this.currentPhase = GameServer.Phase.MUSIC;
this.rateArrangePoint = 50;
this.announceToRoom('changePhase', GameServer.Phase.MUSIC); this.announceToRoom('changePhase', GameServer.Phase.MUSIC);
} }
} }
...@@ -287,12 +292,14 @@ class Player ...@@ -287,12 +292,14 @@ class Player
this.gameRoomId = gameRoom.roomId; this.gameRoomId = gameRoom.roomId;
this.index = gameRoom.currentPlayer.length; this.index = gameRoom.currentPlayer.length;
this.nickname = playerData.nickname; this.nickname = playerData.nickname;
this.playerImage = null;
this.position = null;
this.isAlive = true; this.isAlive = true;
this.rank = -1; this.rank = -1;
this.playerTyping = 0; this.playerTyping = 0;
this.lastAttacks = []; // { attackerId, word, wordGrade, time } this.lastAttacks = []; // { attackerId, attacker, wrongCount, word, wordGrade, time }
this.lastAttack = null; this.lastAttack = null;
} }
...@@ -312,18 +319,22 @@ class Player ...@@ -312,18 +319,22 @@ class Player
if (this.lastAttacks.length > 0) if (this.lastAttacks.length > 0)
{ {
this.lastAttack = this.lastAttacks[this.lastAttacks.length - 1]; this.lastAttack = this.lastAttacks[this.lastAttacks.length - 1];
if (Date.now() - this.lastAttack.time > 40000) this.lastAttack = null; if (Date.now() - this.lastAttack.time > 20000) this.lastAttack = null;
else else
{ {
this.lastAttacks.forEach(function(element) this.lastAttacks.forEach(function(element)
{ {
if (Date.now() - element.time < 40000 && element.wordGrade > player.lastAttack.wordGrade) player.lastAttack = element; if (Date.now() - element.time < 20000)
{
if (element.wrongCount > player.lastAttack.wrongCount) player.lastAttack = element;
else if (element.wrongCount === player.lastAttack.wrongCount && element.wordGrade > player.lastAttack.wordGrade) player.lastAttack = element;
}
}); });
} }
} }
room.announceToRoom('defeat', this); room.announceToRoom('defeat', this);
console.log('[' + this.id + '] defeated, rank: ' + this.rank + ', ' + room.currentPlayer.length + 'player left'); console.log('[' + this.id + '] defeated, rank: ' + this.rank + ', ' + room.aliveCount + ' player left');
if (socket.playerData.currentRoom.aliveCount === 1) if (socket.playerData.currentRoom.aliveCount === 1)
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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