diff --git a/Commands.js b/Commands.js index 7ea600d..0b5a22c 100644 --- a/Commands.js +++ b/Commands.js @@ -49,7 +49,7 @@ function buildRoads(){ sId => { const source = Game.getObjectById(sId); var roads = []; - roads = roads.concat(source.pos.findPathTo(this.controller)); + roads = roads.concat(source.pos.findPathTo(room.controller)); roads.pop(); roads = roads.concat(source.pos.findPathTo(room.find(FIND_MY_STRUCTURES, { filter:{ structureType:STRUCTURE_SPAWN }})[0])); roads.pop(); diff --git a/RoomClass.js b/RoomClass.js index 2ff017b..b7766d5 100644 --- a/RoomClass.js +++ b/RoomClass.js @@ -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; } diff --git a/StructureSpawnClass.js b/StructureSpawnClass.js index 99bd4e9..f1976b0 100644 --- a/StructureSpawnClass.js +++ b/StructureSpawnClass.js @@ -9,7 +9,8 @@ class _StructureSpawn extends StructureSpawn { } tick(){ - if(!this.memory.init) this.begin(); + if(!this.memory.init) this.begin(); + if(this.store.getUsedCapacity(RESOURCE_ENERGY) < 300) return; const job = this.room.memory.vacancies.pop(); if(job){ const name = getJobName(job.role);