-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.memory.js
More file actions
84 lines (69 loc) · 2.24 KB
/
controller.memory.js
File metadata and controls
84 lines (69 loc) · 2.24 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var memoryController = {
/** @param {Room} room */
run: function(room) {
// init room memory
if(!room.memory) {
console.log('No Memory');
}
// Creeps Setup
if(room.memory.census == undefined) {
room.memory.census = {};
}
if(room.memory.census.harvest == undefined) {
room.memory.census.harvest = 2;
}
if(room.memory.census.upgrade == undefined) {
room.memory.census.upgrade = 2;
}
if(room.memory.census.build == undefined) {
room.memory.census.build = 1;
}
if(room.memory.census.repair == undefined) {
room.memory.census.repair = 0;
}
if(room.memory.census.mine == undefined) {
room.memory.census.mine = 0;
}
if(room.memory.census.transport == undefined) {
room.memory.census.transport = 0;
}
if(room.memory.census.wall == undefined) {
room.memory.census.wall = 0;
}
// if(room.memory.census.claim == undefined) {
// room.memory.census.claim = 1;
// }
// Config Setup
if(room.memory.config == undefined) {
room.memory.config = {};
}
if(room.memory.config.storage == undefined) {
room.memory.config.storage = 'none';
}
if(room.memory.config.wallTargetSize == undefined) {
room.memory.config.wallTargetSize = 0.0001;
}
// Check for storage type
checkStorage(room);
}
};
// Check to see if we are direct, containers, or storage
function checkStorage(room) {
let storage = room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_STORAGE)}})
if(storage.length) {
console.log(storage);
room.memory.config.storage = 'storage'
return;
}
let containers = room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_CONTAINER)}})
if(containers.length) {
room.memory.config.storage = 'container'
return;
}
room.memory.config.storage = 'none';
}
module.exports = memoryController;