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
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
DLL_LINKAGE CSelectFieldEqual<BonusType> & type()
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
static CSelectFieldEqual<BonusType> stype(&Bonus::type);
|
2023-04-30 21:55:04 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
DLL_LINKAGE CSelectFieldEqual<BonusSource> & sourceType()
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
static CSelectFieldEqual<BonusSource> ssourceType(&Bonus::source);
|
2023-04-30 21:55:04 +02:00
|
|
|
return ssourceType;
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
DLL_LINKAGE CSelectFieldEqual<BonusSource> & targetSourceType()
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
static CSelectFieldEqual<BonusSource> ssourceType(&Bonus::targetSourceType);
|
2023-04-30 21:55:04 +02:00
|
|
|
return ssourceType;
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
DLL_LINKAGE CSelectFieldEqual<BonusLimitEffect> & effectRange()
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
static CSelectFieldEqual<BonusLimitEffect> seffectRange(&Bonus::effectRange);
|
2023-04-30 21:55:04 +02:00
|
|
|
return seffectRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
DLL_LINKAGE CWillLastTurns turns;
|
|
|
|
DLL_LINKAGE CWillLastDays days;
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
CSelector DLL_LINKAGE typeSubtype(BonusType Type, TBonusSubtype Subtype)
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
|
|
|
return type()(Type).And(subtype()(Subtype));
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
CSelector DLL_LINKAGE typeSubtypeInfo(BonusType type, TBonusSubtype subtype, const CAddInfo & info)
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
return CSelectFieldEqual<BonusType>(&Bonus::type)(type)
|
2023-04-30 21:55:04 +02:00
|
|
|
.And(CSelectFieldEqual<TBonusSubtype>(&Bonus::subtype)(subtype))
|
|
|
|
.And(CSelectFieldEqual<CAddInfo>(&Bonus::additionalInfo)(info));
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
CSelector DLL_LINKAGE source(BonusSource source, ui32 sourceID)
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
return CSelectFieldEqual<BonusSource>(&Bonus::source)(source)
|
2023-04-30 21:55:04 +02:00
|
|
|
.And(CSelectFieldEqual<ui32>(&Bonus::sid)(sourceID));
|
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
CSelector DLL_LINKAGE sourceTypeSel(BonusSource source)
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
return CSelectFieldEqual<BonusSource>(&Bonus::source)(source);
|
2023-04-30 21:55:04 +02:00
|
|
|
}
|
|
|
|
|
2023-05-01 00:20:01 +02:00
|
|
|
CSelector DLL_LINKAGE valueType(BonusValueType valType)
|
2023-04-30 21:55:04 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
return CSelectFieldEqual<BonusValueType>(&Bonus::valType)(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
|