const jobBuilder = require("JobBuilder"); const jobMiner = require("JobMiner"); const jobSupplier = require("JobSupplier"); const jobUpgrader = require("JobUpgrader"); module.exports = { setup: function () { Creep.prototype = _Creep.prototype; global.Role = Role; } } const Role = { BUILDER: 0, MINER: 1, SUPPLIER: 2, UPGRADER: 3 } class _Creep extends Creep { begin(){ if(!this.memory.job) this.memory.job = { role: Role.HARVESTER }; switch (this.memory.job.role) { case Role.BUILDER: jobBuilder.begin(this); break; case Role.MINER: jobMiner.begin(this); break; case Role.SUPPLIER: jobSupplier.begin(this); break; case Role.UPGRADER: jobUpgrader.begin(this); break; } this.memory.init = true; } tick(){ if(!this.memory.init) this.begin(); switch (this.memory.job.role) { case Role.BUILDER: jobBuilder.tick(this); break; case Role.MINER: jobMiner.tick(this); break; case Role.SUPPLIER: jobSupplier.tick(this); break; case Role.UPGRADER: jobUpgrader.tick(this); break; } } }