2016-09-15 00:30:24 -05:00
|
|
|
var roleMiner2 = {
|
2016-09-23 00:12:42 -05:00
|
|
|
run: function(creep) {
|
2016-09-15 00:30:24 -05:00
|
|
|
var sources = creep.room.find(FIND_SOURCES);
|
|
|
|
if(creep.harvest(sources[1]) == ERR_NOT_IN_RANGE) {
|
|
|
|
creep.moveTo(sources[1]);
|
2016-09-23 00:12:42 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
spawn: function(roomname){
|
|
|
|
var myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
|
|
|
|
var myroom = Game.rooms[roomname]
|
|
|
|
for(var thisspawn in myspawns){
|
|
|
|
var spawn = myspawns[thisspawn]
|
|
|
|
var myrole='miner2';
|
|
|
|
var myroles = _.filter(Game.rooms[roomname].find(FIND_MY_CREEPS), (creep) => creep.memory.role == myrole);
|
|
|
|
console.log(myrole + 's: ' + myroles.length + ' Needed: ' + Game.rooms[roomname].memory['max'+myrole+'s']);
|
|
|
|
if(myroles.length < Game.rooms[roomname].memory['max'+myrole+'s']) {
|
|
|
|
var newName = spawn.createCreep([WORK,WORK,WORK,WORK,WORK,MOVE], undefined, {role: myrole});
|
|
|
|
console.log('Spawning new ' + myrole + ': ' + newName);
|
|
|
|
}
|
2016-09-15 00:30:24 -05:00
|
|
|
}
|
2016-09-23 00:12:42 -05:00
|
|
|
}
|
2016-09-15 00:30:24 -05:00
|
|
|
};
|
|
|
|
module.exports = roleMiner2;
|