-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.claim.js
46 lines (32 loc) · 1.09 KB
/
role.claim.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var roleclaim = {
//var testvar = "test";
/** @param {Creep} creep **/
run: function(creep) {
creep.memory.building = true;
if(creep.memory.building) {
// Check to make sure we are in the correct room first
if (creep.room.name == creep.memory.remote) {
//console.log("in right room");
//console.log(creep.claimController(creep.room.controller));
if(creep.claimController(creep.room.controller) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.controller);
// console.log("moving to controller");
} //else {
// creep.moveTo(creep.room.controller);
//}
} else {
var exit = creep.room.findExitTo(creep.memory.remote);
creep.moveTo(creep.pos.findClosestByRange(exit));
}
}
},
workToDo: function(creep)
{
var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
if(targets.length)
return true;
else
return false;
}
};
module.exports = roleclaim;