Changes to esbuild and adds initial creation of creaps

This commit is contained in:
2025-07-05 22:34:23 -03:00
parent d72f3ec851
commit 06d4eff5c9
9 changed files with 669 additions and 33 deletions

View File

@@ -1,7 +1,7 @@
import SpawnHandler from "spawnHandler";
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)
@@ -9,24 +9,25 @@ declare global {
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.
*/
// Memory extension samples
interface Memory {
uuid: number;
log: any;
}
interface CreepMemory {
role: string;
room: string;
working: boolean;
}
// Syntax for adding proprties to `global` (ex "global.log")
namespace NodeJS {
interface Global {
log: any;
// Memory extension samples
interface Memory {
uuid: number;
log: any;
spawnHandlers: { [name: string]: SpawnHandler };
}
interface CreepMemory {
role: string;
room: string;
working: boolean;
}
// Syntax for adding proprties to `global` (ex "global.log")
namespace NodeJS {
interface Global {
log: any;
}
}
}
}
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
@@ -42,10 +43,18 @@ declare global {
// }
// });
export const loop = () => {
for (const spawn of Object.values(Game.spawns)) {
// Create a handler for each spawn
const spawnHandler = new SpawnHandler(spawn);
// Run the handler
spawnHandler.run();
}
Memory.spawnHandlers = Memory.spawnHandlers || {};
console.log(`Current game tick is ${Game.time}`);
// Check if spawn still exists
for (const spawn of Object.values(Game.spawns)) {
// Create a handler for each spawn
if (spawn.name in Memory.spawnHandlers) {
Memory.spawnHandlers[spawn.name] = new SpawnHandler(spawn);
}
// Run the handler
Memory.spawnHandlers[spawn.name].run();
}
};