AIhelper.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * AIhelper.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. /*
  12. !!! Note: Include THIS file at the end of include list to avoid "undefined base class" error
  13. */
  14. #include "ResourceManager.h"
  15. #include "BuildingManager.h"
  16. class ResourceManager;
  17. class BuildingManager;
  18. //indirection interface for various modules
  19. class DLL_EXPORT AIhelper : public IResourceManager, public IBuildingManager
  20. {
  21. friend class VCAI;
  22. friend struct SetGlobalState; //mess?
  23. //members are thread_specific. AIhelper is global
  24. std::shared_ptr<ResourceManager> resourceManager;
  25. std::shared_ptr<BuildingManager> buildingManager;
  26. //TODO: vector<IAbstractManager>
  27. std::shared_ptr<VCAI> ai;
  28. public:
  29. AIhelper();
  30. ~AIhelper();
  31. //from ResourceManager
  32. bool canAfford(const TResources & cost) const;
  33. TResources reservedResources() const override;
  34. TResources freeResources() const override;
  35. TResource freeGold() const override;
  36. TResources allResources() const override;
  37. TResource allGold() const override;
  38. Goals::TSubgoal whatToDo(TResources &res, Goals::TSubgoal goal) override;
  39. Goals::TSubgoal whatToDo() const override; //peek highest-priority goal
  40. bool containsObjective(Goals::TSubgoal goal) const;
  41. bool hasTasksLeft() const override;
  42. private:
  43. bool notifyGoalCompleted(Goals::TSubgoal goal);
  44. void setCB(CPlayerSpecificInfoCallback * CB) override;
  45. void setAI(VCAI * AI) override;
  46. //from BuildingManager
  47. public:
  48. bool getBuildingOptions(const CGTownInstance * t) override;
  49. boost::optional<PotentialBuilding> immediateBuilding() const override;
  50. boost::optional<PotentialBuilding> expensiveBuilding() const override;
  51. boost::optional<BuildingID> canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays = 7) const override;
  52. };