1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Backpack limit part2 (Pick up, Dig up, Object rewards)

This commit is contained in:
SoundSSGood
2023-03-18 22:58:39 +02:00
parent 96e8a1f21c
commit e23766280f
11 changed files with 108 additions and 63 deletions

View File

@@ -1300,9 +1300,12 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
InfoWindow iw;
iw.type = EInfoWindowMode::AUTO;
iw.player = h->tempOwner;
switch(ID)
if(ArtifactUtils::isPossibleToGetArt(h, storedArtifact->artType->getId()))
{
case Obj::ARTIFACT:
switch (ID)
{
case Obj::ARTIFACT:
{
iw.components.emplace_back(Component::EComponentType::ARTIFACT, subID, 0, 0);
if(message.length())
@@ -1311,7 +1314,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
iw.text.addTxt(MetaString::ART_EVNTS, subID);
}
break;
case Obj::SPELL_SCROLL:
case Obj::SPELL_SCROLL:
{
int spellID = storedArtifact->getGivenSpellID();
iw.components.emplace_back(Component::EComponentType::SPELL, spellID, 0, 0);
@@ -1319,11 +1322,16 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
iw.text << message;
else
{
iw.text.addTxt(MetaString::ADVOB_TXT,135);
iw.text.addTxt(MetaString::ADVOB_TXT, 135);
iw.text.addReplacement(MetaString::SPELL_NAME, spellID);
}
}
break;
}
}
else
{
iw.text << "no slots";
}
cb->showInfoDialog(&iw);
pick(h);
@@ -1368,8 +1376,8 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
void CGArtifact::pick(const CGHeroInstance * h) const
{
cb->giveHeroArtifact(h, storedArtifact, ArtifactPosition::FIRST_AVAILABLE);
cb->removeObject(this);
if(cb->giveHeroArtifact(h, storedArtifact, ArtifactPosition::FIRST_AVAILABLE))
cb->removeObject(this);
}
BattleField CGArtifact::getBattlefield() const