mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
Allow replacing war machine if hero has a different machine in the slot
This commit is contained in:
parent
8ef8ffa5c4
commit
a1a194d904
@ -841,7 +841,7 @@ void CCastleBuildings::enterBlacksmith(BuildingID building, ArtifactID artifactI
|
||||
{
|
||||
for(auto slot : art->getPossibleSlots().at(ArtBearer::HERO))
|
||||
{
|
||||
if(hero->getArt(slot) == nullptr)
|
||||
if(hero->getArt(slot) == nullptr || hero->getArt(slot)->getTypeId() != artifactID)
|
||||
{
|
||||
possible = true;
|
||||
break;
|
||||
|
@ -2800,6 +2800,17 @@ bool CGameHandler::buyArtifact(ObjectInstanceID hid, ArtifactID aid)
|
||||
|
||||
if(town->isWarMachineAvailable(aid))
|
||||
{
|
||||
bool hasFreeSlot = false;
|
||||
for(auto slot : art->getPossibleSlots().at(ArtBearer::HERO))
|
||||
if (hero->getArt(slot) == nullptr)
|
||||
hasFreeSlot = true;
|
||||
|
||||
if (!hasFreeSlot)
|
||||
{
|
||||
auto slot = art->getPossibleSlots().at(ArtBearer::HERO).front();
|
||||
removeArtifact(ArtifactLocation(hero->id, slot));
|
||||
}
|
||||
|
||||
giveResource(hero->getOwner(),EGameResID::GOLD,-price);
|
||||
return giveHeroNewArtifact(hero, art);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user