ArmyManager.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * ArmyManager.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 "../../lib/GameConstants.h"
  13. #include "../../lib/VCMI_Lib.h"
  14. #include "../../lib/CTownHandler.h"
  15. #include "../../lib/CBuildingHandler.h"
  16. #include "VCAI.h"
  17. struct SlotInfo
  18. {
  19. const CCreature * creature;
  20. int count;
  21. uint64_t power;
  22. };
  23. class DLL_EXPORT IArmyManager //: public: IAbstractManager
  24. {
  25. public:
  26. virtual void init(CPlayerSpecificInfoCallback * CB) = 0;
  27. virtual void setAI(VCAI * AI) = 0;
  28. virtual bool canGetArmy(const CArmedInstance * target, const CArmedInstance * source) const = 0;
  29. virtual ui64 howManyReinforcementsCanBuy(const CCreatureSet * target, const CGDwelling * source) const = 0;
  30. virtual ui64 howManyReinforcementsCanGet(const CCreatureSet * target, const CCreatureSet * source) const = 0;
  31. virtual std::vector<SlotInfo> getBestArmy(const CCreatureSet * target, const CCreatureSet * source) const = 0;
  32. virtual std::vector<SlotInfo>::iterator getWeakestCreature(std::vector<SlotInfo> & army) const = 0;
  33. virtual std::vector<SlotInfo> getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const = 0;
  34. };
  35. class DLL_EXPORT ArmyManager : public IArmyManager
  36. {
  37. private:
  38. CPlayerSpecificInfoCallback * cb; //this is enough, but we downcast from CCallback
  39. VCAI * ai;
  40. public:
  41. void init(CPlayerSpecificInfoCallback * CB) override;
  42. void setAI(VCAI * AI) override;
  43. bool canGetArmy(const CArmedInstance * target, const CArmedInstance * source) const override;
  44. ui64 howManyReinforcementsCanBuy(const CCreatureSet * target, const CGDwelling * source) const override;
  45. ui64 howManyReinforcementsCanGet(const CCreatureSet * target, const CCreatureSet * source) const override;
  46. std::vector<SlotInfo> getBestArmy(const CCreatureSet * target, const CCreatureSet * source) const override;
  47. std::vector<SlotInfo>::iterator getWeakestCreature(std::vector<SlotInfo> & army) const override;
  48. std::vector<SlotInfo> getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const override;
  49. };