screep/mount.js

48 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2020-10-26 16:15:52 +08:00
/* eslint-disable func-names */
/* eslint-disable no-console */
/* eslint-disable camelcase */
/* eslint-disable no-undef */
const harvester = require("./harvester");
const transfer = require("./transfer");
const builder = require("./builder");
2020-10-23 20:55:20 +08:00
function action() {
2020-10-26 16:45:02 +08:00
const { role } = this.memory;
// this.say(`${role}`);
switch (role) {
case "harvester":
harvester.run(this);
break;
case "transfer":
transfer.run(this);
break;
case "builder":
builder.run(this);
break;
default:
break;
}
2020-10-26 16:15:52 +08:00
}
module.exports = {
2020-10-26 16:45:02 +08:00
mount() {
Creep.prototype.action = action;
if (!Creep.prototype.hasOwnProperty("working_target_id")) {
Object.defineProperty(Creep.prototype, "working_target_id", {
get() {
return this.memory.working_target_id;
},
set(id) {
this.memory.working_target_id = id;
},
});
}
Game.cwt = function (creep_name) {
Game.creeps[creep_name].working_target_id = undefined;
};
Game.pos = function (id) {
console.log(Game.getObjectById(id));
};
},
2020-10-26 16:15:52 +08:00
};