SetupOverlord now builds a harvester (WIP)

SetupOverlord now builds a harvester if possible with the given spawns.
main
Peery 2 years ago
parent c211e84801
commit cbc99ae65b

@ -33,10 +33,14 @@ var roleHarvester = {
/** /**
* Runs the logic and actions of the harvester * Runs the logic and actions of the harvester
* @param {string} creep_name * @param {Creep} creep
*/ */
run: function(creep_name) { run: function(creep) {
console.log("roleHarvester: run() " + creep_name) console.log("roleHarvester: run() " + creep);
let sources = creep.room.find(FIND_SOURCES_ACTIVE);
for (let source in sources) {
console.log("Found source ", source.name);
}
}, },
}; };

@ -98,7 +98,9 @@ var hivemind = {
let creep = Game.creeps[name]; let creep = Game.creeps[name];
let creep_role = creep.memory.role let creep_role = creep.memory.role
console.log("Hivemind: Running creep \""+name+"|"+creep_role+"\""); console.log("Hivemind: Running creep \""+name+"|"+creep_role+"\"");
// TODO run creep's role let role = _.filter(roles, function(node) {return node.ident === creep_role})[0];
role.obj.run(creep);
} }
}, },
}; };

@ -24,7 +24,7 @@ setup_overlord.prototype.run = function () { // TODO somehow these aren't chang
let spawn = Game.spawns[this.underlings['spawns']]; let spawn = Game.spawns[this.underlings['spawns']];
if (spawn.store[RESOURCE_ENERGY] > harvester.min_cost) { // can afford a harvester if (spawn.store[RESOURCE_ENERGY] > harvester.min_cost) { // can afford a harvester
console.log("SetupOverlord: Spawn "+spawn.name+" can afford a harvester! ("+harvester.min_cost+") \\o/"); console.log("SetupOverlord: Spawn "+spawn.name+" can afford a harvester! ("+harvester.min_cost+") \\o/");
let new_harvester_name = harvester.spawn(spawn, this.id+"-0", this.id); let new_harvester_name = harvester.spawn(spawn, this.id+"-"+this.underlings['creeps'].length, this.id);
this.add_creep(new_harvester_name); this.add_creep(new_harvester_name);
break; break;
} }

Loading…
Cancel
Save