mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Do not give spells as reward if hero can't learn them
This commit is contained in:
parent
53fcd3ad26
commit
9e81c53547
@ -161,8 +161,14 @@ void Rewardable::Interface::grantRewardAfterLevelup(IGameCallback * cb, const Re
|
||||
|
||||
if(!info.reward.spells.empty())
|
||||
{
|
||||
std::set<SpellID> spellsToGive(info.reward.spells.begin(), info.reward.spells.end());
|
||||
cb->changeSpells(hero, true, spellsToGive);
|
||||
std::set<SpellID> spellsToGive;
|
||||
|
||||
for (auto const & spell : info.reward.spells)
|
||||
if (hero->canLearnSpell(spell.toEntity(VLC), true))
|
||||
spellsToGive.insert(spell);
|
||||
|
||||
if (!spellsToGive.empty())
|
||||
cb->changeSpells(hero, true, spellsToGive);
|
||||
}
|
||||
|
||||
if(!info.reward.creaturesChange.empty())
|
||||
|
@ -102,7 +102,8 @@ void Rewardable::Reward::loadComponents(std::vector<Component> & comps, const CG
|
||||
comps.emplace_back(ComponentType::ARTIFACT, entry);
|
||||
|
||||
for(const auto & entry : spells)
|
||||
comps.emplace_back(ComponentType::SPELL, entry);
|
||||
if (!h || h->canLearnSpell(entry.toEntity(VLC), true))
|
||||
comps.emplace_back(ComponentType::SPELL, entry);
|
||||
|
||||
for(const auto & entry : creatures)
|
||||
comps.emplace_back(ComponentType::CREATURE, entry.type->getId(), entry.count);
|
||||
|
Loading…
Reference in New Issue
Block a user