TsarBot/util_progress.js

22 lines
630 B
JavaScript

var progressUtils = {
checkProgress : function() {
for(var roomName in Game.rooms){
const room = Game.rooms[roomName];
const structures = room.find(FIND_MY_STRUCTURES);
room.memory.hasContainer = false;
room.memory.hasSpawn = false;
room.memory.extensions = 0;
structures.forEach(function (structure){
if(structure.structureType == STRUCTURE_CONTAINER) room.memory.hasContainer = true;
if(structure.structureType == STRUCTURE_SPAWN) room.memory.hasSpawn = true;
if(structure.structureType == STRUCTURE_EXTENSION) room.memory.extensions++;
});
}
}
}
module.exports = progressUtils;