Commit 6052d290 authored by 18손재민's avatar 18손재민 Committed by 18류지석

호패 생성 수에 제한을 둠

parent 9b13860d
...@@ -242,9 +242,12 @@ WordSpace.generateWord = ...@@ -242,9 +242,12 @@ WordSpace.generateWord =
}, },
Name: function(scene, isStrong, newPlayerData, lenRate) Name: function(scene, isStrong, newPlayerData, lenRate)
{ {
if(newPlayerData == null) word = new NameWord(WordSpace.nameQueue.pop(), isStrong); if(newPlayerData == null)
{
if(WordSpace.nameQueue.queue.length == 1) return null;
word = new NameWord(WordSpace.nameQueue.pop(), isStrong);
}
else word = new NameWord(newPlayerData, isStrong); else word = new NameWord(newPlayerData, isStrong);
//word = new NameWord(RoomData.myself, false);
WordSpace.pushWord(scene, word, lenRate); WordSpace.pushWord(scene, word, lenRate);
return word; return word;
} }
...@@ -473,7 +476,7 @@ WordSpace.nameQueue = ...@@ -473,7 +476,7 @@ WordSpace.nameQueue =
tempQueue.sort(function(){return 0.5-Math.random()}); tempQueue.sort(function(){return 0.5-Math.random()});
tempQueue.forEach(function(element) tempQueue.forEach(function(element)
{ {
if(RoomData.players[element].id != PlayerData.id && RoomData.players[element].isAlive) if(RoomData.players[element].id != PlayerData.id && RoomData.players[element].isAlive && WordSpace.nameQueue.getCount(element) < 3)
WordSpace.nameQueue.queue.push(element); WordSpace.nameQueue.queue.push(element);
}); });
}, },
...@@ -481,8 +484,19 @@ WordSpace.nameQueue = ...@@ -481,8 +484,19 @@ WordSpace.nameQueue =
{ {
let tempElement = WordSpace.nameQueue.queue.shift(); let tempElement = WordSpace.nameQueue.queue.shift();
if(WordSpace.nameQueue.queue.length <= RoomData.aliveCount) this.shuffle(); if(WordSpace.nameQueue.queue.length <= RoomData.aliveCount) this.shuffle();
if(!RoomData.players[tempElement].isAlive) return WordSpace.nameQueue.pop(); if(this.queue.length > 0)
else return RoomData.players[tempElement]; {
if(!RoomData.players[tempElement].isAlive && WordSpace.nameQueue.getCount(tempElement) < 3) WordSpace.nameQueue.pop();
else return RoomData.players[tempElement];
}
},
getCount: function(player)
{
let i = 0;
WordSpace.nameGroup.forEach(function(element){
if(element.id == player.id) i++;
})
return i;
}, },
initiate: function() initiate: function()
{ {
......
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