Created miner, made harvester pick resources and added reset commands.
This commit is contained in:
36
CreepClass.js
Normal file
36
CreepClass.js
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user