Created miner, made harvester pick resources and added reset commands.

This commit is contained in:
Douwe Ravers
2023-08-26 16:57:38 +02:00
parent 76650e22ac
commit e294ad29fe
13 changed files with 310 additions and 136 deletions

36
CreepClass.js Normal file
View File

@@ -0,0 +1,36 @@
const jobHarvester = require("JobHarvester");
const jobMiner = require("JobMiner");
module.exports = {
setup: function () {
Creep.prototype = _Creep.prototype;
global.Role = Role;
}
}
const Role = {
HARVESTER: 0,
MINER: 1,
SUPPLIER: 2,
UPGRADER: 3,
BUILDER: 4
}
class _Creep extends Creep {
begin(){
if(!this.memory.job) this.memory.job = { role: Role.HARVESTER };
switch (this.memory.job.role) {
case Role.HARVESTER: jobHarvester.begin(this); break;
case Role.MINER: jobMiner.begin(this); break;
}
this.memory.init = true;
}
tick(){
if(!this.memory.init) this.begin();
switch (this.memory.job.role) {
case Role.HARVESTER: jobHarvester.tick(this); break;
case Role.MINER: jobMiner.tick(this); break;
}
}
}