diff options
| author | Tom Harley | 2018-06-26 16:15:16 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-06-26 16:15:16 +0100 |
| commit | 98aea93a3c337c38477701b06d98ebf2f83b0fc3 (patch) | |
| tree | 0a04a50e85d5bf499a906b148e8dcd8783aa1895 /src/role.upgrader.js | |
| parent | Add hard-coded spawn reference (diff) | |
| download | screeps-ai-98aea93a3c337c38477701b06d98ebf2f83b0fc3.tar.gz screeps-ai-98aea93a3c337c38477701b06d98ebf2f83b0fc3.zip | |
Unify movement commands
Diffstat (limited to 'src/role.upgrader.js')
| -rw-r--r-- | src/role.upgrader.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/role.upgrader.js b/src/role.upgrader.js index b5d49e2..160b5d5 100644 --- a/src/role.upgrader.js +++ b/src/role.upgrader.js @@ -1,9 +1,11 @@ +const move = 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) { - creep.moveTo(source); + move(creep, source); } if (creep.carry.energy == creep.carryCapacity) { creep.memory.state = "upgrading"; @@ -11,7 +13,7 @@ module.exports = { } else { const controller = creep.room.controller; if (creep.upgradeController(controller) == ERR_NOT_IN_RANGE) { - creep.moveTo(controller, { range: 3 }); + move(creep, controller, { range: 3 }); } if (creep.carry.energy == 0) { creep.memory.state = "withdrawing"; |
