module.exports = { begin(creep){ const jobMemory = creep.memory.job; if(!jobMemory.harvesting) creep.memory.job.harvesting = false; }, tick(creep){ const jobMemory = creep.memory.job; if(jobMemory.harvesting){ const source = creep.pos.findClosestByRange(FIND_SOURCES); if(creep.pos.isNearTo(source)) creep.harvest(source); else creep.moveTo(source); if(!creep.store.getFreeCapacity(RESOURCE_ENERGY)) jobMemory.harvesting = false; } else{ const controller = creep.room.controller; if(creep.pos.isNearTo(controller)) creep.upgradeController(controller); else creep.moveTo(controller); if(!creep.store.getUsedCapacity(RESOURCE_ENERGY)) jobMemory.harvesting = true; } } }