diff options
| author | Tom Harley | 2018-06-26 16:21:46 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-06-26 16:21:46 +0100 |
| commit | 19d3d7dbae37c5d863f8887602ef8241ac770551 (patch) | |
| tree | 1b1e63d378e6e0f719c41cc272b7bad23f10d6c1 /src | |
| parent | Unify movement commands (diff) | |
| download | screeps-ai-19d3d7dbae37c5d863f8887602ef8241ac770551.tar.gz screeps-ai-19d3d7dbae37c5d863f8887602ef8241ac770551.zip | |
Actually include unified movement function
Diffstat (limited to 'src')
| -rw-r--r-- | src/role.builder.js | 6 | ||||
| -rw-r--r-- | src/role.harvester.js | 6 | ||||
| -rw-r--r-- | src/role.offender.js | 4 | ||||
| -rw-r--r-- | src/role.upgrader.js | 6 |
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"; |
