1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Remove strange & unused double-selector logic

This commit is contained in:
Ivan Savenko
2025-06-24 12:06:23 +03:00
parent 2d24c28996
commit 1e3e2f665c
39 changed files with 71 additions and 85 deletions

View File

@ -133,11 +133,10 @@ SlotID StackWithBonuses::unitSlot() const
return slot;
}
TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const CSelector & limit,
const std::string & cachingStr) const
TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const std::string & cachingStr) const
{
auto ret = std::make_shared<BonusList>();
TConstBonusListPtr originalList = origBearer->getAllBonuses(selector, limit, cachingStr);
TConstBonusListPtr originalList = origBearer->getAllBonuses(selector, cachingStr);
vstd::copy_if(*originalList, std::back_inserter(*ret), [this](const std::shared_ptr<Bonus> & b)
{
@ -147,7 +146,7 @@ TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, c
for(const Bonus & bonus : bonusesToUpdate)
{
if(selector(&bonus) && (!limit || limit(&bonus)))
if(selector(&bonus))
{
if(ret->getFirst(Selector::source(BonusSource::SPELL_EFFECT, bonus.sid).And(Selector::typeSubtype(bonus.type, bonus.subtype))))
{
@ -164,7 +163,7 @@ TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, c
for(auto & bonus : bonusesToAdd)
{
auto b = std::make_shared<Bonus>(bonus);
if(selector(b.get()) && (!limit || !limit(b.get())))
if(selector(b.get()))
ret->push_back(b);
}
//TODO limiters?

View File

@ -90,8 +90,7 @@ public:
SlotID unitSlot() const override;
///IBonusBearer
TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit,
const std::string & cachingStr = "") const override;
TConstBonusListPtr getAllBonuses(const CSelector & selector, const std::string & cachingStr = "") const override;
int32_t getTreeVersion() const override;

View File

@ -290,7 +290,7 @@ double getArtifactBonusRelevance(const CGHeroInstance * hero, const std::shared_
for (const auto & slot : hero->Slots())
{
const auto allBonuses = slot.second->getAllBonuses(Selector::all, Selector::all);
const auto allBonuses = slot.second->getAllBonuses(Selector::all);
BonusLimitationContext context = {*bonus, *slot.second, *allBonuses, stillUndecided};
uint64_t unitStrength = slot.second->getPower();

View File

@ -440,14 +440,14 @@ void ClientCommandManager::handleBonusesCommand(std::istringstream & singleWordB
return ss.str();
};
printCommandMessage("Bonuses of " + GAME->interface()->localState->getCurrentArmy()->getObjectName() + "\n");
printCommandMessage(format(*GAME->interface()->localState->getCurrentArmy()->getAllBonuses(Selector::all, Selector::all)) + "\n");
printCommandMessage(format(*GAME->interface()->localState->getCurrentArmy()->getAllBonuses(Selector::all)) + "\n");
printCommandMessage("\nInherited bonuses:\n");
TCNodes parents;
GAME->interface()->localState->getCurrentArmy()->getParents(parents);
for(const CBonusSystemNode *parent : parents)
{
printCommandMessage(std::string("\nBonuses from ") + typeid(*parent).name() + "\n" + format(*parent->getAllBonuses(Selector::all, Selector::all)) + "\n");
printCommandMessage(std::string("\nBonuses from ") + typeid(*parent).name() + "\n" + format(*parent->getAllBonuses(Selector::all)) + "\n");
}
}

View File

@ -805,7 +805,7 @@ void BattleStacksController::removeExpiredColorFilters()
{
if (!filter.persistent)
{
if (filter.source && !filter.target->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(filter.source->id)), Selector::all))
if (filter.source && !filter.target->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(filter.source->id))))
return true;
if (filter.effectColor == Colors::TRANSPARENCY && filter.transparency == 255)
return true;

View File

@ -848,7 +848,7 @@ void CStackWindow::init()
void CStackWindow::initBonusesList()
{
BonusList receivedBonuses = *info->stackNode->getBonuses(CSelector(Bonus::Permanent), Selector::all);
BonusList receivedBonuses = *info->stackNode->getBonuses(CSelector(Bonus::Permanent));
BonusList abilities = info->creature->getExportedBonusList();
// remove all bonuses that are not propagated away

View File

@ -329,7 +329,7 @@ void CCreature::addBonus(int val, BonusType type, BonusSubtypeID subtype)
BonusList & exported = getExportedBonusList();
BonusList existing;
exported.getBonuses(existing, selector, Selector::all);
exported.getBonuses(existing, selector);
if(existing.empty())
{

View File

@ -134,7 +134,7 @@ std::vector<SpellID> CStack::activeSpells() const
return b->type != BonusType::NONE && b->sid.as<SpellID>().toSpell() && !b->sid.as<SpellID>().toSpell()->isAdventure();
}));
TConstBonusListPtr spellEffects = getBonuses(selector, Selector::all, cachingStr.str());
TConstBonusListPtr spellEffects = getBonuses(selector, cachingStr.str());
for(const auto & it : *spellEffects)
{
if(!vstd::contains(ret, it->sid.as<SpellID>())) //do not duplicate spells with multiple effects

View File

@ -1797,7 +1797,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(vstd::RNG & rand, const ba
std::stringstream cachingStr;
cachingStr << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << spellID.num;
if(subject->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(spellID)), Selector::all, cachingStr.str()))
if(subject->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(spellID)), cachingStr.str()))
continue;
auto spellPtr = spellID.toSpell();

View File

@ -495,7 +495,7 @@ bool CUnitState::isGhost() const
bool CUnitState::isFrozen() const
{
return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::STONE_GAZE))), Selector::all);
return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::STONE_GAZE))));
}
bool CUnitState::isValidTarget(bool allowDead) const
@ -948,9 +948,9 @@ CUnitStateDetached::CUnitStateDetached(const IUnitInfo * unit_, const IBonusBear
{
}
TConstBonusListPtr CUnitStateDetached::getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr) const
TConstBonusListPtr CUnitStateDetached::getAllBonuses(const CSelector & selector, const std::string & cachingStr) const
{
return bonus->getAllBonuses(selector, limit, cachingStr);
return bonus->getAllBonuses(selector, cachingStr);
}
int32_t CUnitStateDetached::getTreeVersion() const

