-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole.harvester.js
29 lines (26 loc) · 1.04 KB
/
role.harvester.js
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
var roleFunctions = require('roleFunctions');
var roleHarvester = {
/** @param {Creep} creep **/
run: function(creep) {
var haulers = _.filter(Game.creeps, (hauler) => hauler.memory.role == 'hauler' && hauler.memory.source == creep.memory.source);
if(creep.store.getFreeCapacity() != 0) {
if (creep.pos.isEqualTo(35, 45)) {
creep.move(TOP_LEFT);
}
creep.goHarvest();
//console.log(creep.name);
}
else if (haulers.length == 0) {
console.log(creep.name);
if (!creep.depositResources()) {
var creepSource = creep.room.find(FIND_SOURCES)[creep.memory.source];
creep.moveTo(creepSource, {visualizePathStyle: {stroke: '#ffaa00'}});
}
}
else {
var creepSource = creep.room.find(FIND_SOURCES)[creep.memory.source];
creep.moveTo(creepSource, {visualizePathStyle: {stroke: '#ffaa00'}});
}
}
};
module.exports = roleHarvester;