2018-07-26 12:06:55 +02:00
|
|
|
/*
|
|
|
|
* AIhelper.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/*
|
|
|
|
!!! Note: Include THIS file at the end of include list to avoid "undefined base class" error
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ResourceManager.h"
|
2018-07-29 18:27:21 +02:00
|
|
|
#include "BuildingManager.h"
|
2018-07-26 12:06:55 +02:00
|
|
|
|
|
|
|
class ResourceManager;
|
2018-07-29 18:27:21 +02:00
|
|
|
class BuildingManager;
|
|
|
|
|
2018-07-26 12:06:55 +02:00
|
|
|
|
|
|
|
//indirection interface for various modules
|
2018-07-29 18:27:21 +02:00
|
|
|
class DLL_EXPORT AIhelper : public IResourceManager, public IBuildingManager
|
2018-07-26 12:06:55 +02:00
|
|
|
{
|
|
|
|
friend class VCAI;
|
|
|
|
friend struct SetGlobalState; //mess?
|
|
|
|
|
|
|
|
//members are thread_specific. AIhelper is global
|
|
|
|
std::shared_ptr<ResourceManager> resourceManager;
|
2018-07-29 18:27:21 +02:00
|
|
|
std::shared_ptr<BuildingManager> buildingManager;
|
|
|
|
//TODO: vector<IAbstractManager>
|
2018-07-26 12:06:55 +02:00
|
|
|
std::shared_ptr<VCAI> ai;
|
|
|
|
public:
|
|
|
|
AIhelper();
|
|
|
|
~AIhelper();
|
|
|
|
|
2018-07-29 18:27:21 +02:00
|
|
|
//from ResourceManager
|
2018-07-26 12:06:55 +02:00
|
|
|
bool canAfford(const TResources & cost) const;
|
|
|
|
TResources reservedResources() const override;
|
|
|
|
TResources freeResources() const override;
|
|
|
|
TResource freeGold() const override;
|
|
|
|
TResources allResources() const override;
|
|
|
|
TResource allGold() const override;
|
|
|
|
|
|
|
|
Goals::TSubgoal whatToDo(TResources &res, Goals::TSubgoal goal) override;
|
|
|
|
Goals::TSubgoal whatToDo() const override; //peek highest-priority goal
|
2018-07-26 13:29:46 +02:00
|
|
|
bool containsObjective(Goals::TSubgoal goal) const;
|
2018-07-26 12:06:55 +02:00
|
|
|
bool hasTasksLeft() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool notifyGoalCompleted(Goals::TSubgoal goal);
|
|
|
|
|
|
|
|
void setCB(CPlayerSpecificInfoCallback * CB) override;
|
|
|
|
void setAI(VCAI * AI) override;
|
2018-07-29 18:27:21 +02:00
|
|
|
|
|
|
|
//from BuildingManager
|
|
|
|
public:
|
|
|
|
bool getBuildingOptions(const CGTownInstance * t) override;
|
|
|
|
boost::optional<PotentialBuilding> immediateBuilding() const override;
|
|
|
|
boost::optional<PotentialBuilding> expensiveBuilding() const override;
|
|
|
|
boost::optional<BuildingID> canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays = 7) const override;
|
2018-07-26 12:06:55 +02:00
|
|
|
};
|
|
|
|
|