blob: d26039749f8abd3853ff3a43a1594731fb262e3c (
plain) (
blame)
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
|
const jobs = {
harvester: require('role.harvester')
};
const spawnCreep = (spawn, job, tools) => {
Memory.counts[job]++;
const name = job + Memory.counts[job];
spawn.spawnCreep(tools, name);
Game.creeps[name].memory.job = job;
}
const spawnHarvester = (spawn) => {
spawnCreep(spawn, 'harvester', [WORK, MOVE, CARRY]);
}
module.exports.loop = () => {
for (const name in Game.creeps) {
const creep = Game.creeps[name];
const job = jobs[creep.memory.job];
if (job) {
job.run(creep);
} else {
console.err(creep.name + " is missing instructions for job "
+ creep.memory.job);
}
}
}
|