1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/lib/bonuses/BonusSelector.cpp

97 lines
2.6 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 const CSelectFieldEqual<BonusType> & type()
2023-04-30 21:55:04 +02:00
{
static const CSelectFieldEqual<BonusType> stype(&Bonus::type);
2023-04-30 21:55:04 +02:00
return stype;
}
DLL_LINKAGE const CSelectFieldEqual<BonusSubtypeID> & subtype()
2023-04-30 21:55:04 +02:00
{
static const CSelectFieldEqual<BonusSubtypeID> ssubtype(&Bonus::subtype);
2023-04-30 21:55:04 +02:00
return ssubtype;
}
DLL_LINKAGE const CSelectFieldEqual<CAddInfo> & info()
2023-04-30 21:55:04 +02:00
{
static const CSelectFieldEqual<CAddInfo> sinfo(&Bonus::additionalInfo);
2023-04-30 21:55:04 +02:00
return sinfo;
}
DLL_LINKAGE const CSelectFieldEqual<BonusSource> & sourceType()
2023-04-30 21:55:04 +02:00
{
static const CSelectFieldEqual<BonusSource> ssourceType(&Bonus::source);
2023-04-30 21:55:04 +02:00
return ssourceType;
}
DLL_LINKAGE const CSelectFieldEqual<BonusSource> & targetSourceType()
2023-04-30 21:55:04 +02:00
{
static const CSelectFieldEqual<BonusSource> ssourceType(&Bonus::targetSourceType);
2023-04-30 21:55:04 +02:00
return ssourceType;
}
DLL_LINKAGE const CSelectFieldEqual<BonusLimitEffect> & effectRange()
2023-04-30 21:55:04 +02:00
{
static const CSelectFieldEqual<BonusLimitEffect> seffectRange(&Bonus::effectRange);
2023-04-30 21:55:04 +02:00
return seffectRange;
}
DLL_LINKAGE CWillLastTurns turns;
DLL_LINKAGE CWillLastDays days;
CSelector DLL_LINKAGE typeSubtype(BonusType Type, BonusSubtypeID Subtype)
2023-04-30 21:55:04 +02:00
{
return type()(Type).And(subtype()(Subtype));
}
CSelector DLL_LINKAGE typeSubtypeInfo(BonusType type, BonusSubtypeID subtype, const CAddInfo & info)
2023-04-30 21:55:04 +02:00
{
return CSelectFieldEqual<BonusType>(&Bonus::type)(type)
.And(CSelectFieldEqual<BonusSubtypeID>(&Bonus::subtype)(subtype))
2023-04-30 21:55:04 +02:00
.And(CSelectFieldEqual<CAddInfo>(&Bonus::additionalInfo)(info));
}
CSelector DLL_LINKAGE source(BonusSource source, BonusSourceID sourceID)
2023-04-30 21:55:04 +02:00
{
return CSelectFieldEqual<BonusSource>(&Bonus::source)(source)
.And(CSelectFieldEqual<BonusSourceID>(&Bonus::sid)(sourceID));
2023-04-30 21:55:04 +02:00
}
CSelector DLL_LINKAGE sourceTypeSel(BonusSource source)
2023-04-30 21:55:04 +02:00
{
return CSelectFieldEqual<BonusSource>(&Bonus::source)(source);
2023-04-30 21:55:04 +02:00
}
CSelector DLL_LINKAGE valueType(BonusValueType valType)
2023-04-30 21:55:04 +02:00
{
return CSelectFieldEqual<BonusValueType>(&Bonus::valType)(valType);
2023-04-30 21:55:04 +02:00
}
CSelector DLL_LINKAGE typeSubtypeValueType(BonusType Type, BonusSubtypeID Subtype, BonusValueType valType)
{
return type()(Type)
.And(subtype()(Subtype))
.And(valueType(valType));
}
2023-04-30 21:55:04 +02:00
DLL_LINKAGE CSelector all([](const Bonus * b){return true;});
DLL_LINKAGE CSelector none([](const Bonus * b){return false;});
}
VCMI_LIB_NAMESPACE_END