screeps-bot-hurricane/src/Workers/Upgrader.ts
2022-12-22 09:51:22 +01:00

15 lines
No EOL
717 B
TypeScript

import { Fail, runAction } from "../Actions/Action";
import { harvestFromClosestActiveSource } from "../Actions/harvest";
import { transferEnergy } from "../Actions/transferEnergy";
import { upgradeController } from "../Actions/upgradeController";
import { WorkerDefinition } from "./worker";
export const Upgrader: WorkerDefinition = {
runAction: (creep: Creep, spawn: StructureSpawn) => runAction(creep, harvestFromClosestActiveSource())
.andThen(transferEnergy(spawn))
.or(creep.room.controller ? upgradeController(creep.room.controller) : Fail)
.repeat(),
name: 'upgrader',
requiredCreeps: (room: Room) => 2,
bodyDefinition: (energy: number) => [WORK, WORK, MOVE, CARRY]
}