Optimize game.findPlayer.
(cherry picked from commit 9819bceb12a930c4be2f4a189def95ba0f0568ce)
This commit is contained in:
parent
762ea0dc6c
commit
d0e1063a9b
10
game/game.js
10
game/game.js
|
@ -38784,15 +38784,7 @@
|
|||
if(typeof func!='function') func=lib.filter.all;
|
||||
return list.addArray(game.players.concat(game.dead).filter(value=>(includeOut||!value.isOut())&&func(value)));
|
||||
},
|
||||
findPlayer:function(func,includeOut){
|
||||
for(var i=0;i<game.players.length;i++){
|
||||
if(!includeOut&&game.players[i].isOut()) continue;
|
||||
if(func(game.players[i])){
|
||||
return game.players[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
findPlayer:(func,includeOut)=>game.players.find(value=>(includeOut||!value.isOut())&&func(value))||null,
|
||||
findPlayer2:(func,includeOut)=>game.players.concat(game.dead).find(value=>(includeOut||!value.isOut())&&func(value))||null,
|
||||
findCards:(func,all)=>Object.keys(lib.card).filter(value=>{
|
||||
if(!lib.translate[`${value}_info`]) return false;
|
||||
|
|
Loading…
Reference in New Issue