mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
vcmi: allow converting bonusParams to selector
This commit is contained in:
@@ -1998,6 +1998,22 @@ const JsonNode & BonusParams::toJson()
|
||||
return ret;
|
||||
};
|
||||
|
||||
CSelector BonusParams::toSelector()
|
||||
{
|
||||
assert(isConverted);
|
||||
if(subtypeRelevant && !subtypeStr.empty())
|
||||
JsonUtils::resolveIdentifier(subtype, toJson(), "subtype");
|
||||
|
||||
auto ret = Selector::type()(type);
|
||||
if(subtypeRelevant)
|
||||
ret = ret.And(Selector::subtype()(subtype));
|
||||
if(valueTypeRelevant)
|
||||
ret = ret.And(Selector::valueType(valueType));
|
||||
if(targetTypeRelevant)
|
||||
ret = ret.And(Selector::targetSourceType()(targetType));
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bonus::Bonus(Bonus::BonusDuration Duration, BonusType Type, BonusSource Src, si32 Val, ui32 ID, std::string Desc, si32 Subtype)
|
||||
: duration((ui16)Duration), type(Type), subtype(Subtype), source(Src), val(Val), sid(ID), description(Desc)
|
||||
{
|
||||
|
@@ -554,6 +554,7 @@ struct DLL_LINKAGE BonusParams {
|
||||
BonusParams(bool isConverted = true) : isConverted(isConverted) {};
|
||||
BonusParams(std::string deprecatedTypeStr, std::string deprecatedSubtypeStr = "", int deprecatedSubtype = 0);
|
||||
const JsonNode & toJson();
|
||||
CSelector toSelector();
|
||||
private:
|
||||
JsonNode ret;
|
||||
bool jsonCreated = false;
|
||||
|
Reference in New Issue
Block a user