Builder Creeps and Extension Blueprints

This commit is contained in:
uwap 2022-12-21 15:19:45 +01:00
parent 48350d6f33
commit 5e6618edca
5 changed files with 62 additions and 10 deletions

View file

@ -51,7 +51,7 @@ export const createAction = (name: string, action: (creep: Creep) => Action): Ac
if ((creep.memory.state ?? 0) > state) {
return Success(creep, state);
}
console.log(`[${creep.name}] Running action ${name}`)
//console.log(`[${creep.name}] Running action ${name}`)
return action(creep)(creep, state);
}
}

View file

@ -0,0 +1,23 @@
import { createAction, Fail, InProgress, Success } from "./Action";
import { moveTo } from "./moveTo";
export const buildConstructionSite = () => createAction('buildConstructionSite', (creep: Creep) => {
const cs = creep.pos.findClosestByRange(FIND_CONSTRUCTION_SITES);
if (!cs) {
return Fail;
}
switch (creep.build(cs)) {
case OK: {
return InProgress;
}
case ERR_NOT_ENOUGH_RESOURCES: {
return Success;
}
case ERR_NOT_IN_RANGE: {
return moveTo(cs);
}
default: {
return Fail;
}
}
})