1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Bonus Source ID now uses metaidentifier

This commit is contained in:
Ivan Savenko
2023-10-10 18:05:18 +03:00
parent 77facf9387
commit b394158dc9
85 changed files with 295 additions and 262 deletions

View File

@@ -121,23 +121,23 @@ BattleHex::EDir CStack::destShiftDir() const
}
}
std::vector<si32> CStack::activeSpells() const
std::vector<SpellID> CStack::activeSpells() const
{
std::vector<si32> ret;
std::vector<SpellID> ret;
std::stringstream cachingStr;
cachingStr << "!type_" << vstd::to_underlying(BonusType::NONE) << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT);
CSelector selector = Selector::sourceType()(BonusSource::SPELL_EFFECT)
.And(CSelector([](const Bonus * b)->bool
{
return b->type != BonusType::NONE && SpellID(b->sid).toSpell() && !SpellID(b->sid).toSpell()->isAdventure();
return b->type != BonusType::NONE && b->sid.as<SpellID>().toSpell() && !b->sid.as<SpellID>().toSpell()->isAdventure();
}));
TConstBonusListPtr spellEffects = getBonuses(selector, Selector::all, cachingStr.str());
for(const auto & it : *spellEffects)
{
if(!vstd::contains(ret, it->sid)) //do not duplicate spells with multiple effects
ret.push_back(it->sid);
if(!vstd::contains(ret, it->sid.as<SpellID>())) //do not duplicate spells with multiple effects
ret.push_back(it->sid.as<SpellID>());
}
return ret;