make builder build, not transfer

This commit is contained in:
Tyrel Souza 2016-06-28 21:52:40 -04:00
parent a629713ed5
commit 3b4cd13dad
2 changed files with 10 additions and 10 deletions

View File

@ -5,17 +5,17 @@ var roleBuilder = require('role.builder');
var creepRolePriority = ['harvester', 'builder', 'upgrader'];
var creepsConfig = {
harvester: {
bodyParts: [WORK, CARRY, MOVE],
bodyParts: [WORK, CARRY, MOVE, MOVE],
minimumCreeps: 2,
role: roleHarvester
},
builder: {
bodyParts: [WORK, CARRY, MOVE],
bodyParts: [WORK, CARRY, MOVE, MOVE],
minimumCreeps: 2,
role: roleBuilder
},
upgrader: {
bodyParts: [WORK, CARRY, MOVE],
bodyParts: [WORK, CARRY, MOVE, MOVE],
minimumCreeps: 2,
role: roleUpgrader
}

View File

@ -13,13 +13,11 @@ var roleBuilder = {
console.log("\t is building");
var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
let transerErrorCode = creep.transfer(targets[0], RESOURCE_ENERGY);
if(transerErrorCode == ERR_NOT_IN_RANGE) {
var transferErrorCode = creep.build(targets[0]);
if(transferErrorCode == ERR_NOT_IN_RANGE) {
console.log("\t moving to", targets[0]);
creep.moveTo(targets[0]);
} else if (transerErrorCode == ERR_INVALID_TARGET){
console.log("\tError, invalid Target");
}
} else {
console.log("\t","isFindingSources");
var sources = creep.room.find(FIND_SOURCES);
@ -27,6 +25,8 @@ var roleBuilder = {
creep.moveTo(sources[0]);
}
}
}
}
};
module.exports = roleBuilder;