summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/role.builder.js6
-rw-r--r--src/role.harvester.js6
-rw-r--r--src/role.offender.js4
-rw-r--r--src/role.upgrader.js6
4 files changed, 13 insertions, 9 deletions
diff --git a/src/role.builder.js b/src/role.builder.js
index a4fc27f..8c7fc6b 100644
--- a/src/role.builder.js
+++ b/src/role.builder.js
@@ -1,3 +1,5 @@
+const util = require('creep');
+
module.exports = {
run: (creep) => {
if (creep.memory.state === "building") {
@@ -5,7 +7,7 @@ module.exports = {
const targets = creep.room.find(FIND_CONSTRUCTION_SITES);
if (targets.length) {
if (creep.build(targets[0]) == ERR_NOT_IN_RANGE) {
- move(creep, targets[0]);
+ util.move(creep, targets[0]);
}
}
} else {
@@ -16,7 +18,7 @@ module.exports = {
// still filling up
const spawn = Game.spawns['Initial'];
if (creep.transfer(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
- move(creep, spawn);
+ util.move(creep, spawn);
}
} else {
creep.memory.state = "building";
diff --git a/src/role.harvester.js b/src/role.harvester.js
index e08db08..126f575 100644
--- a/src/role.harvester.js
+++ b/src/role.harvester.js
@@ -1,4 +1,4 @@
-const move = require('creep');
+const util = require('creep');
module.exports = {
run: (creep) => {
@@ -6,12 +6,12 @@ module.exports = {
// just use the first source for now
const source = creep.pos.findClosestByPath(FIND_SOURCES);
if (creep.harvest(source) == ERR_NOT_IN_RANGE) {
- move(creep, source);
+ util.move(creep, source);
}
} else {
const spawn = Game.spawns['Initial'];
if (creep.transfer(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
- move(creep, spawn);
+ util.move(creep, spawn);
}
}
}
diff --git a/src/role.offender.js b/src/role.offender.js
index fc5196d..91d131e 100644
--- a/src/role.offender.js
+++ b/src/role.offender.js
@@ -1,9 +1,11 @@
+const util = require('creep');
+
module.exports = {
run: (creep) => {
const hostiles = creep.room.find(FIND_HOSTILE_CREEPS);
if (hostiles.length > 0) {
if (creep.attack(hostiles[0]) == ERR_NOT_IN_RANGE) {
- move(creep, hostiles[0]);
+ util.move(creep, hostiles[0]);
}
}
}
diff --git a/src/role.upgrader.js b/src/role.upgrader.js
index 160b5d5..26ccdf6 100644
--- a/src/role.upgrader.js
+++ b/src/role.upgrader.js
@@ -1,11 +1,11 @@
-const move = require('creep');
+const util = require('creep');
module.exports = {
run: (creep) => {
if (creep.memory.state === "withdrawing") {
const source = Game.spawns['Initial'];
if (creep.withdraw(source, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
- move(creep, source);
+ util.move(creep, source);
}
if (creep.carry.energy == creep.carryCapacity) {
creep.memory.state = "upgrading";
@@ -13,7 +13,7 @@ module.exports = {
} else {
const controller = creep.room.controller;
if (creep.upgradeController(controller) == ERR_NOT_IN_RANGE) {
- move(creep, controller, { range: 3 });
+ util.move(creep, controller, { range: 3 });
}
if (creep.carry.energy == 0) {
creep.memory.state = "withdrawing";