-
Notifications
You must be signed in to change notification settings - Fork 1
/
growth.js
36 lines (34 loc) · 1.36 KB
/
growth.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
var growthManager = {
checkGrowth: function () {
let spawn = Game.spawns['Spawn1'];
// Energy buildings
let excessEnergy = true;
let energyBuildings = spawn.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType === STRUCTURE_EXTENSION || structure.structureType === STRUCTURE_SPAWN) &&
structure.store.getFreeCapacity(RESOURCE_ENERGY) > 0;
}
});
if (energyBuildings.length > 0) {
excessEnergy = false;
}
// Growth
if (excessEnergy) {
let pUpgrader = spawn.memory.pUpgrader;
let pBuilder = spawn.memory.pBuilder;
let pHarvester = spawn.memory.pHarvester;
let lPU = spawn.memory.lastPopulationUpdate;
// Creep count
if ((pUpgrader < pBuilder - 3) && Game.time - lPU > 50) {
spawn.memory.pUpgrader = pUpgrader + 1;
spawn.memory.lastPopulationUpdate = Game.time;
console.log('Upgrader population increased.');
} else if (pBuilder < 7){
spawn.memory.pBuilder = pBuilder + 1;
spawn.memory.lastPopulationUpdate = Game.time;
console.log('Builder population increased.');
}
}
}
};
module.exports = growthManager;