diff options
Diffstat (limited to 'src/role.upgrader.js')
| -rw-r--r-- | src/role.upgrader.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/role.upgrader.js b/src/role.upgrader.js new file mode 100644 index 0000000..7c018d7 --- /dev/null +++ b/src/role.upgrader.js @@ -0,0 +1,15 @@ +module.exports = { + run: (creep) => { + if (creep.carry.energy < creep.carryCapacity) { + const source = Game.spawns['Initial']; + if (creep.withdraw(source, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { + creep.moveTo(source); + } + } else { + const controller = creep.room.controller; + if (creep.upgradeController(controller) == ERR_NOT_IN_RANGE) { + creep.moveTo(controller, { range: 3 }); + } + } + } +}; |
