Optimize game.addPlayer.
(cherry picked from commit e376bcdc6122914a2cc6f8c0880322dcea85b3b6)
This commit is contained in:
parent
5536c0bbd9
commit
5948ab207a
18
game/game.js
18
game/game.js
|
@ -38483,18 +38483,14 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addPlayer:function(position,character,character2){
|
addPlayer:(position,character,character2)=>{
|
||||||
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;
|
});
|
||||||
}
|
const player=ui.create.player(ui.arena).animate('start');
|
||||||
}
|
|
||||||
var player=ui.create.player(ui.arena).animate('start');
|
|
||||||
if(character) player.init(character,character2);
|
if(character) player.init(character,character2);
|
||||||
game.players.push(player);
|
game.players.push(player);
|
||||||
player.dataset.position=position;
|
player.dataset.position=position;
|
||||||
|
|
Loading…
Reference in New Issue