1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/lib/bonuses/BonusSelector.cpp

89 lines
2.4 KiB
C++
Raw Normal View History

2023-04-30 21:55:04 +02:00
/*
* BonusSelector.cpp, part of VCMI engine
*
* 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
*
*/
#include "StdInc.h"
#include "BonusSelector.h"
VCMI_LIB_NAMESPACE_BEGIN
namespace Selector
{
DLL_LINKAGE CSelectFieldEqual<Bonus::BonusType> & type()
{
static CSelectFieldEqual<Bonus::BonusType> stype(&Bonus::type);
return stype;
}
DLL_LINKAGE CSelectFieldEqual<TBonusSubtype> & subtype()
{
static CSelectFieldEqual<TBonusSubtype> ssubtype(&Bonus::subtype);
return ssubtype;
}
DLL_LINKAGE CSelectFieldEqual<CAddInfo> & info()
{
static CSelectFieldEqual<CAddInfo> sinfo(&Bonus::additionalInfo);
return sinfo;
}
DLL_LINKAGE CSelectFieldEqual<Bonus::BonusSource> & sourceType()
{
static CSelectFieldEqual<Bonus::BonusSource> ssourceType(&Bonus::source);
return ssourceType;
}
DLL_LINKAGE CSelectFieldEqual<Bonus::BonusSource> & targetSourceType()
{
static CSelectFieldEqual<Bonus::BonusSource> ssourceType(&Bonus::targetSourceType);
return ssourceType;
}
DLL_LINKAGE CSelectFieldEqual<Bonus::LimitEffect> & effectRange()
{
static CSelectFieldEqual<Bonus::LimitEffect> seffectRange(&Bonus::effectRange);
return seffectRange;
}
DLL_LINKAGE CWillLastTurns turns;
DLL_LINKAGE CWillLastDays days;
CSelector DLL_LINKAGE typeSubtype(Bonus::BonusType Type, TBonusSubtype Subtype)
{
return type()(Type).And(subtype()(Subtype));
}
CSelector DLL_LINKAGE typeSubtypeInfo(Bonus::BonusType type, TBonusSubtype subtype, const CAddInfo & info)
{
return CSelectFieldEqual<Bonus::BonusType>(&Bonus::type)(type)
.And(CSelectFieldEqual<TBonusSubtype>(&Bonus::subtype)(subtype))
.And(CSelectFieldEqual<CAddInfo>(&Bonus::additionalInfo)(info));
}
CSelector DLL_LINKAGE source(Bonus::BonusSource source, ui32 sourceID)
{
return CSelectFieldEqual<Bonus::BonusSource>(&Bonus::source)(source)
.And(CSelectFieldEqual<ui32>(&Bonus::sid)(sourceID));
}
CSelector DLL_LINKAGE sourceTypeSel(Bonus::BonusSource source)
{
return CSelectFieldEqual<Bonus::BonusSource>(&Bonus::source)(source);
}
CSelector DLL_LINKAGE valueType(Bonus::ValueType valType)
{
return CSelectFieldEqual<Bonus::ValueType>(&Bonus::valType)(valType);
}
DLL_LINKAGE CSelector all([](const Bonus * b){return true;});
DLL_LINKAGE CSelector none([](const Bonus * b){return false;});
}
VCMI_LIB_NAMESPACE_END