AIhelper.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. AIhelper::AIhelper()
  13. {
  14. pathfindingManager.reset(new PathfindingManager());
  15. armyManager.reset(new ArmyManager());
  16. heroManager.reset(new HeroManager());
  17. }
  18. AIhelper::~AIhelper()
  19. {
  20. }
  21. void AIhelper::init(CPlayerSpecificInfoCallback * CB)
  22. {
  23. pathfindingManager->init(CB);
  24. armyManager->init(CB);
  25. heroManager->init(CB);
  26. }
  27. void AIhelper::setAI(VCAI * AI)
  28. {
  29. pathfindingManager->setAI(AI);
  30. armyManager->setAI(AI);
  31. heroManager->setAI(AI);
  32. }
  33. void AIhelper::update()
  34. {
  35. armyManager->update();
  36. heroManager->update();
  37. }
  38. std::vector<AIPath> AIhelper::getPathsToTile(const HeroPtr & hero, const int3 & tile) const
  39. {
  40. return pathfindingManager->getPathsToTile(hero, tile);
  41. }
  42. std::vector<AIPath> AIhelper::getPathsToTile(const int3 & tile) const
  43. {
  44. return pathfindingManager->getPathsToTile(tile);
  45. }
  46. void AIhelper::updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain)
  47. {
  48. pathfindingManager->updatePaths(heroes, useHeroChain);
  49. }
  50. uint64_t AIhelper::evaluateStackPower(const CCreature * creature, int count) const
  51. {
  52. return armyManager->evaluateStackPower(creature, count);
  53. }
  54. SlotInfo AIhelper::getTotalCreaturesAvailable(CreatureID creatureID) const
  55. {
  56. return armyManager->getTotalCreaturesAvailable(creatureID);
  57. }
  58. bool AIhelper::canGetArmy(const CArmedInstance * army, const CArmedInstance * source) const
  59. {
  60. return armyManager->canGetArmy(army, source);
  61. }
  62. ui64 AIhelper::howManyReinforcementsCanBuy(const CCreatureSet * h, const CGDwelling * t) const
  63. {
  64. return armyManager->howManyReinforcementsCanBuy(h, t);
  65. }
  66. ui64 AIhelper::howManyReinforcementsCanGet(const CCreatureSet * target, const CCreatureSet * source) const
  67. {
  68. return armyManager->howManyReinforcementsCanGet(target, source);
  69. }
  70. std::vector<SlotInfo> AIhelper::getBestArmy(const CCreatureSet * target, const CCreatureSet * source) const
  71. {
  72. return armyManager->getBestArmy(target, source);
  73. }
  74. std::vector<SlotInfo>::iterator AIhelper::getWeakestCreature(std::vector<SlotInfo> & army) const
  75. {
  76. return armyManager->getWeakestCreature(army);
  77. }
  78. std::vector<SlotInfo> AIhelper::getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const
  79. {
  80. return armyManager->getSortedSlots(target, source);
  81. }
  82. std::vector<creInfo> AIhelper::getArmyAvailableToBuy(const CCreatureSet * hero, const CGDwelling * dwelling) const
  83. {
  84. return armyManager->getArmyAvailableToBuy(hero, dwelling);
  85. }
  86. ArmyUpgradeInfo AIhelper::calculateCreateresUpgrade(
  87. const CCreatureSet * army,
  88. const CGObjectInstance * upgrader,
  89. const TResources & availableResources) const
  90. {
  91. return armyManager->calculateCreateresUpgrade(army, upgrader, availableResources);
  92. }
  93. int AIhelper::selectBestSkill(const HeroPtr & hero, const std::vector<SecondarySkill> & skills) const
  94. {
  95. return heroManager->selectBestSkill(hero, skills);
  96. }
  97. const std::map<HeroPtr, HeroRole> & AIhelper::getHeroRoles() const
  98. {
  99. return heroManager->getHeroRoles();
  100. }
  101. HeroRole AIhelper::getHeroRole(const HeroPtr & hero) const
  102. {
  103. return heroManager->getHeroRole(hero);
  104. }
  105. float AIhelper::evaluateSecSkill(SecondarySkill skill, const CGHeroInstance * hero) const
  106. {
  107. return heroManager->evaluateSecSkill(skill, hero);
  108. }
  109. float AIhelper::evaluateHero(const CGHeroInstance * hero) const
  110. {
  111. return heroManager->evaluateHero(hero);
  112. }