RecruitHeroBehavior.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * RecruitHeroBehavior.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. #include "../AIUtility.h"
  12. #include "../Analyzers/DangerHitMapAnalyzer.h"
  13. #include "../Analyzers/HeroManager.h"
  14. #include "../Goals/CGoal.h"
  15. #include "lib/GameLibrary.h"
  16. namespace NK2AI
  17. {
  18. namespace Goals
  19. {
  20. struct RecruitHeroChoice
  21. {
  22. mutable float score = 0;
  23. mutable const CGHeroInstance * hero = nullptr;
  24. mutable const CGTownInstance * town = nullptr;
  25. mutable int closestThreat = 0;
  26. };
  27. class RecruitHeroBehavior : public CGoal<RecruitHeroBehavior>
  28. {
  29. public:
  30. RecruitHeroBehavior() : CGoal(RECRUIT_HERO_BEHAVIOR) {}
  31. ~RecruitHeroBehavior() override = default;
  32. TGoalVec decompose(const Nullkiller * aiNk) const override;
  33. std::string toString() const override;
  34. bool operator==(const RecruitHeroBehavior & other) const override
  35. {
  36. return true; // TODO: Mircea: How does that make sense?
  37. }
  38. static void calculateTreasureSources(
  39. const std::vector<const CGObjectInstance *> & nearbyObjects,
  40. const PlayerColor & playerID,
  41. const DangerHitMapAnalyzer & dangerHitMap,
  42. int & treasureSourcesCount,
  43. const CGTownInstance & town
  44. );
  45. static void calculateBestHero(
  46. const std::vector<const CGHeroInstance *> & availableHeroes,
  47. const HeroManager & heroManager,
  48. const RecruitHeroChoice & bestChoice,
  49. const CGTownInstance & town,
  50. uint8_t closestThreatTurn,
  51. float visitabilityRatio
  52. );
  53. static void calculateFinalDecision(
  54. const Nullkiller & aiNk,
  55. Goals::TGoalVec & tasks,
  56. const std::vector<const CGHeroInstance *> & ourHeroes,
  57. const RecruitHeroChoice & bestChoice,
  58. bool haveCapitol,
  59. int treasureSourcesCount
  60. );
  61. };
  62. }
  63. }