AIhelper.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #include "StdInc.h"
  11. #include "AIhelper.h"
  12. #include "ResourceManager.h"
  13. #include "BuildingManager.h"
  14. boost::thread_specific_ptr<AIhelper> ah;
  15. AIhelper::AIhelper()
  16. {
  17. resourceManager.reset(new ResourceManager());
  18. buildingManager.reset(new BuildingManager());
  19. //TODO: push to vector
  20. }
  21. AIhelper::~AIhelper()
  22. {
  23. }
  24. bool AIhelper::notifyGoalCompleted(Goals::TSubgoal goal)
  25. {
  26. return resourceManager->notifyGoalCompleted(goal);
  27. }
  28. void AIhelper::setCB(CPlayerSpecificInfoCallback * CB)
  29. {
  30. //TODO: for
  31. resourceManager->setCB(CB);
  32. buildingManager->setCB(CB);
  33. }
  34. void AIhelper::setAI(VCAI * AI)
  35. {
  36. //TODO: for loop
  37. resourceManager->setAI(AI);
  38. buildingManager->setAI(AI);
  39. }
  40. bool AIhelper::getBuildingOptions(const CGTownInstance * t)
  41. {
  42. return buildingManager->getBuildingOptions(t);
  43. }
  44. boost::optional<PotentialBuilding> AIhelper::immediateBuilding() const
  45. {
  46. return buildingManager->immediateBuilding();
  47. }
  48. boost::optional<PotentialBuilding> AIhelper::expensiveBuilding() const
  49. {
  50. return buildingManager->expensiveBuilding();
  51. }
  52. boost::optional<BuildingID> AIhelper::canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays) const
  53. {
  54. return buildingManager->canBuildAnyStructure(t, buildList, maxDays);
  55. }
  56. Goals::TSubgoal AIhelper::whatToDo(TResources & res, Goals::TSubgoal goal)
  57. {
  58. return resourceManager->whatToDo(res, goal);
  59. }
  60. Goals::TSubgoal AIhelper::whatToDo() const
  61. {
  62. return resourceManager->whatToDo();
  63. }
  64. bool AIhelper::containsObjective(Goals::TSubgoal goal) const
  65. {
  66. return resourceManager->containsObjective(goal);
  67. }
  68. bool AIhelper::hasTasksLeft() const
  69. {
  70. return resourceManager->hasTasksLeft();
  71. }
  72. bool AIhelper::canAfford(const TResources & cost) const
  73. {
  74. return resourceManager->canAfford(cost);
  75. }
  76. TResources AIhelper::reservedResources() const
  77. {
  78. return resourceManager->reservedResources();
  79. }
  80. TResources AIhelper::freeResources() const
  81. {
  82. return resourceManager->freeResources();
  83. }
  84. TResource AIhelper::freeGold() const
  85. {
  86. return resourceManager->freeGold();
  87. }
  88. TResources AIhelper::allResources() const
  89. {
  90. return resourceManager->allResources();
  91. }
  92. TResource AIhelper::allGold() const
  93. {
  94. return resourceManager->allGold();
  95. }