-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole.builder.js
47 lines (41 loc) · 1.2 KB
/
role.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var action = require('action.creep');
var utilsRoom = require('utils.room');
var roleBuilder = {
/** @param {Creep} creep **/
run: function(creep) {
var debug = false;
//if(creep.name == 'Michael')
//debug = true;
if(creep.memory.building && creep.carry.energy == 0) {
creep.memory.building = false;
}
if(!creep.memory.building && action.isCarryFull(creep)) {
creep.memory.building = true;
}
if(!creep.memory.renewing)
action.doNeedRenew(creep);
if(action.isCarryingOtherResource(creep)){
action.doTransferToStorage(creep);
}
else if (creep.memory.renewing){
action.doRenew(creep);
}
else if(action.isDanger(creep)){
action.doAvoid(creep);
}
else if(creep.memory.building) {
action.doBuild(creep);
}
else {
/*if(creep.room == utilsRoom.getMotherRoom()){
var result = action.doGetEnergyFromStorage(creep);
console.log(result)
if(result==ERR_NOT_ENOUGH_RESOURCES)
action.doHarvest(creep);
}
else*/
action.doHarvest(creep);
}
}
};
module.exports = roleBuilder;