-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
40 lines (32 loc) · 1.05 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
var spawnerCode = require("spawner")
var roleHarvester = require("role.harvester");
var roleUpgrader = require("role.upgrader");
var roleBuilder = require("role.builder")
var roleRepairer = require("role.repairer")
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);
}
}
for (var name in Game.spawns) {
var spawnername = Game.spawns[name]
spawnerCode.run(spawnername)
}
for(var name in Game.creeps) {
var creep = Game.creeps[name];
if(creep.memory.role == "harvester") {
roleHarvester.run(creep);
}
if(creep.memory.role == "upgrader") {
roleUpgrader.run(creep);
}
if (creep.memory.role == "builder") {
roleBuilder.run(creep)
}
if (creep.memory.role == "repairer") {
roleRepairer.run(creep)
}
}
}