Fix typechecks
This commit is contained in:
parent
6895b94279
commit
0176c85df4
11 changed files with 35 additions and 16 deletions
|
|
@ -222,7 +222,7 @@ export default profiler.registerFN(function (room: Room) {
|
|||
for (let i = 0; i < path.length; i++) {
|
||||
const pos = path[i];
|
||||
structures[getCoord(pos.x, pos.y)]
|
||||
= (i === path.length - 1 && "energy" in target)
|
||||
= (i === path.length - 1 && "ticksToRegeneration" in target)
|
||||
? STRUCTURE_CONTAINER
|
||||
: STRUCTURE_ROAD;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ export const runRepair = profiler.registerFN(
|
|||
return TaskStatus.DONE;
|
||||
}
|
||||
|
||||
if (target != null && target.hits >= target.hitsMax) {
|
||||
return TaskStatus.DONE;
|
||||
}
|
||||
|
||||
if (target == null
|
||||
|| creep.repair(target) === ERR_NOT_IN_RANGE) {
|
||||
creep.travelTo(task.targetPos);
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ const assignTask = (creep: Creep) => {
|
|||
}
|
||||
if (creep.room.controller != null) {
|
||||
if (creep.room.controller.ticksToDowngrade > 1000) {
|
||||
const urgentRepair = creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
|
||||
filter: s => s.hits < s.hitsMax * 0.3,
|
||||
const urgentRepair = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
||||
filter: s => s.hits < s.hitsMax * 0.3 && ("my" in s
|
||||
? s.my
|
||||
: s.structureType === STRUCTURE_CONTAINER),
|
||||
});
|
||||
if (urgentRepair != null) {
|
||||
return Tasks.Repair(urgentRepair);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ const assignTask = (creep: Creep) => {
|
|||
}
|
||||
else {
|
||||
const urgentRepair = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
||||
filter: s => "my" in s
|
||||
filter: s => ("my" in s
|
||||
? s.my
|
||||
: s.structureType === STRUCTURE_CONTAINER
|
||||
&& s.hits < s.hitsMax * 0.3,
|
||||
: s.structureType === STRUCTURE_CONTAINER)
|
||||
&& s.hits < s.hitsMax * 0.3,
|
||||
});
|
||||
if (urgentRepair != null) {
|
||||
return Tasks.Repair(urgentRepair);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import "../deps/Traveler/Traveler.js";
|
||||
import "../deps/Traveler/index.d.ts";
|
||||
import "./Proto";
|
||||
import profiler from "screeps-profiler";
|
||||
|
||||
import { Clerk } from "./Workers/Clerk";
|
||||
import { Constructor } from "./Workers/Constructor";
|
||||
import { Miner } from "./Workers/Miner";
|
||||
import { Upgrader } from "./Workers/Upgrader";
|
||||
import { runWorkers, spawnWorkers } from "./Workers/worker";
|
||||
import "../deps/Traveler/Traveler";
|
||||
import profiler from "screeps-profiler";
|
||||
import "./Proto";
|
||||
import RoomPlanner from "./RoomPlanner";
|
||||
|
||||
const runTowers = profiler.registerFN((spawn: StructureSpawn) => {
|
||||
|
|
|
|||
3
src/types.d.ts
vendored
Normal file
3
src/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import lodash from "lodash";
|
||||
|
||||
declare const _ = typeof lodash;
|
||||
Loading…
Add table
Add a link
Reference in a new issue