-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
52 lines (43 loc) · 1.3 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
let roleTower = require('role.tower');
let roomManager = require('roomManager');
require('prototype.creep')();
module.exports.loop = function () {
/**
* Make sure all rooms are having screep populations managed
*/
for (let name in Game.rooms)
{
roomManager.run(Game.rooms[name]);
}
/**
* Remove lingering creeps from memory store, ready to repopulate
*/
for (let name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name);
}
}
Memory.creepTypes = {};
Memory.creepTypes.harvesters = [];
Memory.creepTypes.upgraders = [];
Memory.creepTypes.repairers = [];
Memory.creepTypes.builders = [];
Memory.creepTypes.carriers = [];
Memory.creepTypes.defenders = [];
Memory.creepTypes.siegers = [];
/**
* Run roles on each creep and push creep types into appropriate memory locations for easy access through Memory tab
*/
for (let creep in Game.creeps) {
Game.creeps[creep].runRole();
}
/**
* Run Tower role on all towers
*/
let towers = _.filter(Game.structures, (s) => s.structureType == STRUCTURE_TOWER);
for (let tower of towers)
{
roleTower.run(tower);
}
};