View File

@ -278,7 +278,7 @@ public:
CUnitStateDetached & operator= (const CUnitState & other);
TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr = "") const override;
TConstBonusListPtr getAllBonuses(const CSelector & selector, const std::string & cachingStr = "") const override;
int32_t getTreeVersion() const override;

View File

@ -523,7 +523,7 @@ int DamageCalculator::battleBonusValue(const IBonusBearer * bearer, const CSelec
: Selector::effectRange()(BonusLimitEffect::ONLY_MELEE_FIGHT);
//any regular bonuses or just ones for melee/ranged
return bearer->getBonuses(selector, noLimit.Or(limitMatches))->totalValue();
return bearer->getBonuses(selector)->valOfBonuses(noLimit.Or(limitMatches));
};
DamageEstimation DamageCalculator::calculateDmgRange() const

View File

@ -172,11 +172,11 @@ std::shared_ptr<const Bonus> BonusList::getFirst(const CSelector &selector) cons
return nullptr;
}
void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSelector &limit) const
void BonusList::getBonuses(BonusList & out, const CSelector &selector) const
{
for(const auto & b : bonuses)
{
if(selector(b.get()) && (!limit || ((bool)limit && limit(b.get()))))
if(selector(b.get()))
out.push_back(b);
}
}
@ -190,8 +190,7 @@ void BonusList::getAllBonuses(BonusList &out) const
int BonusList::valOfBonuses(const CSelector &select, int baseValue) const
{
BonusList ret;
CSelector limit = nullptr;
getBonuses(ret, select, limit);
getBonuses(ret, select);
return ret.totalValue(baseValue);
}

