Optimize game.countPlayer.
(cherry picked from commit df9c74b86040e6e576b643e8f094cec99372b397)
This commit is contained in:
parent
ed19d18f75
commit
674f45e8b8
25
game/game.js
25
game/game.js
|
@ -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&¤tValue.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;
|
||||||
|
|
Loading…
Reference in New Issue