mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Allow replacing war machine if hero has a different machine in the slot
This commit is contained in:
@@ -841,7 +841,7 @@ void CCastleBuildings::enterBlacksmith(BuildingID building, ArtifactID artifactI
|
|||||||
{
|
{
|
||||||
for(auto slot : art->getPossibleSlots().at(ArtBearer::HERO))
|
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;
|
possible = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2800,6 +2800,17 @@ bool CGameHandler::buyArtifact(ObjectInstanceID hid, ArtifactID aid)
|
|||||||
|
|
||||||
if(town->isWarMachineAvailable(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);
|
giveResource(hero->getOwner(),EGameResID::GOLD,-price);
|
||||||
return giveHeroNewArtifact(hero, art);
|
return giveHeroNewArtifact(hero, art);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user