View File

@ -54,7 +54,7 @@ public:
// BonusList functions
void stackBonuses();
int totalValue(int baseValue = 0) const;
void getBonuses(BonusList &out, const CSelector &selector, const CSelector &limit = nullptr) const;
void getBonuses(BonusList &out, const CSelector &selector) const;
void getAllBonuses(BonusList &out) const;
//special find functions

View File

@ -80,7 +80,7 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out) const
}
}
TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr) const
TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, const std::string &cachingStr) const
{
if (cachingEnabled)
{
@ -103,7 +103,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
{
// Cached bonuses are up-to-date - use shared/read access and compute results
std::shared_lock lock(sync);
cachedBonuses.getBonuses(*ret, selector, limit);
cachedBonuses.getBonuses(*ret, selector);
}
else
{
@ -113,7 +113,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
if (cachedLast == nodeChanged)
{
// While our thread was waiting, another one have updated bonus tree. Use cached bonuses.
cachedBonuses.getBonuses(*ret, selector, limit);
cachedBonuses.getBonuses(*ret, selector);
}
else
{
@ -126,7 +126,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
limitBonuses(allBonuses, cachedBonuses);
cachedBonuses.stackBonuses();
cachedLast = nodeChanged;
cachedBonuses.getBonuses(*ret, selector, limit);
cachedBonuses.getBonuses(*ret, selector);
}
}
@ -147,11 +147,11 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
}
else
{
return getAllBonusesWithoutCaching(selector, limit);
return getAllBonusesWithoutCaching(selector);
}
}
TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit) const
TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector) const
{
auto ret = std::make_shared<BonusList>();
@ -160,7 +160,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector
BonusList afterLimiting;
getAllBonusesRec(beforeLimiting);
limitBonuses(beforeLimiting, afterLimiting);
afterLimiting.getBonuses(*ret, selector, limit);
afterLimiting.getBonuses(*ret, selector);
ret->stackBonuses();
return ret;
}
@ -300,7 +300,7 @@ void CBonusSystemNode::removeBonusesRecursive(const CSelector & s)
void CBonusSystemNode::reduceBonusDurations(const CSelector &s)
{
BonusList bl;
exportedBonuses.getBonuses(bl, s, Selector::all);
exportedBonuses.getBonuses(bl, s);
for(const auto & b : bl)
{
b->turnsRemain--;
@ -351,7 +351,7 @@ void CBonusSystemNode::removeBonus(const std::shared_ptr<Bonus>& b)
void CBonusSystemNode::removeBonuses(const CSelector & selector)
{
BonusList toRemove;
exportedBonuses.getBonuses(toRemove, selector, Selector::all);
exportedBonuses.getBonuses(toRemove, selector);
for(const auto & bonus : toRemove)
removeBonus(bonus);
}

View File

@ -70,7 +70,7 @@ private:
mutable std::shared_mutex sync;
void getAllBonusesRec(BonusList &out) const;
TConstBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit) const;
TConstBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector) const;
std::shared_ptr<Bonus> getUpdatedBonus(const std::shared_ptr<Bonus> & b, const TUpdaterPtr & updater) const;
void limitBonuses(const BonusList &allBonuses, BonusList &out) const; //out will bo populed with bonuses that are not limited here
@ -101,7 +101,7 @@ public:
explicit CBonusSystemNode(ENodeTypes NodeType);
virtual ~CBonusSystemNode();
TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const override;
TConstBonusListPtr getAllBonuses(const CSelector &selector, const std::string &cachingStr = "") const override;
void getParents(TCNodes &out) const; //retrieves list of parent nodes (nodes to inherit bonuses from),
/// Returns first bonus matching selector

View File

