-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscratchfile.js
51 lines (41 loc) · 1.43 KB
/
scratchfile.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
48
49
50
51
const THRESHHOLDS = {
[STRUCTURE_WALL]: 10000,
};
function towerRepairTarget(tower, range) {
const targets = tower.pos.findInRange(FIND_STRUCTURE, range, {
filter(structure) {
return !(structure.structureType in THRESHHOLDS) || structure.hits < THRESHHOLDS[structure.structureType];
},
});
if (targets) {
return _.first(_.sort(targets, (structure) => structure.hits / (THRESHHOLDS[target.structureType] || structure.hitsMax));
}
}
// bunch of useful commands here
var room = Game.rooms['E39S95'];
var creep = {roomName:'E39S95'};
var cpu = Game.cpu.getUsed();
var filtered = _.filter(Game.spawns, (s) => s.spawning && s.room.name == creep.roomName);
if (filtered.length > 0) {
console.log(JSON.stringify(filtered[0]));
}
console.log('filtered cpu ' + (Game.cpu.getUsed() - cpu).toFixed(3));
var bpu = Game.cpu.getUsed();
var found = room.find(FIND_STRUCTURES, {
filter: (i) => i.structureType == STRUCTURE_SPAWN && i.spawning
});
if (found.length > 0) {
console.log(JSON.stringify(found[0]));
}
console.log('found cpu ' + (Game.cpu.getUsed() - bpu).toFixed(3));
var CPU = Game.cpu.getUsed();
var creep = {
role:'builder',
roomName:'E39S95',
cost:1000
};
console.log(JSON.stringify(global.Queue.remove(creep)));
console.log(Game.cpu.getUsed() - CPU);
var CPU = Game.cpu.getUsed();
console.log(JSON.stringify(global.Queue.process()));
console.log(Game.cpu.getUsed() - CPU);