-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreep.getRepositories.js
More file actions
33 lines (31 loc) · 1.05 KB
/
Creep.getRepositories.js
File metadata and controls
33 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var CreepGetRepositories = function(blacklist) {
if(!blacklist) {
blacklist = [];
}
var foundStructures = this.room.memory.found.structures;
var inRangeStructures = this.pos.findInRange(foundStructures, 1);
var viableRepositories = [
STRUCTURE_SPAWN,
STRUCTURE_EXTENSION,
STRUCTURE_LINK,
STRUCTURE_STORAGE,
STRUCTURE_TOWER,
STRUCTURE_CONTAINER
];
var repositories = _.filter(inRangeStructures, function(structure) {
var type = structure.structureType
var amount;
if(blacklist.indexOf(type) === -1) {
if(viableRepositories.indexOf(type) > -1) {
if(type === STRUCTURE_STORAGE || type === STRUCTURE_CONTAINER) {
amount = structure.storeCapacity - structure.store.energy;
} else {
amount = structure.energyCapacity - structure.energy;
}
return amount > 0;
}
}
});
return repositories;
};
module.exports = CreepGetRepositories