Commit 44c46a35 authored by 18손재민's avatar 18손재민

현재 방에 있는 플레이어들 닉네임으로 랜덤 큐 제작 wip 현재 최대 플레이어 수를 제대로 인식하지 못하는 문제 있음

parent 30e0a44f
var GameServer = GameServer || {};
GameServer.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3};
GameServer.startCount = 2;
GameServer.startCount = 3;
GameServer.currentPlayer = [];
GameServer.playingRoom = [];
......
......@@ -60,6 +60,8 @@ var gameScene = new Phaser.Class(
WordSpace.setPlayerTyping.initiate(this);
WordSpace.nameWordTextForTest = WordSpace.gameSceneForTest.add.text(50,400,'현재 가진 호패들 : 없음').setDepth(10).setColor('#000000');
WordSpace.nameQueue.shuffle();
},
update: function()
......
......@@ -253,6 +253,10 @@ WordSpace.generateWord =
Name: function(scene, isStrong, lenRate)
{
//To do
/*RoomData.players.forEach(function(element)
{
WordSpace.generateWord.Attack(WordSpace.gameSceneForTest, wordText, grade, PlayerData.nickname, element.isStrong);
});*/
word = new NameWord(PlayerData.nickname, isStrong);
WordSpace.pushWord(scene, word, lenRate);
}
......@@ -391,4 +395,32 @@ WordSpace.attack = function(wordText, grade)
Input.maxInput = 6;
Input.attackMode = false;
WordSpace.attackGauge.pauseCycle(false);
}
WordSpace.nameQueue =
{
queue: [],
shuffle: function()
{
let tempIdx, tempElement, tempLength;
let tempQueue = RoomData.players;
for(tempLength = tempQueue.length; tempLength; tempLength -= 1)
{
tempIdx = Math.floor(Math.random() * tempLength);
tempElement = tempQueue[tempLength - 1];
tempQueue[tempLength - 1] = tempQueue[tempIdx];
tempQueue[tempIdx] = tempElement;
}
tempQueue.forEach(function(element){
if(element.nickname != PlayerData.nickname && element.isAlive)
WordSpace.nameQueue.queue.push(element);
});
console.log(WordSpace.nameQueue.queue);
console.log(RoomData.aliveCount);
},
pop: function()
{
let tempElement = WordSpace.nameQueue.queue.pop();
if(WordSpace.nameQueue.queue.length <= RoomData.aliveCount) this.shuffle();
return tempElement;
}
}
\ 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