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: {
|
builder: {
|
||||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||||
minimumCreeps: 1,
|
minimumCreeps: 2,
|
||||||
role: roleBuilder
|
role: roleBuilder
|
||||||
},
|
},
|
||||||
upgrader: {
|
upgrader: {
|
||||||
|
@ -8,10 +8,14 @@ var roleGuard = {
|
|||||||
let flagNumbers = _.map(patrolFlags, function(flag){
|
let flagNumbers = _.map(patrolFlags, function(flag){
|
||||||
return parseInt(flag.name.substring("patrol_".length, flag.name.length));
|
return parseInt(flag.name.substring("patrol_".length, flag.name.length));
|
||||||
});
|
});
|
||||||
let max = Math.max.apply(Math, flagNumbers);
|
return Math.max.apply(Math, flagNumbers);
|
||||||
return max;
|
},
|
||||||
|
getDestinationFlag: function(){
|
||||||
|
return Game.flags['patrol_' + this.creep.memory.patrolDestination];
|
||||||
},
|
},
|
||||||
run: function(creep){
|
run: function(creep){
|
||||||
|
this.creep = creep;
|
||||||
|
|
||||||
console.log(creep, 'running Guard')
|
console.log(creep, 'running Guard')
|
||||||
// Reset creep to 1
|
// Reset creep to 1
|
||||||
creep.memory.patrolDestination = creep.memory.patrolDestination || 1;
|
creep.memory.patrolDestination = creep.memory.patrolDestination || 1;
|
||||||
@ -22,18 +26,15 @@ var roleGuard = {
|
|||||||
creep.moveTo(target);
|
creep.moveTo(target);
|
||||||
creep.attack(target);
|
creep.attack(target);
|
||||||
} else {
|
} else {
|
||||||
var destinationFlag = Game.flags['patrol_' + creep.memory.patrolDestination];
|
if (creep.pos.isEqualTo(this.getDestinationFlag())){
|
||||||
|
|
||||||
if (creep.pos.isEqualTo(destinationFlag)){
|
|
||||||
creep.memory.patrolDestination += 1;
|
creep.memory.patrolDestination += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (creep.memory.patrolDestination > this.getLastFlag()){
|
if (creep.memory.patrolDestination > this.getLastFlag()){
|
||||||
creep.memory.patrolDestination = 1;
|
creep.memory.patrolDestination = 1;
|
||||||
}
|
}
|
||||||
destinationFlag = Game.flags['patrol_' + creep.memory.patrolDestination];
|
|
||||||
console.log('\tMoving to Patrol leg:', 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