ArmyManager.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. virtual std::vector<creInfo> getArmyAvailableToBuy(const CCreatureSet * hero, const CGDwelling * dwelling) const = 0;
  35. };
  36. class DLL_EXPORT ArmyManager : public IArmyManager
  37. {
  38. private:
  39. CPlayerSpecificInfoCallback * cb; //this is enough, but we downcast from CCallback
  40. VCAI * ai;
  41. public:
  42. void init(CPlayerSpecificInfoCallback * CB) override;
  43. void setAI(VCAI * AI) override;
  44. bool canGetArmy(const CArmedInstance * target, const CArmedInstance * source) const override;
  45. ui64 howManyReinforcementsCanBuy(const CCreatureSet * target, const CGDwelling * source) const override;
  46. ui64 howManyReinforcementsCanGet(const CCreatureSet * target, const CCreatureSet * source) const override;
  47. std::vector<SlotInfo> getBestArmy(const CCreatureSet * target, const CCreatureSet * source) const override;
  48. std::vector<SlotInfo>::iterator getWeakestCreature(std::vector<SlotInfo> & army) const override;
  49. std::vector<SlotInfo> getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const override;
  50. std::vector<creInfo> getArmyAvailableToBuy(const CCreatureSet * hero, const CGDwelling * dwelling) const override;
  51. };