@ -17,7 +17,7 @@ VCMI_LIB_NAMESPACE_BEGIN
int IBonusBearer::valOfBonuses(const CSelector &selector, const std::string &cachingStr, int baseValue) const
{
TConstBonusListPtr hlp = getAllBonuses(selector, nullptr, cachingStr);
TConstBonusListPtr hlp = getAllBonuses(selector, cachingStr);
return hlp->totalValue(baseValue);
}
@ -27,19 +27,9 @@ bool IBonusBearer::hasBonus(const CSelector &selector, const std::string &cachin
return !getBonuses(selector, cachingStr)->empty();
}
bool IBonusBearer::hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr) const
{
return !getBonuses(selector, limit, cachingStr)->empty();
}
TConstBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const std::string &cachingStr) const
{
return getAllBonuses(selector, nullptr, cachingStr);
}
TConstBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr) const
{
return getAllBonuses(selector, limit, cachingStr);
return getAllBonuses(selector, cachingStr);
}
TConstBonusListPtr IBonusBearer::getBonusesFrom(BonusSource source) const
@ -120,7 +110,7 @@ bool IBonusBearer::hasBonusFrom(BonusSource source) const
std::shared_ptr<const Bonus> IBonusBearer::getBonus(const CSelector &selector) const
{
auto bonuses = getAllBonuses(selector, Selector::all);
auto bonuses = getAllBonuses(selector);
return bonuses->getFirst(Selector::all);
}

View File

@ -20,11 +20,9 @@ public:
// * selector is predicate that tests if Bonus matches our criteria
IBonusBearer() = default;
virtual ~IBonusBearer() = default;
virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const = 0;
virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const std::string &cachingStr = {}) const = 0;
int valOfBonuses(const CSelector &selector, const std::string &cachingStr = {}, int baseValue = 0) const;
bool hasBonus(const CSelector &selector, const std::string &cachingStr = {}) const;
bool hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const;
TConstBonusListPtr getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const;
TConstBonusListPtr getBonuses(const CSelector &selector, const std::string &cachingStr = {}) const;
std::shared_ptr<const Bonus> getBonus(const CSelector &selector) const; //returns any bonus visible on node that matches (or nullptr if none matches)

View File

@ -317,7 +317,7 @@ bool DimensionDoorMechanics::canBeCastImpl(spells::Problem & problem, const IGam
std::stringstream cachingStr;
cachingStr << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << owner->id.num;
int castsAlreadyPerformedThisTurn = caster->getHeroCaster()->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(owner->id)), Selector::all, cachingStr.str())->size();
int castsAlreadyPerformedThisTurn = caster->getHeroCaster()->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(owner->id)), cachingStr.str())->size();
int castsLimit = owner->getLevelPower(schoolLevel);
bool isTournamentRulesLimitEnabled = cb->getSettings().getBoolean(EGameSettings::DIMENSION_DOOR_TOURNAMENT_RULES_LIMIT);

View File

@ -246,21 +246,22 @@ int BonusBearerProxy::getBonuses(lua_State * L)
if(hasRangeSelector)
{
auto rangeSelector = [](const Bonus * b)
{
return false;//TODO: BonusBearerProxy::getBonuses rangeSelector
};
//TODO: BonusBearerProxy::getBonuses rangeSelector
//auto rangeSelector = [](const Bonus * b)
//{
// return false;
//};
ret = object->getBonuses(selector, rangeSelector);
ret = object->getBonuses(selector);
}
else
{
ret = object->getBonuses(selector, Selector::all);
ret = object->getBonuses(selector);
}
}
else
{
ret = object->getBonuses(Selector::all, Selector::all);
ret = object->getBonuses(Selector::all);
}
S.clear();

View File

