RecruitHeroBehavior.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "lib/GameLibrary.h"
  12. #include "../Goals/CGoal.h"
  13. #include "../AIUtility.h"
  14. #include "../Analyzers/DangerHitMapAnalyzer.h"
  15. #include "../Analyzers/HeroManager.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()
  31. : CGoal(RECRUIT_HERO_BEHAVIOR)
  32. {
  33. }
  34. ~RecruitHeroBehavior() override = default;
  35. TGoalVec decompose(const Nullkiller * aiNk) const override;
  36. std::string toString() const override;
  37. bool operator==(const RecruitHeroBehavior & other) const override
  38. {
  39. return true; // TODO: Mircea: How does that make sense?
  40. }
  41. static void calculateTreasureSources(const std::vector<const CGObjectInstance *> & nearbyObjects,
  42. const PlayerColor & playerID,
  43. const DangerHitMapAnalyzer & dangerHitMap,
  44. int & treasureSourcesCount,
  45. const CGTownInstance * town);
  46. static void calculateBestHero(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. }
  54. }