-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole.claimer.js
30 lines (29 loc) · 1008 Bytes
/
role.claimer.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
let builder = require('role.builder');
let claimer = module.exports;
claimer.run = function(creep) {
let spawn1 = Game.rooms[creep.memory.home].find(FIND_MY_SPAWNS)[0];
if(creep.memory.targetRoom) {
if(creep.room.name == creep.memory.targetRoom) {
if(!creep.room.controller.my) {
let c = creep.claimController(creep.room.controller);
// console.log(creep.name + ": " + c);
if(c != OK) {
creep.moveTo(creep.room.controller);
} else {
delete creep.memory.targetRoom;
}
} else {
builder.run(creep);
}
} else {
creep.moveTo(creep.pos.findClosestByPath(creep.room.findExitTo(creep.memory.targetRoom)));
}
} else {
builder.run(creep);
}
};
claimer.base = [CLAIM,WORK,WORK,CARRY,MOVE,MOVE,MOVE,MOVE];
claimer.add = {
0: { type: [MOVE], amt: 2},
1: { type: [WORK], amt: 2}
};