1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Merge pull request #1635 from SoundSSGood/warmachine-buying-fix

warmachine buying fix
This commit is contained in:
Ivan Savenko 2023-03-09 15:52:41 +02:00 committed by GitHub
commit 11dc9228e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -804,10 +804,25 @@ void CCastleBuildings::enterBlacksmith(ArtifactID artifactID)
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % town->town->buildings.find(BuildingID::BLACKSMITH)->second->getNameTranslated()));
return;
}
auto art = artifactID.toArtifact(CGI->artifacts());
auto art = dynamic_cast<const CArtifact*>(artifactID.toArtifact(CGI->artifacts()));
int price = art->getPrice();
bool possible = LOCPLINT->cb->getResourceAmount(Res::GOLD) >= price && !hero->hasArt(artifactID);
bool possible = LOCPLINT->cb->getResourceAmount(Res::GOLD) >= price;
if(possible)
{
for(auto slot : art->possibleSlots.at(ArtBearer::HERO))
{
if(hero->getArt(slot) == nullptr)
{
possible = true;
break;
}
else
{
possible = false;
}
}
}
CreatureID cre = art->getWarMachine();
GH.pushIntT<CBlacksmithDialog>(possible, cre, artifactID, hero->id);
}