-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagement.js
42 lines (37 loc) · 1.37 KB
/
management.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var constants = require('./constants');
var management = {
/** @description Cleaning creep memories */
cleanmemories: function() {
for(var name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name);
}
}
},
showSpawningMessage: function() {
if(Game.spawns[constants.SPAWN1_NAME].spawning) {
var spawningCreep = Game.creeps[Game.spawns[constants.SPAWN1_NAME].spawning.name];
Game.spawns[constants.SPAWN1_NAME].room.visual.text(
'Building... ' + spawningCreep.memory.role,
Game.spawns[constants.SPAWN1_NAME].pos.x + 1,
Game.spawns[constants.SPAWN1_NAME].pos.y,
{align: 'left', opacity: 0.8});
}
},
executeCreepProcess: function() {
for(var name in Game.creeps) {
var creep = Game.creeps[name];
if(creep.memory.role == constants.ROLE_HARVESTER) {
roleHarvester.run(creep);
}
if(creep.memory.role == constants.ROLE_UPGRADER) {
roleUpgrader.run(creep);
}
if(creep.memory.role == constants.ROLE_BUILDER) {
roleBuilder.run(creep);
}
}
}
};
module.exports = management;