First working version of colony.

Harversters and spawn work.
This commit is contained in:
douwe
2025-08-13 20:43:26 +02:00
parent 8a39526580
commit 9a1682a857
28 changed files with 1328 additions and 114 deletions

View File

@@ -1,18 +1,25 @@
#include <nlohmann/json.hpp>
#include <Screeps/JS.hpp>
#include <Screeps/Game.hpp>
#include <Screeps/Room.hpp>
#include <Screeps/StructureSpawn.hpp>
#include <emscripten.h>
#include "Constants.hpp"
#include "structures/spawn.hpp"
void SpawnManager::process()
void DouwcoHivemind::Spawn::process()
{
for (auto& spawn : Screeps::Game.spawns())
{
int creepcount = spawn.second.room().find(Screeps::FIND_MY_CREEPS, nullptr).size();
// EM_ASM({ console.log('creepcount: ' + $0); }, creepcount);
if (creepcount >= 3) continue;
int resp = spawn.second.spawnCreep({"work", "carry", "move"}, "harvester" + std::to_string(creepcount + 1));
}
int creepcount = structure->room().find(Screeps::FIND_MY_CREEPS, nullptr).size();
EM_ASM({ console.log('creepcount: ' + $0); }, creepcount);
if (creepcount >= 10) return;
JSON opts;
opts["memory"]["role"] = DouwcoHivemind::ROLE_HARVESTER;
int resp = structure->spawnCreep(
{"work", "carry", "move"},
"harvester" + std::to_string(creepcount + 1),
opts
);
}