more builders, and do some scoping stuff
This commit is contained in:
parent
0ada42efb3
commit
b4be39510a
2
main.js
2
main.js
@ -13,7 +13,7 @@ var creepsConfig = {
|
||||
},
|
||||
builder: {
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 1,
|
||||
minimumCreeps: 2,
|
||||
role: roleBuilder
|
||||
},
|
||||
upgrader: {
|
||||
|
@ -8,10 +8,14 @@ var roleGuard = {
|
||||
let flagNumbers = _.map(patrolFlags, function(flag){
|
||||
return parseInt(flag.name.substring("patrol_".length, flag.name.length));
|
||||
});
|
||||
let max = Math.max.apply(Math, flagNumbers);
|
||||
return max;
|
||||
return Math.max.apply(Math, flagNumbers);
|
||||
},
|
||||
getDestinationFlag: function(){
|
||||
return Game.flags['patrol_' + this.creep.memory.patrolDestination];
|
||||
},
|
||||
run: function(creep){
|
||||
this.creep = creep;
|
||||
|
||||
console.log(creep, 'running Guard')
|
||||
// Reset creep to 1
|
||||
creep.memory.patrolDestination = creep.memory.patrolDestination || 1;
|
||||
@ -22,18 +26,15 @@ var roleGuard = {
|
||||
creep.moveTo(target);
|
||||
creep.attack(target);
|
||||
} else {
|
||||
var destinationFlag = Game.flags['patrol_' + creep.memory.patrolDestination];
|
||||
|
||||
if (creep.pos.isEqualTo(destinationFlag)){
|
||||
if (creep.pos.isEqualTo(this.getDestinationFlag())){
|
||||
creep.memory.patrolDestination += 1;
|
||||
}
|
||||
|
||||
if (creep.memory.patrolDestination > this.getLastFlag()){
|
||||
creep.memory.patrolDestination = 1;
|
||||
}
|
||||
destinationFlag = Game.flags['patrol_' + creep.memory.patrolDestination];
|
||||
console.log('\tMoving to Patrol leg:', creep.memory.patrolDestination);
|
||||
creep.moveTo(destinationFlag);
|
||||
creep.moveTo(this.getDestinationFlag());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user