-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
52 lines (46 loc) · 1.41 KB
/
main.ts
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
import './defines';
import structure_spawn from './structure.spawn';
import structure_controller from './structure.controller';
import role_harvester from './role.harvester';
import role_upgrader from './role.upgrader';
import role_builder from './role.builder';
for(const spawnName in Game.spawns) {
let spawn = Game.spawns[spawnName];
structure_spawn.updateSources(spawn);
}
module.exports.loop = function() {
for(let name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name);
}
}
for(let name in Memory.rooms) {
if(!Game.rooms[name].controller.my) {
delete Memory.rooms[name];
console.log('Clearing unowned room memory:', name);
}
}
for(const spawnName in Game.spawns) {
let spawn = Game.spawns[spawnName];
structure_spawn.run(spawn);
if(Game.time % 10 == 0) {
structure_spawn.updateSources(spawn);
if(spawn.room.controller.level >= 2) {
structure_spawn.createStructures(spawn);
structure_controller.buildExtensions(spawn.room.controller);
structure_controller.createContainers(spawn.room.controller);
}
}
}
for(let name in Game.creeps) {
let creep = Game.creeps[name];
if(creep.memory.role == 'harvester') {
role_harvester.run(creep);
} else if(creep.memory.role == 'upgrader') {
role_upgrader.run(creep);
} else if(creep.memory.role == 'builder') {
role_builder.run(creep);
}
}
};