redo some naming

This commit is contained in:
Tyrel Souza 2016-06-28 17:17:03 -04:00
parent 9882dc75e1
commit a2ea1a4d1f

13
main.js
View File

@ -6,19 +6,20 @@ var creepsConfig = {
harvester: {
bodyParts: [WORK, CARRY, MOVE],
minimumCreeps: 4,
run: roleHarvester.run
role: roleHarvester
},
builder: {
bodyParts: [WORK, CARRY, MOVE],
minimumCreeps: 2,
run: roleBuilder.run
role: roleBuilder
},
upgrader: {
bodyParts: [WORK, CARRY, MOVE],
minimumCreeps: 2,
run: roleUpgrader.run
role: roleUpgrader
}
}
module.exports.loop = function(){
// Cleanup Creeps
for (var name in Memory.creeps){
@ -32,7 +33,9 @@ module.exports.loop = function(){
for (var roleName in creepsConfig){
var creepsOfKind = _.filter(Game.creeps, (creep) => creep.memory.role == roleName);
if (creepsOfKind.length < creepsConfig[roleName].minimumCreeps){
var newName = Game.spawns.Spawn1.createCreep(creepsConfig[roleName].bodyParts, undefined, {role: roleName});
var newName = Game.spawns.Spawn1.createCreep(creepsConfig[roleName].bodyParts,
undefined,
{role: roleName});
console.log("Spawning new ", roleName, ": ", newName);
}
};
@ -41,6 +44,6 @@ module.exports.loop = function(){
for (var name in Game.creeps){
var creep = Game.creeps[name];
var role = creep.memory.role;
creepsConfig[role].run(creep);
creepsConfig[role].role.run(creep);
}
}