Miner not working properly but implementation is close.

This commit is contained in:
2026-06-22 23:30:49 +02:00
parent 50e8c81cf0
commit 6fcf742cfa
13 changed files with 391 additions and 321 deletions

View File

@@ -3,47 +3,35 @@
#include <Screeps/Creep.hpp>
namespace Screeps{
class RoomPosition;
class RoomObject;
class PathStep;
}
namespace Screeps {
class RoomPosition;
class RoomObject;
class PathStep;
} // namespace Screeps
namespace DouwcoHivemind
{
enum CreepRole
{
UNEMPLOYED,
SUPPLIER,
UPGRADER,
BUILDER,
MAINTAINER
};
namespace DouwcoHivemind {
enum CreepRole { UNEMPLOYED, SUPPLIER, UPGRADER, BUILDER, MAINTAINER, MINER };
class CreepBase
{
public:
CreepRole role;
std::string target_id;
class CreepBase {
public:
CreepRole role;
std::string target_id;
protected:
Screeps::Creep creep;
JSON memory;
protected:
Screeps::Creep creep;
JSON memory;
public:
CreepBase(Screeps::Creep crp);
virtual ~CreepBase();
virtual void loop() {}
public:
CreepBase(Screeps::Creep crp);
virtual ~CreepBase();
virtual void loop() {}
bool isNearTo(const Screeps::RoomPosition &pos, int dist);
bool isNearTo(const Screeps::RoomPosition &pos, int dist);
protected:
void moveToTarget(int dist = 1);
std::unique_ptr<Screeps::RoomObject> getRoomObjectTarget();
};
}
protected:
void moveToTarget(int dist = 1);
std::unique_ptr<Screeps::RoomObject> getRoomObjectTarget();
};
} // namespace DouwcoHivemind
#endif // DOUWCO_HIVEMIND_CREEPBASE_HPP

View File

@@ -0,0 +1,21 @@
#ifndef DOUWCO_HIVEMIND_MINER_HPP
#define DOUWCO_HIVEMIND_MINER_HPP
#include "Creeps/CreepBase.hpp"
#include <string>
namespace DouwcoHivemind
{
class Miner : public CreepBase
{
private:
bool arrivedAtContainer;
public:
Miner(Screeps::Creep crp);
~Miner() override;
void loop() override;
};
}
#endif // DOUWCO_HIVEMIND_MINER_HPP

View File

@@ -20,6 +20,7 @@ namespace DouwcoHivemind
virtual void depositEnergy(){}
private:
void getEnergy();
void harvestSource();
std::unique_ptr<Screeps::Source> getSourceTarget();
void searchSource();

View File

@@ -4,7 +4,7 @@
#include <vector>
#include "Creeps/CreepBase.hpp"
#include "Room.hpp"
#include "Entity/Room.hpp"
#include "Structures/StructureBase.hpp"
namespace DouwcoHivemind {