// Build structures
var structs = curRoom.find(FIND_CONSTRUCTION_SITES, {
filter: (structure) => {
return
_.filter(Memory.jobs.worker.normal,
(job) => {
return job.id == structure.id;
}).length == 0 // Test if this structure is already in the queue
&& _.filter(Game.creeps,
(creep) => {
return creep.memory.curJob != undefined && creep.memory.curJob.id == structure.id;
}).length == 0; // Test if a creep is already working on this structure
}
});
上面的代码返回 0 个建筑工地(应该通过测试的 40 个),但每个建筑工地都通过了(外部)过滤器。
我还测试了内部过滤器(使用.length == 0
):
console.log(<filter1>); // true
console.log(<filter2>); // true
console.log(<filter1>, <filter2>) // true true
console.log(<filter1> && <filter2>
有什么我遗漏的或者我做错了什么吗?