Fix typechecks

This commit is contained in:
uwap 2026-01-03 09:30:08 +01:00
parent 6895b94279
commit 0176c85df4
11 changed files with 35 additions and 16 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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
View file

@ -0,0 +1,3 @@
import lodash from "lodash";
declare const _ = typeof lodash;