-
Notifications
You must be signed in to change notification settings - Fork 2
/
builder.js
31 lines (29 loc) · 926 Bytes
/
builder.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
var util = require('util');
module.exports = function (mon, creep) {
creep.memory.state = creep.memory.state || 'build';
if (creep.memory.state == 'build') {
if (creep.carry.energy == 0) {
creep.say('Gather');
creep.memory.state = 'gather';
}
else {
var targets = mon.findConstructionSites(creep.room);
if (creep.room.controller.level < 2) {
creep.moveTo(creep.room.controller);
creep.upgradeController(creep.room.controller);
}
else if(targets.length) {
creep.moveTo(targets[0]);
creep.build(targets[0]);
}
// might as well do something
else {
creep.moveTo(creep.room.controller);
creep.upgradeController(creep.room.controller);
}
}
}
else {
util.gather(mon, creep, 'build', 'Build');
}
}