mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Implemented configurable shrine
This commit is contained in:
@ -842,77 +842,6 @@ void CGArtifact::serializeJsonOptions(JsonSerializeFormat& handler)
|
||||
}
|
||||
}
|
||||
|
||||
void CGShrine::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
if(spell == SpellID::NONE)
|
||||
{
|
||||
logGlobal->error("Not initialized shrine visited!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!wasVisited(h->tempOwner))
|
||||
cb->setObjProperty(id, CGShrine::OBJPROP_VISITED, h->tempOwner.getNum());
|
||||
|
||||
InfoWindow iw;
|
||||
iw.type = EInfoWindowMode::AUTO;
|
||||
iw.player = h->getOwner();
|
||||
iw.text = visitText;
|
||||
iw.text.appendLocalString(EMetaText::SPELL_NAME,spell);
|
||||
iw.text.appendRawString(".");
|
||||
|
||||
if(!h->getArt(ArtifactPosition::SPELLBOOK))
|
||||
{
|
||||
iw.text.appendLocalString(EMetaText::ADVOB_TXT,131);
|
||||
}
|
||||
else if(h->spellbookContainsSpell(spell))//hero already knows the spell
|
||||
{
|
||||
iw.text.appendLocalString(EMetaText::ADVOB_TXT,174);
|
||||
}
|
||||
else if(spell.toSpell()->getLevel() > h->maxSpellLevel()) //it's third level spell and hero doesn't have wisdom
|
||||
{
|
||||
iw.text.appendLocalString(EMetaText::ADVOB_TXT,130);
|
||||
}
|
||||
else //give spell
|
||||
{
|
||||
std::set<SpellID> spells;
|
||||
spells.insert(spell);
|
||||
cb->changeSpells(h, true, spells);
|
||||
|
||||
iw.components.emplace_back(Component::EComponentType::SPELL, spell, 0, 0);
|
||||
}
|
||||
|
||||
cb->showInfoDialog(&iw);
|
||||
}
|
||||
|
||||
void CGShrine::initObj(CRandomGenerator & rand)
|
||||
{
|
||||
VLC->objtypeh->getHandlerFor(ID, subID)->configureObject(this, rand);
|
||||
}
|
||||
|
||||
std::string CGShrine::getHoverText(PlayerColor player) const
|
||||
{
|
||||
std::string hoverName = getObjectName();
|
||||
if(wasVisited(player))
|
||||
{
|
||||
hoverName += "\n" + VLC->generaltexth->allTexts[355]; // + (learn %s)
|
||||
boost::algorithm::replace_first(hoverName,"%s", spell.toSpell()->getNameTranslated());
|
||||
}
|
||||
return hoverName;
|
||||
}
|
||||
|
||||
std::string CGShrine::getHoverText(const CGHeroInstance * hero) const
|
||||
{
|
||||
std::string hoverName = getHoverText(hero->tempOwner);
|
||||
if(wasVisited(hero->tempOwner) && hero->spellbookContainsSpell(spell)) //know what spell there is and hero knows that spell
|
||||
hoverName += "\n\n" + VLC->generaltexth->allTexts[354]; // (Already learned)
|
||||
return hoverName;
|
||||
}
|
||||
|
||||
void CGShrine::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
{
|
||||
handler.serializeId("spell", spell, SpellID::NONE);
|
||||
}
|
||||
|
||||
void CGSignBottle::initObj(CRandomGenerator & rand)
|
||||
{
|
||||
//if no text is set than we pick random from the predefined ones
|
||||
|
Reference in New Issue
Block a user