2023-04-30 18:13:55 +02:00
|
|
|
|
|
|
|
/*
|
2023-05-01 19:29:53 +02:00
|
|
|
* IBonusBearer.h, part of VCMI engine
|
2023-04-30 18:13:55 +02: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 19:29:53 +02:00
|
|
|
#include "Bonus.h"
|
2023-04-30 18:13:55 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class DLL_LINKAGE IBonusBearer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//new bonusing node interface
|
|
|
|
// * selector is predicate that tests if HeroBonus matches our criteria
|
|
|
|
// * root is node on which call was made (nullptr will be replaced with this)
|
|
|
|
//interface
|
|
|
|
IBonusBearer() = default;
|
|
|
|
virtual ~IBonusBearer() = default;
|
|
|
|
virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr, const std::string &cachingStr = "") const = 0;
|
|
|
|
int valOfBonuses(const CSelector &selector, const std::string &cachingStr = "") const;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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)
|
2023-05-05 19:39:57 +02: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-05 15:13:52 +02:00
|
|
|
int valOfBonuses(BonusType type, TBonusSubtype subtype) const; //subtype -> subtype of bonus;
|
|
|
|
bool hasBonusOfType(BonusType type, TBonusSubtype subtype) const;//determines if hero has a bonus of given type (and optionally subtype)
|
2023-10-10 17:05:18 +02:00
|
|
|
bool hasBonusFrom(BonusSource source, TBonusSourceID sourceID) const;
|
2023-04-30 18:13:55 +02:00
|
|
|
|
|
|
|
virtual int64_t getTreeVersion() const = 0;
|
|
|
|
};
|
|
|
|
|
2023-10-05 15:13:52 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|