-
Notifications
You must be signed in to change notification settings - Fork 62
/
main.js
35 lines (31 loc) · 962 Bytes
/
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
// import modules
require('prototype.creep');
require('prototype.tower');
require('prototype.spawn');
module.exports.loop = function() {
// check for memory entries of died creeps by iterating over Memory.creeps
for (let name in Memory.creeps) {
// and checking if the creep is still alive
if (Game.creeps[name] == undefined) {
// if not, delete the memory entry
delete Memory.creeps[name];
}
}
// for each creeps
for (let name in Game.creeps) {
// run creep logic
Game.creeps[name].runRole();
}
// find all towers
var towers = _.filter(Game.structures, s => s.structureType == STRUCTURE_TOWER);
// for each tower
for (let tower of towers) {
// run tower logic
tower.defend();
}
// for each spawn
for (let spawnName in Game.spawns) {
// run spawn logic
Game.spawns[spawnName].spawnCreepsIfNecessary();
}
};