2
0

ArmyManager.h 2.1 KB

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