mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Fixed #1213
This commit is contained in:
@ -120,11 +120,34 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
|||||||
InfoWindow iw;
|
InfoWindow iw;
|
||||||
iw.player = h->getOwner();
|
iw.player = h->getOwner();
|
||||||
|
|
||||||
|
//TODO: reuse this code for Scholar skill
|
||||||
if(spells.size())
|
if(spells.size())
|
||||||
{
|
{
|
||||||
std::set<SpellID> spellsToGive;
|
std::set<SpellID> spellsToGive;
|
||||||
|
|
||||||
|
std::vector<ConstTransitivePtr<CSpell> > * sp = &VLC->spellh->objects;
|
||||||
|
auto i = spells.cbegin();
|
||||||
|
while (i != spells.cend())
|
||||||
|
{
|
||||||
iw.components.clear();
|
iw.components.clear();
|
||||||
if (spells.size() > 1)
|
iw.text.clear();
|
||||||
|
spellsToGive.clear();
|
||||||
|
|
||||||
|
for (; i != spells.cend(); i++)
|
||||||
|
{
|
||||||
|
if ((*sp)[*i]->level <= h->getSecSkillLevel(SecondarySkill::WISDOM) + 2) //enough wisdom
|
||||||
|
{
|
||||||
|
iw.components.push_back(Component(Component::SPELL, *i, 0, 0));
|
||||||
|
spellsToGive.insert(*i);
|
||||||
|
}
|
||||||
|
if (spellsToGive.size() == 8) //display up to 8 spells at once
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!spellsToGive.empty())
|
||||||
|
{
|
||||||
|
if (spellsToGive.size() > 1)
|
||||||
{
|
{
|
||||||
iw.text.addTxt(MetaString::ADVOB_TXT, 188); //%s learns spells
|
iw.text.addTxt(MetaString::ADVOB_TXT, 188); //%s learns spells
|
||||||
}
|
}
|
||||||
@ -133,21 +156,11 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
|
|||||||
iw.text.addTxt(MetaString::ADVOB_TXT, 184); //%s learns a spell
|
iw.text.addTxt(MetaString::ADVOB_TXT, 184); //%s learns a spell
|
||||||
}
|
}
|
||||||
iw.text.addReplacement(h->name);
|
iw.text.addReplacement(h->name);
|
||||||
std::vector<ConstTransitivePtr<CSpell> > * sp = &VLC->spellh->objects;
|
|
||||||
for(auto i=spells.cbegin(); i != spells.cend(); i++)
|
|
||||||
{
|
|
||||||
if ((*sp)[*i]->level <= h->getSecSkillLevel(SecondarySkill::WISDOM) + 2) //enough wisdom
|
|
||||||
{
|
|
||||||
iw.components.push_back(Component(Component::SPELL,*i,0,0));
|
|
||||||
spellsToGive.insert(*i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!spellsToGive.empty())
|
|
||||||
{
|
|
||||||
cb->changeSpells(h, true, spellsToGive);
|
cb->changeSpells(h, true, spellsToGive);
|
||||||
cb->showInfoDialog(&iw);
|
cb->showInfoDialog(&iw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(manaDiff)
|
if(manaDiff)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user