-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.js
47 lines (39 loc) · 1.46 KB
/
status.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
/*
This class is used to display room statuses every x ticks
*/
var status = {
run:function(){
var message ="";
var header = "STATUS REPORT\n";
//report on bucket level
message += "BUCKET LEVEL: " +Game.cpu.bucket+"\n";
message += header;
for (let room_name in Game.rooms){
message+=this.roomStatus(Game.rooms[room_name]);
}
console.log(message);
},
roomStatus : function(room){
if(room.name=== undefined){
return ""; // this is for when im simulating
}
if (room.controller === undefined ){
return "";
}
if (!room.controller.my){
return "";
}
var roomMessage="-----------------\n";
roomMessage += '<font color="cyan">Room: ' +room.name +'</font>\n';
roomMessage += "Controller Level: " +room.controller.level +"\n";
roomMessage += '<font color="yellow">Energy: ' +room.energyAvailable +"/"+ room.energyCapacityAvailable +'</font>\n';
var storage= room.find(FIND_STRUCTURES,{filter: (s)=> s.structureType==STRUCTURE_STORAGE});
if (storage.length){
roomMessage += '<font color="yellow">Storage energy: ' + storage[0].store[RESOURCE_ENERGY] +"\n";
}
var numCreeps = _.sum(Game.creeps, (c) => c.memory.home == room.name );
roomMessage += "Creeps: " +numCreeps +"\n";
return roomMessage;
}
};
module.exports= status;