-
Notifications
You must be signed in to change notification settings - Fork 0
/
spawn.js
46 lines (39 loc) · 1.29 KB
/
spawn.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
const {
countRole: countRoleF,
createBalancedCreep,
clearMemory,
logRoles
} = require('./spawnUtils')
const MIN_NUMBER_OF_HARVERSTERS = 6
const MIN_NUMBER_OF_UPGRADERS = 2
const MIN_NUMBER_OF_BUILDERS = 10
const MIN_NUMBER_OF_REPAIRERS = 2
module.exports = {
run: spawn => {
clearMemory()
const countRole = countRoleF(Game.creeps)
const numberOfHarversters = countRole('harvester')
const numberOfUpgraders = countRole('upgrader')
const numberOfBuilders = countRole('builder')
const numberOfRepairers = countRole('repairer')
logRoles({
numberOfHarversters,
numberOfUpgraders,
numberOfBuilders,
numberOfRepairers
})
const createCreep = createBalancedCreep({
energy: Game.spawns.Spawn1.room.energyCapacityAvailable,
spawn
})
if (numberOfHarversters < MIN_NUMBER_OF_HARVERSTERS) {
createCreep('harvester')
} else if (numberOfUpgraders < MIN_NUMBER_OF_UPGRADERS) {
createCreep('upgrader')
} else if (numberOfRepairers < MIN_NUMBER_OF_REPAIRERS) {
createCreep('repairer')
} else if (numberOfBuilders < MIN_NUMBER_OF_BUILDERS) {
createCreep('builder')
}
}
}