IBonusBearer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * IBonusBearer.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 "Bonus.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class DLL_LINKAGE IBonusBearer
  14. {
  15. public:
  16. //new bonusing node interface
  17. // * selector is predicate that tests if HeroBonus matches our criteria
  18. // * root is node on which call was made (nullptr will be replaced with this)
  19. //interface
  20. IBonusBearer() = default;
  21. virtual ~IBonusBearer() = default;
  22. virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const = 0;
  23. int valOfBonuses(const CSelector &selector, const std::string &cachingStr = "") const;
  24. bool hasBonus(const CSelector &selector, const std::string &cachingStr = "") const;
  25. bool hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const;
  26. TConstBonusListPtr getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const;
  27. TConstBonusListPtr getBonuses(const CSelector &selector, const std::string &cachingStr = "") const;
  28. std::shared_ptr<const Bonus> getBonus(const CSelector &selector) const; //returns any bonus visible on node that matches (or nullptr if none matches)
  29. //Optimized interface (with auto-caching)
  30. int valOfBonuses(BonusType type) const; //subtype -> subtype of bonus;
  31. bool hasBonusOfType(BonusType type) const;//determines if hero has a bonus of given type (and optionally subtype)
  32. int valOfBonuses(BonusType type, BonusSubtypeID subtype) const; //subtype -> subtype of bonus;
  33. bool hasBonusOfType(BonusType type, BonusSubtypeID subtype) const;//determines if hero has a bonus of given type (and optionally subtype)
  34. bool hasBonusFrom(BonusSource source, BonusSourceID sourceID) const;
  35. virtual int64_t getTreeVersion() const = 0;
  36. };
  37. VCMI_LIB_NAMESPACE_END