Worker abstraction
This commit is contained in:
parent
57c4ac1688
commit
e2e93947b5
5 changed files with 75 additions and 22 deletions
15
src/Workers/Upgrader.ts
Normal file
15
src/Workers/Upgrader.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
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]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue