-
Notifications
You must be signed in to change notification settings - Fork 0
/
director.js
46 lines (41 loc) · 1.37 KB
/
director.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
/**
* The director configures the architect, general and manager and runs them.
*/
var director = {
/**
* Orchestrate the system.
*/
orchestrate: function (manager, general, architect) {
var ticksHour = Math.floor((Game.time) % 10000);
if (ticksHour % 1000 >= 0 && ticksHour % 1000 < 500) {
architect.setMode('study');
} else {
architect.setMode('plan');
}
for (let roomName in Game.rooms) {
var targets = Game.rooms[roomName].find(FIND_HOSTILE_CREEPS);
architect.plan(roomName); // study, plan, rest
// general
general.setMode('rest');
general.command(roomName); // defend, attack, rest
/*
if (false) {
try {
if (roomName == 'E68N51') {
//problem! this gets wrong with also attack mode
general.attackRoom(roomName, 'E66N51');
}
} catch (error) {
console.log('Error: ' + error);
Game.notify('Error: ' + error);
}
} else {
}
*/
// manager
manager.setMode('default');
manager.manage(roomName); // default, upgrade, build, repair
}
}
};
module.exports = director;