fixed wrong vacancy generation bug.

This commit is contained in:
Douwe Ravers
2023-08-26 21:31:29 +02:00
parent e294ad29fe
commit 91448edc0a
3 changed files with 12 additions and 6 deletions

View File

@@ -29,11 +29,16 @@ function jobScan(room){
function vacancyScan(room){
const activeJobs = room.find(FIND_MY_CREEPS).map(creep=>creep.memory.job);
const jobs = [].concat(room.memory.jobs);
activeJobs.forEach(job => {
const index = jobs.indexOf(job);
if(0 <= index) jobs.splice(index,1);
console.log(activeJobs.toString());
console.log(room.memory.jobs.toString());
const jobs = room.memory.jobs.filter((j)=>{
const index = activeJobs.findIndex(aj=> _.isEqual(aj,j));
if(index < 0) return true;
activeJobs.splice(index,1);
return false;
});
console.log(jobs.toString());
room.memory.vacancies = jobs;
}