2023-04-30 19:13:55 +03:00
|
|
|
/*
|
2023-05-01 20:29:53 +03:00
|
|
|
* IBonusBearer.h, part of VCMI engine
|
2023-04-30 19:13:55 +03:00
|
|
|
*
|
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
|
*
|
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-05-01 20:29:53 +03:00
|
|
|
#include "Bonus.h"
|
2023-04-30 19:13:55 +03:00
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
class DLL_LINKAGE IBonusBearer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
//new bonusing node interface
|
2024-09-18 16:41:41 +02:00
|
|
|
// * selector is predicate that tests if Bonus matches our criteria
|
2023-04-30 19:13:55 +03:00
|
|
|
IBonusBearer() = default;
|
|
|
|
|
virtual ~IBonusBearer() = default;
|
2024-12-21 18:47:11 +00:00
|
|
|
virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const = 0;
|
2025-06-09 13:50:45 +03:00
|
|
|
int valOfBonuses(const CSelector &selector, const std::string &cachingStr = {}, int baseValue = 0) const;
|
2024-12-21 18:47:11 +00:00
|
|
|
bool hasBonus(const CSelector &selector, const std::string &cachingStr = {}) const;
|
|
|
|
|
bool hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const;
|
|
|
|
|
TConstBonusListPtr getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const;
|
|
|
|
|
TConstBonusListPtr getBonuses(const CSelector &selector, const std::string &cachingStr = {}) const;
|
2023-04-30 19:13:55 +03:00
|
|
|
|
|
|
|
|
std::shared_ptr<const Bonus> getBonus(const CSelector &selector) const; //returns any bonus visible on node that matches (or nullptr if none matches)
|
|
|
|
|
|
|
|
|
|
//Optimized interface (with auto-caching)
|
2025-06-09 13:50:45 +03:00
|
|
|
int applyBonuses(BonusType type, int baseValue) const; //subtype -> subtype of bonus;
|
2023-05-05 20:39:57 +03:00
|
|
|
int valOfBonuses(BonusType type) const; //subtype -> subtype of bonus;
|
|
|
|
|
bool hasBonusOfType(BonusType type) const;//determines if hero has a bonus of given type (and optionally subtype)
|
2023-10-21 14:50:42 +03:00
|
|
|
int valOfBonuses(BonusType type, BonusSubtypeID subtype) const; //subtype -> subtype of bonus;
|
|
|
|
|
bool hasBonusOfType(BonusType type, BonusSubtypeID subtype) const;//determines if hero has a bonus of given type (and optionally subtype)
|
2024-12-21 18:47:11 +00:00
|
|
|
bool hasBonusFrom(BonusSource source) const;
|
2023-10-21 14:50:42 +03:00
|
|
|
bool hasBonusFrom(BonusSource source, BonusSourceID sourceID) const;
|
2023-04-30 19:13:55 +03:00
|
|
|
|
2024-12-21 18:47:11 +00:00
|
|
|
TConstBonusListPtr getBonusesFrom(BonusSource source) const;
|
|
|
|
|
TConstBonusListPtr getBonusesOfType(BonusType type) const;
|
|
|
|
|
TConstBonusListPtr getBonusesOfType(BonusType type, BonusSubtypeID subtype) const;
|
|
|
|
|
|
2025-01-10 23:45:02 +00:00
|
|
|
virtual int32_t getTreeVersion() const = 0;
|
2023-04-30 19:13:55 +03:00
|
|
|
};
|
|
|
|
|
|
2023-10-05 16:13:52 +03:00
|
|
|
VCMI_LIB_NAMESPACE_END
|