2017-07-20 06:08:49 +02:00
|
|
|
/*
|
|
|
|
* mock_BonusBearer.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 "mock_BonusBearer.h"
|
|
|
|
|
|
|
|
BonusBearerMock::BonusBearerMock()
|
|
|
|
: treeVersion(1),
|
|
|
|
cachedLast(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BonusBearerMock::~BonusBearerMock() = default;
|
|
|
|
|
|
|
|
void BonusBearerMock::addNewBonus(const std::shared_ptr<Bonus> & b)
|
|
|
|
{
|
|
|
|
bonuses.push_back(b);
|
|
|
|
treeVersion++;
|
|
|
|
}
|
|
|
|
|
2020-10-01 07:55:41 +02:00
|
|
|
TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const CSelector & limit, const CBonusSystemNode * root, const std::string & cachingStr) const
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
if(cachedLast != treeVersion)
|
|
|
|
{
|
2018-03-27 09:54:58 +02:00
|
|
|
bonuses.stackBonuses();
|
2017-07-20 06:08:49 +02:00
|
|
|
cachedLast = treeVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ret = std::make_shared<BonusList>();
|
|
|
|
bonuses.getBonuses(*ret, selector, limit);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t BonusBearerMock::getTreeVersion() const
|
|
|
|
{
|
|
|
|
int64_t ret = treeVersion;
|
|
|
|
return ret << 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
|