-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
50 lines (38 loc) · 1.14 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
var autospawn = require('autospawn');
var generatePixels = require('generatePixels');
var tower = require('structure.tower');
var roleMap = require('rolemap');
function hasTombstones(room) {
return room.find(FIND_TOMBSTONES, {
filter: (tomb) => tomb.store.getUsedCapacity() > 0
}).length > 0;
}
module.exports.loop = function () {
for(var name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name);
}
}
generatePixels(false, true);
autospawn(2, "harvester", "Spawn1");
// /*
autospawn(4, "upgrader", "Spawn1");
autospawn(2, "builder", "Spawn1");
autospawn(1, "reloader", "Spawn1");
// */
if (hasTombstones(Game.spawns['Spawn1'].room)) {
autospawn(1, "tombraider", "Spawn1");
}
for (let rooms in Game.rooms) {
let room = Game.rooms[rooms];
tower.run(room);
}
for (const name in Game.creeps) {
const creep = Game.creeps[name];
const role = creep.memory.role;
if (roleMap[role]) {
roleMap[role].run(creep);
}
}
}