Builder Creeps and Extension Blueprints
This commit is contained in:
parent
48350d6f33
commit
5e6618edca
5 changed files with 62 additions and 10 deletions
23
src/Actions/buildConstructionSite.ts
Normal file
23
src/Actions/buildConstructionSite.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue