Optimize game.restorePlayer.
(cherry picked from commit 906e5d6b2c78d2837ec68eef63d093cef2da65fe)
This commit is contained in:
parent
b7ebba8f53
commit
bbde8b2cb9
18
game/game.js
18
game/game.js
|
@ -38517,19 +38517,15 @@
|
||||||
event.trigger('enterGame');
|
event.trigger('enterGame');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
restorePlayer:function(player){
|
restorePlayer:player=>{
|
||||||
if(game.players.contains(player)||game.dead.contains(player)) return;
|
if(game.players.contains(player)||game.dead.contains(player)) return;
|
||||||
var position=parseInt(player.dataset.position);
|
let position=parseInt(player.dataset.position);
|
||||||
if(position<0||position>game.players.length+game.dead.length||position==undefined){
|
if(position<0||position>game.players.length+game.dead.length||position==undefined) position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
|
||||||
position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
|
const players=game.players.concat(game.dead);
|
||||||
}
|
|
||||||
var players=game.players.concat(game.dead);
|
|
||||||
ui.arena.setNumber(players.length+1);
|
ui.arena.setNumber(players.length+1);
|
||||||
for(var i=0;i<players.length;i++){
|
players.forEach(value=>{
|
||||||
if(parseInt(players[i].dataset.position)>=position){
|
if(parseInt(value.dataset.position)>=position) value.dataset.position=parseInt(value.dataset.position)+1;
|
||||||
players[i].dataset.position=parseInt(players[i].dataset.position)+1;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
game.players.push(player);
|
game.players.push(player);
|
||||||
delete player.removed;
|
delete player.removed;
|
||||||
player.removeAttribute('style');
|
player.removeAttribute('style');
|
||||||
|
|
Loading…
Reference in New Issue