added the maintainer and changed some naming.
This commit is contained in:
22
douwco_hivemind/include/Creeps/Builder.hpp
Normal file
22
douwco_hivemind/include/Creeps/Builder.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DOUWCO_HIVEMIND_BUILDER_HPP
|
||||
#define DOUWCO_HIVEMIND_BUILDER_HPP
|
||||
|
||||
#include "Creeps/Worker.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Builder : public Worker
|
||||
{
|
||||
public:
|
||||
Builder(Screeps::Creep creep) : Worker(creep) {}
|
||||
|
||||
protected:
|
||||
void depositEnergy() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Screeps::ConstructionSite> getConstructionSiteTarget();
|
||||
void searchConstructionSite();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_BUILDER_HPP
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef DOUWCO_HIVEMIND_CREEP_HPP
|
||||
#define DOUWCO_HIVEMIND_CREEP_HPP
|
||||
#ifndef DOUWCO_HIVEMIND_CREEPBASE_HPP
|
||||
#define DOUWCO_HIVEMIND_CREEPBASE_HPP
|
||||
|
||||
#include <Screeps/Creep.hpp>
|
||||
|
||||
@@ -14,12 +14,13 @@ namespace DouwcoHivemind
|
||||
enum CreepRole
|
||||
{
|
||||
UNEMPLOYED,
|
||||
HARVESTER_SUPPLIER,
|
||||
HARVESTER_UPGRADER,
|
||||
HARVESTER_BUILDER
|
||||
SUPPLIER,
|
||||
UPGRADER,
|
||||
BUILDER,
|
||||
MAINTAINER
|
||||
};
|
||||
|
||||
class Creep
|
||||
class CreepBase
|
||||
{
|
||||
public:
|
||||
CreepRole role;
|
||||
@@ -30,15 +31,19 @@ namespace DouwcoHivemind
|
||||
JSON memory;
|
||||
|
||||
public:
|
||||
Creep(Screeps::Creep crp);
|
||||
virtual ~Creep();
|
||||
CreepBase(Screeps::Creep crp);
|
||||
virtual ~CreepBase();
|
||||
virtual void loop() {}
|
||||
|
||||
|
||||
|
||||
bool isNearTo(const Screeps::RoomPosition &pos, int dist);
|
||||
|
||||
|
||||
protected:
|
||||
void moveToTarget(int dist = 1);
|
||||
std::unique_ptr<Screeps::RoomObject> getRoomObjectTarget();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_CREEP_HPP
|
||||
#endif // DOUWCO_HIVEMIND_CREEPBASE_HPP
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef DOUWCO_HIVEMIND_HARVESTER_BUILDER_HPP
|
||||
#define DOUWCO_HIVEMIND_HARVESTER_BUILDER_HPP
|
||||
|
||||
#include "Creeps/Harvester.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class HarvesterBuilder : public Harvester
|
||||
{
|
||||
public:
|
||||
HarvesterBuilder(Screeps::Creep creep) : Harvester(creep) {}
|
||||
|
||||
protected:
|
||||
void depositEnergy() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Screeps::ConstructionSite> getConstructionSiteTarget();
|
||||
void searchConstructionSite();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_HARVESTER_BUILDER_HPP
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef DOUWCO_HIVEMIND_HARVESTER_SUPPLIER_HPP
|
||||
#define DOUWCO_HIVEMIND_HARVESTER_SUPPLIER_HPP
|
||||
|
||||
#include "Creeps/Harvester.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class HarvesterSupplier : public Harvester
|
||||
{
|
||||
public:
|
||||
HarvesterSupplier(Screeps::Creep creep) : Harvester(creep) {}
|
||||
|
||||
protected:
|
||||
void depositEnergy() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Screeps::Structure> getEnergyStructureTarget();
|
||||
void searchEnergyStructure();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_HARVESTER_SUPPLIER_HPP
|
||||
22
douwco_hivemind/include/Creeps/Maintainer.hpp
Normal file
22
douwco_hivemind/include/Creeps/Maintainer.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DOUWCO_HIVEMIND_MAINTAINER_HPP
|
||||
#define DOUWCO_HIVEMIND_MAINTAINER_HPP
|
||||
|
||||
#include "Creeps/Worker.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Maintainer : public Worker
|
||||
{
|
||||
public:
|
||||
Maintainer(Screeps::Creep creep) : Worker(creep) {}
|
||||
|
||||
protected:
|
||||
void depositEnergy() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Screeps::Structure> getDamagedStructureTarget();
|
||||
void searchDamagedStructure();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_MAINTAINER_HPP
|
||||
22
douwco_hivemind/include/Creeps/Supplier.hpp
Normal file
22
douwco_hivemind/include/Creeps/Supplier.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DOUWCO_HIVEMIND_SUPPLIER_HPP
|
||||
#define DOUWCO_HIVEMIND_SUPPLIER_HPP
|
||||
|
||||
#include "Creeps/Worker.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Supplier : public Worker
|
||||
{
|
||||
public:
|
||||
Supplier(Screeps::Creep creep) : Worker(creep) {}
|
||||
|
||||
protected:
|
||||
void depositEnergy() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Screeps::Structure> getEnergyStructureTarget();
|
||||
void searchEnergyStructure();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_SUPPLIER_HPP
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef DOUWCO_HIVEMIND_HARVESTER_UPGRADER_HPP
|
||||
#define DOUWCO_HIVEMIND_HARVESTER_UPGRADER_HPP
|
||||
|
||||
#include "Creeps/Harvester.hpp"
|
||||
#include "Creeps/Worker.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class HarvesterUpgrader : public Harvester
|
||||
class Upgrader : public Worker
|
||||
{
|
||||
public:
|
||||
HarvesterUpgrader(Screeps::Creep creep) : Harvester(creep) {}
|
||||
Upgrader(Screeps::Creep creep) : Worker(creep) {}
|
||||
|
||||
protected:
|
||||
void depositEnergy() override;
|
||||
@@ -1,18 +1,18 @@
|
||||
#ifndef DOUWCO_HIVEMIND_HARVESTER_HPP
|
||||
#define DOUWCO_HIVEMIND_HARVESTER_HPP
|
||||
|
||||
#include "Creeps/Creep.hpp"
|
||||
#include "Creeps/CreepBase.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Harvester : public Creep
|
||||
class Worker : public CreepBase
|
||||
{
|
||||
private:
|
||||
bool harvesting;
|
||||
|
||||
public:
|
||||
Harvester(Screeps::Creep crp);
|
||||
~Harvester() override;
|
||||
Worker(Screeps::Creep crp);
|
||||
~Worker() override;
|
||||
|
||||
void loop() override;
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Creeps/Creep.hpp"
|
||||
#include "Structures/Structure.hpp"
|
||||
#include "Creeps/CreepBase.hpp"
|
||||
#include "Structures/StructureBase.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Engine
|
||||
{
|
||||
private:
|
||||
std::vector<std::unique_ptr<Creep>> creeps;
|
||||
std::vector<std::unique_ptr<Structure>> structures;
|
||||
std::vector<std::unique_ptr<CreepBase>> creeps;
|
||||
std::vector<std::unique_ptr<StructureBase>> structures;
|
||||
|
||||
public:
|
||||
Engine();
|
||||
@@ -21,6 +21,7 @@ namespace DouwcoHivemind
|
||||
private:
|
||||
void ReadOutCreeps();
|
||||
void ReadOutStructures();
|
||||
void clearDeadCreepMemory();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef DOUWCO_HIVEMIND_ROOMS_HPP
|
||||
#define DOUWCO_HIVEMIND_ROOMS_HPP
|
||||
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Room
|
||||
{
|
||||
public:
|
||||
Room();
|
||||
void loop();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOUWCO_HIVEMIND_ROOMS_HPP
|
||||
@@ -3,18 +3,18 @@
|
||||
|
||||
#include <Screeps/StructureSpawn.hpp>
|
||||
|
||||
#include "Structures/Structure.hpp"
|
||||
#include "Structures/StructureBase.hpp"
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Spawn : public Structure
|
||||
class Spawn : public StructureBase
|
||||
{
|
||||
private:
|
||||
Screeps::StructureSpawn spawn;
|
||||
|
||||
public:
|
||||
Spawn(Screeps::StructureSpawn spwn) : spawn(spwn),
|
||||
Structure() {}
|
||||
StructureBase() {}
|
||||
~Spawn() {}
|
||||
|
||||
void loop() override;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
class Structure
|
||||
class StructureBase
|
||||
{
|
||||
public:
|
||||
virtual void loop(){}
|
||||
@@ -2,11 +2,11 @@
|
||||
#define DOUWCO_HIVEMIND_PATH_TOOL_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <Screeps/ReturnTypes.hpp>
|
||||
#include <Screeps/Room.hpp>
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
static std::vector<int> flattenPathSteps(const std::vector<Screeps::PathStep> &pathSteps)
|
||||
static std::vector<int> flattenPathSteps(const std::vector<Screeps::Room::PathStep> &pathSteps)
|
||||
{
|
||||
std::vector<int> flattened;
|
||||
for (const auto &step : pathSteps)
|
||||
@@ -20,12 +20,18 @@ namespace DouwcoHivemind
|
||||
return flattened;
|
||||
}
|
||||
|
||||
static std::vector<Screeps::PathStep> unflattenPathSteps(const std::vector<int> &flattened)
|
||||
static std::vector<Screeps::Room::PathStep> unflattenPathSteps(const std::vector<int> &flattened)
|
||||
{
|
||||
std::vector<Screeps::PathStep> pathSteps;
|
||||
std::vector<Screeps::Room::PathStep> pathSteps;
|
||||
for (size_t i = 0; i < flattened.size(); i += 5)
|
||||
{
|
||||
pathSteps.emplace_back(Screeps::PathStep(flattened[i], flattened[i + 1], flattened[i + 2], flattened[i + 3], flattened[i + 4]));
|
||||
Screeps::Room::PathStep step;
|
||||
step.x = flattened[i];
|
||||
step.y = flattened[i+1];
|
||||
step.dx = flattened[i+2];
|
||||
step.dy = flattened[i+3];
|
||||
step.direction = flattened[i+4];
|
||||
pathSteps.emplace_back(step);
|
||||
}
|
||||
return pathSteps;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user