chore: fixes module pathing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { CreepRole, CreepRoles } from 'types/creeps';
|
import { CreepRole, CreepRoles } from '@/types/creeps';
|
||||||
import { getRoomCreeps } from 'utils/funcs/getRoomCreeps';
|
import { getRoomCreeps } from '@/utils/funcs/getRoomCreeps';
|
||||||
|
|
||||||
class CreepRunner {
|
class CreepRunner {
|
||||||
public static run(room: Room, state: GameState): GameState {
|
public static run(room: Room, state: GameState): GameState {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { CreepRequisition, CreepRole, CreepRoles } from 'types/creeps';
|
import { CreepRequisition, CreepRole, CreepRoles } from '@/types/creeps';
|
||||||
import { DEFAULT_GAME_CONFIG } from 'types/gameConfig';
|
import { DEFAULT_GAME_CONFIG } from '@/types/gameConfig';
|
||||||
import { get_role_cost } from 'utils/funcs/getRoleCost';
|
import { get_role_cost } from '@/utils/funcs/getRoleCost';
|
||||||
import { getRoomCreeps } from 'utils/funcs/getRoomCreeps';
|
import { getRoomCreeps } from '@/utils/funcs/getRoomCreeps';
|
||||||
import { sortCreepRolesByPriority } from 'utils/funcs/sortCreepRolesByPriority';
|
import { sortCreepRolesByPriority } from '@/utils/funcs/sortCreepRolesByPriority';
|
||||||
|
|
||||||
class RequisitionsManager {
|
class RequisitionsManager {
|
||||||
public static validateState(room: Room, state: GameState): GameState {
|
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 {
|
import {
|
||||||
createSourcePositionMatrix,
|
createSourcePositionMatrix,
|
||||||
forEachMatrixSpot,
|
forEachMatrixSpot,
|
||||||
getPositionWithDelta,
|
getPositionWithDelta,
|
||||||
PositionSpotStatus,
|
PositionSpotStatus,
|
||||||
setSpotStatus,
|
setSpotStatus,
|
||||||
} from 'utils/positions';
|
} from '@/utils/positions';
|
||||||
|
|
||||||
class RoomInspector {
|
class RoomInspector {
|
||||||
public static inspectState(room: Room, state: GameState): GameState {
|
public static inspectState(room: Room, state: GameState): GameState {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import CreepRunner from 'CreepRunner';
|
import CreepRunner from '@/CreepRunner';
|
||||||
import RequisitionsManager from 'RequisitionsManager';
|
import RequisitionsManager from '@/RequisitionsManager';
|
||||||
import RoomInspector from 'RoomInspector';
|
import RoomInspector from '@/RoomInspector';
|
||||||
|
|
||||||
class RoomRunner {
|
class RoomRunner {
|
||||||
public static run(room: Room, state: GameState): GameState {
|
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 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const loop = () => {
|
export const loop = () => {
|
||||||
Memory.roomStateRegistry = Memory.roomStateRegistry || {};
|
Memory.roomStateRegistry = Memory.roomStateRegistry || {};
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { RoleHandler } from './BaseHandler.interface';
|
import { RoleHandler } from './BaseHandler.interface';
|
||||||
import { SourceDestination } from 'types/creeps';
|
import { SourceDestination } from '@/types/creeps';
|
||||||
import { getSourceById, getSpawnById } from 'utils/funcs/getById';
|
import { getSourceById, getSpawnById } from '@/utils/funcs/getById';
|
||||||
import {
|
import {
|
||||||
getNextEmptySpot,
|
getNextEmptySpot,
|
||||||
getPositionWithDelta,
|
getPositionWithDelta,
|
||||||
PositionSpotStatus,
|
PositionSpotStatus,
|
||||||
setSpotStatus,
|
setSpotStatus,
|
||||||
} from 'utils/positions';
|
} from '@/utils/positions';
|
||||||
|
|
||||||
class HarvesterHandler extends RoleHandler {
|
class HarvesterHandler extends RoleHandler {
|
||||||
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { RoleHandler } from './BaseHandler.interface';
|
import { RoleHandler } from './BaseHandler.interface';
|
||||||
import { SourceDestination } from 'types/creeps';
|
import { SourceDestination } from '@/types/creeps';
|
||||||
import { getControllerById, getSourceById } from 'utils/funcs/getById';
|
import { getControllerById, getSourceById } from '@/utils/funcs/getById';
|
||||||
import {
|
import {
|
||||||
getNextEmptySpot,
|
getNextEmptySpot,
|
||||||
|
getPositionWithDelta,
|
||||||
PositionSpotStatus,
|
PositionSpotStatus,
|
||||||
setSpotStatus,
|
setSpotStatus,
|
||||||
getPositionWithDelta,
|
} from '@/utils/positions';
|
||||||
} from 'utils/positions';
|
|
||||||
|
|
||||||
class UpgraderHandler extends RoleHandler {
|
class UpgraderHandler extends RoleHandler {
|
||||||
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { HarvesterHandler, RoleHandler, UpgraderHandler } from 'roleHandlers';
|
import { HarvesterHandler, RoleHandler, UpgraderHandler } from '@/roleHandlers';
|
||||||
import { PositionDelta } from 'utils/positions';
|
import { PositionDelta } from '@/utils/positions';
|
||||||
|
|
||||||
export type RoleDefinition = {
|
export type RoleDefinition = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RoleDefinition } from 'types/creeps';
|
import { RoleDefinition } from '@/types/creeps';
|
||||||
|
|
||||||
export const get_role_cost = (role: RoleDefinition) => {
|
export const get_role_cost = (role: RoleDefinition) => {
|
||||||
return role.body.reduce((cost, part) => {
|
return role.body.reduce((cost, part) => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
CreepRole,
|
CreepRole,
|
||||||
CreepRoles,
|
CreepRoles,
|
||||||
RoleDefinition,
|
RoleDefinition,
|
||||||
} from 'types/creeps';
|
} from '@/types/creeps';
|
||||||
|
|
||||||
export const sortCreepRolesByPriority = (
|
export const sortCreepRolesByPriority = (
|
||||||
requisition: CreepRequisition
|
requisition: CreepRequisition
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ describe('HarvesterHandler', () => {
|
|||||||
// None of the source spots should have changed
|
// None of the source spots should have changed
|
||||||
expect(
|
expect(
|
||||||
state.sourcesStates['src1'].spots.every(
|
state.sourcesStates['src1'].spots.every(
|
||||||
(s) =>
|
(s: PositionSpotStatus) =>
|
||||||
s === PositionSpotStatus.EMPTY ||
|
s === PositionSpotStatus.EMPTY ||
|
||||||
s === PositionSpotStatus.CENTER
|
s === PositionSpotStatus.CENTER
|
||||||
)
|
)
|
||||||
@@ -232,7 +232,7 @@ describe('HarvesterHandler', () => {
|
|||||||
// Fill all non-center spots with OCCUPIED
|
// Fill all non-center spots with OCCUPIED
|
||||||
state.sourcesStates['src1'].spots = state.sourcesStates[
|
state.sourcesStates['src1'].spots = state.sourcesStates[
|
||||||
'src1'
|
'src1'
|
||||||
].spots.map((s) =>
|
].spots.map((s: PositionSpotStatus) =>
|
||||||
s === PositionSpotStatus.CENTER
|
s === PositionSpotStatus.CENTER
|
||||||
? s
|
? s
|
||||||
: PositionSpotStatus.OCCUPIED
|
: PositionSpotStatus.OCCUPIED
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ describe('UpgraderHandler', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
state.sourcesStates['src1'].spots.every(
|
state.sourcesStates['src1'].spots.every(
|
||||||
(s) =>
|
(s: PositionSpotStatus) =>
|
||||||
s === PositionSpotStatus.EMPTY ||
|
s === PositionSpotStatus.EMPTY ||
|
||||||
s === PositionSpotStatus.CENTER
|
s === PositionSpotStatus.CENTER
|
||||||
)
|
)
|
||||||
@@ -220,7 +220,7 @@ describe('UpgraderHandler', () => {
|
|||||||
// Occupy all spots so onFindNewSource cannot reassign a source
|
// Occupy all spots so onFindNewSource cannot reassign a source
|
||||||
state.sourcesStates['src1'].spots = state.sourcesStates[
|
state.sourcesStates['src1'].spots = state.sourcesStates[
|
||||||
'src1'
|
'src1'
|
||||||
].spots.map((s) =>
|
].spots.map((s: PositionSpotStatus) =>
|
||||||
s === PositionSpotStatus.CENTER
|
s === PositionSpotStatus.CENTER
|
||||||
? s
|
? s
|
||||||
: PositionSpotStatus.OCCUPIED
|
: PositionSpotStatus.OCCUPIED
|
||||||
@@ -260,7 +260,7 @@ describe('UpgraderHandler', () => {
|
|||||||
const state = makeState();
|
const state = makeState();
|
||||||
state.sourcesStates['src1'].spots = state.sourcesStates[
|
state.sourcesStates['src1'].spots = state.sourcesStates[
|
||||||
'src1'
|
'src1'
|
||||||
].spots.map((s) =>
|
].spots.map((s: PositionSpotStatus) =>
|
||||||
s === PositionSpotStatus.CENTER
|
s === PositionSpotStatus.CENTER
|
||||||
? s
|
? s
|
||||||
: PositionSpotStatus.OCCUPIED
|
: PositionSpotStatus.OCCUPIED
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"],
|
"@/*": ["./src/*"],
|
||||||
"~/*": ["./*"]
|
"~/*": ["./*"]
|
||||||
}
|
},
|
||||||
|
"typeRoots": ["node_modules/@types", "src"]
|
||||||
},
|
},
|
||||||
"include": ["src/*.ts", "src/**/*.ts"],
|
"include": ["src/global.d.ts", "src/*.ts", "src/**/*.ts"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user