@ -83,13 +83,13 @@ public:
void redirectBonusesToFake()
{
ON_CALL(*this, getAllBonuses(_, _, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
ON_CALL(*this, getAllBonuses(_, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
ON_CALL(*this, getTreeVersion()).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getTreeVersion));
}
void expectAnyBonusSystemCall()
{
EXPECT_CALL(*this, getAllBonuses(_, _, _)).Times(AtLeast(0));
EXPECT_CALL(*this, getAllBonuses(_, _)).Times(AtLeast(0));
EXPECT_CALL(*this, getTreeVersion()).Times(AtLeast(0));
}

View File

@ -29,7 +29,7 @@ public:
void setDefaultExpectations()
{
EXPECT_CALL(mock, getAllBonuses(_, _, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
EXPECT_CALL(mock, getAllBonuses(_, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
EXPECT_CALL(mock, getTreeVersion()).WillRepeatedly(Return(1));
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, UNIT_HEALTH, BonusSourceID()));
@ -235,7 +235,7 @@ TEST_F(HealthTest, singleUnitStack)
//one Titan
EXPECT_CALL(mock, getAllBonuses(_, _, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
EXPECT_CALL(mock, getAllBonuses(_, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
EXPECT_CALL(mock, getTreeVersion()).WillRepeatedly(Return(1));
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 300, BonusSourceID()));

View File

@ -34,13 +34,13 @@ void UnitFake::makeDead()
void UnitFake::redirectBonusesToFake()
{
ON_CALL(*this, getAllBonuses(_, _, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
ON_CALL(*this, getAllBonuses(_, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
ON_CALL(*this, getTreeVersion()).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getTreeVersion));
}
void UnitFake::expectAnyBonusSystemCall()
{
EXPECT_CALL(*this, getAllBonuses(_, _, _)).Times(AtLeast(0));
EXPECT_CALL(*this, getAllBonuses(_, _)).Times(AtLeast(0));
EXPECT_CALL(*this, getTreeVersion()).Times(AtLeast(0));
}

View File

@ -25,7 +25,7 @@ void BonusBearerMock::addNewBonus(const std::shared_ptr<Bonus> & b)
treeVersion++;
}
TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr) const
TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const std::string & cachingStr) const
{
if(cachedLast != treeVersion)
{
@ -34,7 +34,7 @@ TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, co
}
auto ret = std::make_shared<BonusList>();
bonuses.getBonuses(*ret, selector, limit);
bonuses.getBonuses(*ret, selector);
return ret;
}

View File

@ -23,7 +23,7 @@ public:
void addNewBonus(const std::shared_ptr<Bonus> & b);
TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr = "") const override;
TConstBonusListPtr getAllBonuses(const CSelector & selector, const std::string & cachingStr = "") const override;
int32_t getTreeVersion() const override;
private:

View File

@ -15,7 +15,7 @@
class UnitMock : public battle::Unit
{
public:
MOCK_CONST_METHOD3(getAllBonuses, TConstBonusListPtr(const CSelector &, const CSelector &, const std::string &));
MOCK_CONST_METHOD2(getAllBonuses, TConstBonusListPtr(const CSelector &, const std::string &));
MOCK_CONST_METHOD0(getTreeVersion, int32_t());
MOCK_CONST_METHOD0(getCasterUnitId, int32_t());

View File

@ -33,7 +33,7 @@ public:
protected:
void SetUp() override
{
ON_CALL(actualCaster, getAllBonuses(_, _, _)).WillByDefault(Invoke(&casterBonuses, &BonusBearerMock::getAllBonuses));
ON_CALL(actualCaster, getAllBonuses(_, _)).WillByDefault(Invoke(&casterBonuses, &BonusBearerMock::getAllBonuses));
ON_CALL(actualCaster, getTreeVersion()).WillByDefault(Invoke(&casterBonuses, &BonusBearerMock::getTreeVersion));
}
@ -57,7 +57,7 @@ TEST_F(AbilityCasterTest, MagicAbilityAffectedByGenericBonus)
casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, BonusSourceID(), BonusSubtypeID(SpellSchool::ANY)));
EXPECT_CALL(actualCaster, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(actualCaster, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(actualCaster, getTreeVersion()).Times(AtLeast(0));
setupSubject(1);
@ -71,7 +71,7 @@ TEST_F(AbilityCasterTest, MagicAbilityIgnoresSchoolBonus)
casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
EXPECT_CALL(actualCaster, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(actualCaster, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(actualCaster, getTreeVersion()).Times(AtLeast(0));
setupSubject(1);

View File

@ -24,7 +24,7 @@ public:
void setDefaultExpectations()
{
EXPECT_CALL(mechanicsMock, isMagicalEffect()).WillRepeatedly(Return(true));
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
}

View File

@ -24,7 +24,7 @@ public:
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
EXPECT_CALL(mechanicsMock, getSpellIndex()).WillRepeatedly(Return(castSpell));
}

View File

@ -21,7 +21,7 @@ class BonusConditionTest : public TargetConditionItemTest
public:
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
}

View File

@ -21,7 +21,7 @@ class CreatureConditionTest : public TargetConditionItemTest
public:
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(0);
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(0);
EXPECT_CALL(unitMock, getTreeVersion()).Times(0);
}

View File

@ -23,7 +23,7 @@ public:
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
EXPECT_CALL(mechanicsMock, getSpell()).Times(AtLeast(1)).WillRepeatedly(Return(&spellMock));

View File

@ -23,7 +23,7 @@ public:
const int64_t EFFECT_VALUE = 101;
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(0);
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(0);
EXPECT_CALL(unitMock, getTreeVersion()).Times(0);
EXPECT_CALL(unitMock, getAvailableHealth()).WillOnce(Return(UNIT_HP));
EXPECT_CALL(mechanicsMock, getEffectValue()).WillOnce(Return(EFFECT_VALUE));

View File

@ -30,7 +30,7 @@ public:
{
ownerMatches = ::testing::get<0>(GetParam());
isMagicalEffect = ::testing::get<1>(GetParam());
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(0));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(0));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
EXPECT_CALL(mechanicsMock, isMagicalEffect()).Times(AtLeast(0)).WillRepeatedly(Return(isMagicalEffect));
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unitMock), Field(&boost::logic::tribool::value, boost::logic::tribool::false_value))).WillRepeatedly(Return(ownerMatches));

View File

@ -27,7 +27,7 @@ public:
isMagicalEffect = GetParam();
EXPECT_CALL(mechanicsMock, isMagicalEffect()).WillRepeatedly(Return(isMagicalEffect));
if(isMagicalEffect)
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
}

View File

@ -24,7 +24,7 @@ public:
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
EXPECT_CALL(mechanicsMock, getSpellIndex()).WillRepeatedly(Return(castSpell));
}

View File

@ -27,7 +27,7 @@ public:
isPositive = ::testing::get<0>(GetParam());
hasBonus = ::testing::get<1>(GetParam());
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(0));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(0));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
EXPECT_CALL(mechanicsMock, isPositiveSpell()).WillRepeatedly(Return(isPositive));
if(hasBonus)

View File

@ -21,7 +21,7 @@ class SpellEffectConditionTest : public TargetConditionItemTest
public:
void setDefaultExpectations()
{
EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
}

View File

@ -37,7 +37,7 @@ protected:
void SetUp() override
{
using namespace ::testing;
ON_CALL(unitMock, getAllBonuses(_, _, _)).WillByDefault(Invoke(&unitBonuses, &BonusBearerMock::getAllBonuses));
ON_CALL(unitMock, getAllBonuses(_, _)).WillByDefault(Invoke(&unitBonuses, &BonusBearerMock::getAllBonuses));
ON_CALL(unitMock, getTreeVersion()).WillByDefault(Invoke(&unitBonuses, &BonusBearerMock::getTreeVersion));
}
};