chore: fixes module pathing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { CreepRole, CreepRoles } from 'types/creeps';
|
||||
import { getRoomCreeps } from 'utils/funcs/getRoomCreeps';
|
||||
import { CreepRole, CreepRoles } from '@/types/creeps';
|
||||
import { getRoomCreeps } from '@/utils/funcs/getRoomCreeps';
|
||||
|
||||
class CreepRunner {
|
||||
public static run(room: Room, state: GameState): GameState {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { CreepRequisition, CreepRole, CreepRoles } from 'types/creeps';
|
||||
import { DEFAULT_GAME_CONFIG } from 'types/gameConfig';
|
||||
import { get_role_cost } from 'utils/funcs/getRoleCost';
|
||||
import { getRoomCreeps } from 'utils/funcs/getRoomCreeps';
|
||||
import { sortCreepRolesByPriority } from 'utils/funcs/sortCreepRolesByPriority';
|
||||
import { CreepRequisition, CreepRole, CreepRoles } from '@/types/creeps';
|
||||
import { DEFAULT_GAME_CONFIG } from '@/types/gameConfig';
|
||||
import { get_role_cost } from '@/utils/funcs/getRoleCost';
|
||||
import { getRoomCreeps } from '@/utils/funcs/getRoomCreeps';
|
||||
import { sortCreepRolesByPriority } from '@/utils/funcs/sortCreepRolesByPriority';
|
||||
|
||||
class RequisitionsManager {
|
||||
public static validateState(room: Room, state: GameState): GameState {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { checkPositionWalkable } from 'utils/funcs/checkPosition';
|
||||
import { checkPositionWalkable } from '@/utils/funcs/checkPosition';
|
||||
import {
|
||||
createSourcePositionMatrix,
|
||||
forEachMatrixSpot,
|
||||
getPositionWithDelta,
|
||||
PositionSpotStatus,
|
||||
setSpotStatus,
|
||||
} from 'utils/positions';
|
||||
} from '@/utils/positions';
|
||||
|
||||
class RoomInspector {
|
||||
public static inspectState(room: Room, state: GameState): GameState {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import CreepRunner from 'CreepRunner';
|
||||
import RequisitionsManager from 'RequisitionsManager';
|
||||
import RoomInspector from 'RoomInspector';
|
||||
import CreepRunner from '@/CreepRunner';
|
||||
import RequisitionsManager from '@/RequisitionsManager';
|
||||
import RoomInspector from '@/RoomInspector';
|
||||
|
||||
class RoomRunner {
|
||||
public static run(room: Room, state: GameState): GameState {
|
||||
|
||||
48
src/global.d.ts
vendored
Normal file
48
src/global.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { CreepDestination } from '@/types/creeps';
|
||||
import { PositionMatrix } from '@/utils/positions';
|
||||
|
||||
declare global {
|
||||
/*
|
||||
Example types, expand on these or remove them and add your own.
|
||||
Note: Values, properties defined here do no fully *exist* by this type definiton alone.
|
||||
You must also give them an implemention if you would like to use them. (ex. actually setting a `role` property in a Creeps memory)
|
||||
|
||||
Types added in this `global` block are in an ambient, global context. This is needed because `main.ts` is a module file (uses import or export).
|
||||
Interfaces matching on name from @types/screeps will be merged. This is how you can extend the 'built-in' interfaces from @types/screeps.
|
||||
*/
|
||||
interface SourceState {
|
||||
id: string;
|
||||
spots: PositionMatrix;
|
||||
pos: RoomPosition;
|
||||
}
|
||||
|
||||
interface GameState {
|
||||
sourcesStates: { [sourceId: string]: SourceState };
|
||||
maxHarvesters: number; // Maximum number of harvesters allowed in the game
|
||||
}
|
||||
|
||||
// Memory extension samples
|
||||
interface Memory {
|
||||
uuid: number;
|
||||
log: any;
|
||||
roomStateRegistry: { [name: string]: GameState };
|
||||
}
|
||||
|
||||
interface CreepMemory {
|
||||
role: string;
|
||||
room: string;
|
||||
spawnId: string;
|
||||
working: boolean;
|
||||
destination?: CreepDestination;
|
||||
previousDestination?: CreepDestination;
|
||||
}
|
||||
|
||||
// Syntax for adding proprties to `global` (ex "global.log")
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
log: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
48
src/main.ts
48
src/main.ts
@@ -1,50 +1,4 @@
|
||||
import RoomRunner from 'RoomRunner';
|
||||
import { CreepDestination } from 'types/creeps';
|
||||
import { PositionMatrix } from 'utils/positions';
|
||||
|
||||
declare global {
|
||||
/*
|
||||
Example types, expand on these or remove them and add your own.
|
||||
Note: Values, properties defined here do no fully *exist* by this type definiton alone.
|
||||
You must also give them an implemention if you would like to use them. (ex. actually setting a `role` property in a Creeps memory)
|
||||
|
||||
Types added in this `global` block are in an ambient, global context. This is needed because `main.ts` is a module file (uses import or export).
|
||||
Interfaces matching on name from @types/screeps will be merged. This is how you can extend the 'built-in' interfaces from @types/screeps.
|
||||
*/
|
||||
interface SourceState {
|
||||
id: string;
|
||||
spots: PositionMatrix;
|
||||
pos: RoomPosition;
|
||||
}
|
||||
|
||||
interface GameState {
|
||||
sourcesStates: { [sourceId: string]: SourceState };
|
||||
maxHarvesters: number; // Maximum number of harvesters allowed in the game
|
||||
}
|
||||
|
||||
// Memory extension samples
|
||||
interface Memory {
|
||||
uuid: number;
|
||||
log: any;
|
||||
roomStateRegistry: { [name: string]: GameState };
|
||||
}
|
||||
|
||||
interface CreepMemory {
|
||||
role: string;
|
||||
room: string;
|
||||
spawnId: string;
|
||||
working: boolean;
|
||||
destination?: CreepDestination;
|
||||
previousDestination?: CreepDestination;
|
||||
}
|
||||
|
||||
// Syntax for adding proprties to `global` (ex "global.log")
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
log: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
import RoomRunner from '@/RoomRunner';
|
||||
|
||||
export const loop = () => {
|
||||
Memory.roomStateRegistry = Memory.roomStateRegistry || {};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RoleHandler } from './BaseHandler.interface';
|
||||
import { SourceDestination } from 'types/creeps';
|
||||
import { getSourceById, getSpawnById } from 'utils/funcs/getById';
|
||||
import { SourceDestination } from '@/types/creeps';
|
||||
import { getSourceById, getSpawnById } from '@/utils/funcs/getById';
|
||||
import {
|
||||
getNextEmptySpot,
|
||||
getPositionWithDelta,
|
||||
PositionSpotStatus,
|
||||
setSpotStatus,
|
||||
} from 'utils/positions';
|
||||
} from '@/utils/positions';
|
||||
|
||||
class HarvesterHandler extends RoleHandler {
|
||||
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RoleHandler } from './BaseHandler.interface';
|
||||
import { SourceDestination } from 'types/creeps';
|
||||
import { getControllerById, getSourceById } from 'utils/funcs/getById';
|
||||
import { SourceDestination } from '@/types/creeps';
|
||||
import { getControllerById, getSourceById } from '@/utils/funcs/getById';
|
||||
import {
|
||||
getNextEmptySpot,
|
||||
getPositionWithDelta,
|
||||
PositionSpotStatus,
|
||||
setSpotStatus,
|
||||
getPositionWithDelta,
|
||||
} from 'utils/positions';
|
||||
} from '@/utils/positions';
|
||||
|
||||
class UpgraderHandler extends RoleHandler {
|
||||
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HarvesterHandler, RoleHandler, UpgraderHandler } from 'roleHandlers';
|
||||
import { PositionDelta } from 'utils/positions';
|
||||
import { HarvesterHandler, RoleHandler, UpgraderHandler } from '@/roleHandlers';
|
||||
import { PositionDelta } from '@/utils/positions';
|
||||
|
||||
export type RoleDefinition = {
|
||||
name: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RoleDefinition } from 'types/creeps';
|
||||
import { RoleDefinition } from '@/types/creeps';
|
||||
|
||||
export const get_role_cost = (role: RoleDefinition) => {
|
||||
return role.body.reduce((cost, part) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
CreepRole,
|
||||
CreepRoles,
|
||||
RoleDefinition,
|
||||
} from 'types/creeps';
|
||||
} from '@/types/creeps';
|
||||
|
||||
export const sortCreepRolesByPriority = (
|
||||
requisition: CreepRequisition
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('HarvesterHandler', () => {
|
||||
// None of the source spots should have changed
|
||||
expect(
|
||||
state.sourcesStates['src1'].spots.every(
|
||||
(s) =>
|
||||
(s: PositionSpotStatus) =>
|
||||
s === PositionSpotStatus.EMPTY ||
|
||||
s === PositionSpotStatus.CENTER
|
||||
)
|
||||
@@ -232,7 +232,7 @@ describe('HarvesterHandler', () => {
|
||||
// Fill all non-center spots with OCCUPIED
|
||||
state.sourcesStates['src1'].spots = state.sourcesStates[
|
||||
'src1'
|
||||
].spots.map((s) =>
|
||||
].spots.map((s: PositionSpotStatus) =>
|
||||
s === PositionSpotStatus.CENTER
|
||||
? s
|
||||
: PositionSpotStatus.OCCUPIED
|
||||
|
||||
@@ -131,7 +131,7 @@ describe('UpgraderHandler', () => {
|
||||
|
||||
expect(
|
||||
state.sourcesStates['src1'].spots.every(
|
||||
(s) =>
|
||||
(s: PositionSpotStatus) =>
|
||||
s === PositionSpotStatus.EMPTY ||
|
||||
s === PositionSpotStatus.CENTER
|
||||
)
|
||||
@@ -220,7 +220,7 @@ describe('UpgraderHandler', () => {
|
||||
// Occupy all spots so onFindNewSource cannot reassign a source
|
||||
state.sourcesStates['src1'].spots = state.sourcesStates[
|
||||
'src1'
|
||||
].spots.map((s) =>
|
||||
].spots.map((s: PositionSpotStatus) =>
|
||||
s === PositionSpotStatus.CENTER
|
||||
? s
|
||||
: PositionSpotStatus.OCCUPIED
|
||||
@@ -260,7 +260,7 @@ describe('UpgraderHandler', () => {
|
||||
const state = makeState();
|
||||
state.sourcesStates['src1'].spots = state.sourcesStates[
|
||||
'src1'
|
||||
].spots.map((s) =>
|
||||
].spots.map((s: PositionSpotStatus) =>
|
||||
s === PositionSpotStatus.CENTER
|
||||
? s
|
||||
: PositionSpotStatus.OCCUPIED
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
"~/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"typeRoots": ["node_modules/@types", "src"]
|
||||
},
|
||||
"include": ["src/*.ts", "src/**/*.ts"],
|
||||
"include": ["src/global.d.ts", "src/*.ts", "src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user