-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.20ticks.js
47 lines (40 loc) · 1.81 KB
/
timer.20ticks.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
var roleEmergencyRepairer = require('role.emergencyRepairer');
var alerts = require('alerts');
var timer20Ticks = {
run: function()
{
// Initialize if it has never been setup before
if (Memory.twentyTicks == undefined)
Memory.twentyTicks = 0;
if (Memory.twentyTicks <= Game.time)
{
Memory.twentyTicks = Game.time + 20;
// everythng that follows gets executed
//Emergency Mode Check
for(var room_it in Game.rooms) {
var room = Game.rooms[room_it];
//console.log("==== " + room.name + " ====");
var goToEmergencyRepairMode = roleEmergencyRepairer.amINeeded(room.name);
if (goToEmergencyRepairMode) {
if (room.memory.emergencyRepairMode == 999 || room.memory.emergencyRepairMode == undefined) {
room.memory.emergencyRepairMode = 10;
alerts.newAlert(1, "(SL) Room " + room.name + " Entered into Emergency Repair Mode");
}
//Memory.emergencyRepairMode = 10;
} else {
if (room.memory.emergencyRepairMode != 999) {
var amIStillNeeded = roleEmergencyRepairer.amIStillNeeded(room.name);
//console.log("Am I Still Needed in room "+ room.name + ": " + amIStillNeeded);
if (!amIStillNeeded) {
room.memory.emergencyRepairMode = 999;
alerts.newAlert(1, "(SL) Room " + room.name + " Exited from Emergency Repair Mode");
}
}
}
//console.log("Start Emergency Repair Mode in room " + room.name + ": " + goToEmergencyRepairMode);
//console.log("Current running emergency repair mode in room " + room.name + ": " + room.memory.emergencyRepairMode);
}
}
}
};
module.exports = timer20Ticks;