IBonusBearer.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 Bonus matches our criteria
  18. IBonusBearer() = default;
  19. virtual ~IBonusBearer() = default;
  20. virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const std::string &cachingStr = {}) const = 0;
  21. int valOfBonuses(const CSelector &selector, const std::string &cachingStr = {}, int baseValue = 0) const;
  22. bool hasBonus(const CSelector &selector, const std::string &cachingStr = {}) const;
  23. TConstBonusListPtr getBonuses(const CSelector &selector, const std::string &cachingStr = {}) const;
  24. std::shared_ptr<const Bonus> getBonus(const CSelector &selector) const; //returns any bonus visible on node that matches (or nullptr if none matches)
  25. //Optimized interface (with auto-caching)
  26. int applyBonuses(BonusType type, int baseValue) const; //subtype -> subtype of bonus;
  27. int valOfBonuses(BonusType type) const; //subtype -> subtype of bonus;
  28. bool hasBonusOfType(BonusType type) const;//determines if hero has a bonus of given type (and optionally subtype)
  29. int valOfBonuses(BonusType type, BonusSubtypeID subtype) const; //subtype -> subtype of bonus;
  30. bool hasBonusOfType(BonusType type, BonusSubtypeID subtype) const;//determines if hero has a bonus of given type (and optionally subtype)
  31. bool hasBonusFrom(BonusSource source) const;
  32. bool hasBonusFrom(BonusSource source, BonusSourceID sourceID) const;
  33. TConstBonusListPtr getBonusesFrom(BonusSource source) const;
  34. TConstBonusListPtr getBonusesOfType(BonusType type) const;
  35. TConstBonusListPtr getBonusesOfType(BonusType type, BonusSubtypeID subtype) const;
  36. virtual int32_t getTreeVersion() const = 0;
  37. };
  38. VCMI_LIB_NAMESPACE_END