Added basic creep behaviour execution based on assigned role.
This commit is contained in:
parent
cae7ac03fb
commit
d1e49ce9fc
@ -13,6 +13,10 @@ var creepBuilds = {
|
||||
|
||||
return buildsDict;
|
||||
},
|
||||
|
||||
getRoleObject: function(roleStr) {
|
||||
return require("./roles_" + roleStr);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = creepBuilds;
|
||||
|
@ -13,6 +13,7 @@ var creepGoalAmount = settings.getCreepGoalAmount();
|
||||
var creepManager = {
|
||||
|
||||
run: function() {
|
||||
//spawn desired creeps
|
||||
if (spawnCreeps) {
|
||||
for (let role in creepGoalAmount) {
|
||||
let roleCreepsAmount = (_.filter(Game.creeps, (creep) => creep.memory.role == role)).length;
|
||||
@ -21,6 +22,14 @@ var creepManager = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//run creeps by role
|
||||
for (let creep in Game.creeps) {
|
||||
let creepName = Game.creeps[creep];
|
||||
let role = creepName.memory.role;
|
||||
let roleObject = creepBuilds.getRoleObject(role);
|
||||
roleObject.run(creepName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* mod.thing == 'a thing'; // true
|
||||
*/
|
||||
|
||||
var roleBuilder = {
|
||||
var creep = {
|
||||
|
||||
/** @param {Creep} creep **/
|
||||
run: function(creep) {
|
||||
@ -38,4 +38,4 @@ var roleBuilder = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = roleBuilder;
|
||||
module.exports = creep;
|
||||
|
@ -1,11 +1,14 @@
|
||||
var roleHarvester = {
|
||||
var settings = require("./settings");
|
||||
var colorScheme = settings.getColorScheme();
|
||||
|
||||
var creep = {
|
||||
|
||||
/** @param {Creep} creep **/
|
||||
run: function(creep) {
|
||||
if(creep.store.getFreeCapacity() > 0) {
|
||||
var sources = creep.room.find(FIND_SOURCES);
|
||||
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
|
||||
creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}});
|
||||
creep.moveTo(sources[0], {visualizePathStyle: {stroke: colorScheme["primary"]}});
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -24,4 +27,4 @@ var roleHarvester = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = roleHarvester;
|
||||
module.exports = creep;
|
||||
|
@ -11,7 +11,16 @@ var settings = {
|
||||
|
||||
getSpawnCreeps: function() {
|
||||
return true
|
||||
}
|
||||
},
|
||||
|
||||
getColorScheme: function() {
|
||||
let colors = {
|
||||
primary: "#7b9ce6",
|
||||
secondary: "f6e6bd",
|
||||
tertiary: "cc2222",
|
||||
};
|
||||
return colors;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = settings;
|
||||
|
Loading…
Reference in New Issue
Block a user