From b7ebba8f53910fd0efa48b982940486a5fe78317 Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Thu, 24 Aug 2023 07:58:13 -0700 Subject: [PATCH] Optimize game.removePlayer. (cherry picked from commit 662380e02d1e72d0867d07b0318b08b1e8066661) --- game/game.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/game/game.js b/game/game.js index dfb3d8a18..5b398fb23 100644 --- a/game/game.js +++ b/game/game.js @@ -38538,20 +38538,16 @@ game.arrangePlayers(); return player; }, - removePlayer:function(player){ - if(_status.roundStart==player){ - _status.roundStart=player.next||player.getNext()||game.players[0]; - } - var players=game.players.concat(game.dead); - player.style.left=player.getLeft()+'px'; - player.style.top=player.getTop()+'px'; + removePlayer:player=>{ + if(_status.roundStart==player) _status.roundStart=player.next||player.getNext()||game.players[0]; + const players=game.players.concat(game.dead); + player.style.left=`${player.getLeft()}px`; + player.style.top=`${player.getTop()}px`; if(player==undefined) player=game.dead[0]||game.me.next; - var position=parseInt(player.dataset.position); - for(var i=0;iposition){ - players[i].dataset.position=parseInt(players[i].dataset.position)-1; - } - } + const position=parseInt(player.dataset.position); + players.forEach(value=>{ + if(parseInt(value.dataset.position)>position) value.dataset.position=parseInt(value.dataset.position)-1; + }); if(player.isAlive()){ player.next.previous=player.previous; player.previous.next=player.next; @@ -38568,9 +38564,7 @@ ui.auto.hide(); ui.wuxie.hide(); } - setTimeout(function(){ - player.removeAttribute('style'); - },500); + setTimeout(()=>player.removeAttribute('style'),500); return player; }, replacePlayer:(player,character,character2)=>{