Better Typing for Positions and Formats Code

This commit is contained in:
2025-07-14 23:07:44 -03:00
parent 230153403f
commit 952d274c53
14 changed files with 235 additions and 182 deletions

View File

@@ -1,5 +1,5 @@
import { HarvesterHandler, RoleHandler, UpgraderHandler } from "roleHandlers";
import { PositionDelta } from "./source";
import { PositionDelta } from "utils/positions";
export type RoleDefinition = {
name: string;
@@ -33,35 +33,29 @@ export type CreepRole = keyof typeof CreepRoles;
export type CreepRequisition = Record<CreepRole, number>;
export type SpawnDestination = {
id: string; // ID of the spawn
type: "spawn";
}
};
export type SourceDestination = {
id: string; // ID of the source
type: "source";
sourceSpot: PositionDelta; // Position delta for the source spot
}
};
export type ControllerDestination = {
id: string; // ID of the controller
type: "controller";
}
};
export type ConstructionSiteDestination = {
id: string; // ID of the construction site
type: "constructionSite";
}
export type CreepDestination = (
SpawnDestination |
SourceDestination |
ControllerDestination |
ConstructionSiteDestination
);
};
export type CreepDestination =
| SpawnDestination
| SourceDestination
| ControllerDestination
| ConstructionSiteDestination;