Optimize game.countPlayer.

(cherry picked from commit df9c74b86040e6e576b643e8f094cec99372b397)
This commit is contained in:
Tipx-L 2023-08-24 06:45:37 -07:00
parent ed19d18f75
commit 674f45e8b8
1 changed files with 9 additions and 16 deletions

View File

@ -38739,22 +38739,15 @@
} }
return false; return false;
}, },
countPlayer:function(func,includeOut){ countPlayer:(func,includeOut)=>{
var num=0; if(typeof func!='function') func=lib.filter.all;
if(typeof func!='function'){ return game.players.reduce((previousValue,currentValue)=>{
func=lib.filter.all; if(!includeOut&&currentValue.isOut()) return previousValue;
} const result=func(currentValue);
for(var i=0;i<game.players.length;i++){ if(typeof result=='number') previousValue+=result;
if(!includeOut&&game.players[i].isOut()) continue; else if(result) previousValue++;
var result=func(game.players[i]); return previousValue;
if(typeof result=='number'){ },0);
num+=result;
}
else if(result){
num++;
}
}
return num;
}, },
countPlayer2:(func,includeOut)=>{ countPlayer2:(func,includeOut)=>{
if(typeof func!='function') func=lib.filter.all; if(typeof func!='function') func=lib.filter.all;