mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
02b5a5e830
Addresses several related problems: * Propagation / unpropagation of duplicate bonuses is inconsistent, causing bugs * Duplicate bonuses never stack, which is not always intended behaviour (e.g. multiple copies of resource generating artifacts) * Different bonuses always stack, which is not always intended behaviour (e.g. Angel + Archangel morale bonuses) This is addressed as follows: * Duplicate bonuses are never eliminated during propagation/inheritance. * Unpropagation eliminates only a single copy of duplicated bonus * Bonus receives a new field stacking that determines stacking behaviour: * * empty string = no stacking with duplicates (default) * * "ALWAYS" = stacks with duplicates & everything else * * some other value = no stacking with bonuses with same stacking value Also Morale/Luck window now hides non-stacking bonuses.
48 lines
991 B
C++
48 lines
991 B
C++
/*
|
|
* 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++;
|
|
}
|
|
|
|
const TBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const CSelector & limit, const CBonusSystemNode * root, const std::string & cachingStr) const
|
|
{
|
|
if(cachedLast != treeVersion)
|
|
{
|
|
bonuses.stackBonuses();
|
|
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;
|
|
}
|
|
|
|
|