1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Merge pull request #4766 from SoundSSGood/fused-artifacts

Fused artifacts
This commit is contained in:
Ivan Savenko
2024-10-16 15:08:20 +03:00
committed by GitHub
14 changed files with 125 additions and 68 deletions

View File

@ -1805,6 +1805,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
assert(hero);
const auto transformedArt = hero->getArt(al.slot);
assert(transformedArt);
const auto builtArt = artId.toArtifact();
assert(vstd::contains_if(ArtifactUtils::assemblyPossibilities(hero, transformedArt->getTypeId()), [=](const CArtifact * art)->bool
{
return art->getId() == builtArt->getId();
@ -1816,14 +1817,11 @@ void AssembledArtifact::applyGs(CGameState *gs)
// Find slots for all involved artifacts
std::vector<ArtifactPosition> slotsInvolved;
CArtifactFittingSet artSet(*hero);
for(const auto constituent : builtArt->getConstituents())
{
ArtifactPosition slot;
if(transformedArt->getTypeId() == constituent->getId())
slot = transformedArtSlot;
else
slot = hero->getArtPos(constituent->getId(), false, false);
const auto slot = artSet.getArtPos(constituent->getId(), false, false);
artSet.lockSlot(slot);
assert(slot != ArtifactPosition::PRE_FIRST);
slotsInvolved.emplace_back(slot);
}
@ -1831,7 +1829,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
// Find a slot for combined artifact
al.slot = transformedArtSlot;
for(const auto slot : slotsInvolved)
for(const auto & slot : slotsInvolved)
{
if(ArtifactUtils::isSlotEquipment(transformedArtSlot))
{
@ -1854,15 +1852,18 @@ void AssembledArtifact::applyGs(CGameState *gs)
}
// Delete parts from hero
for(const auto slot : slotsInvolved)
for(const auto & slot : slotsInvolved)
{
const auto constituentInstance = hero->getArt(slot);
gs->map->removeArtifactInstance(*hero, slot);
if(ArtifactUtils::isSlotEquipment(al.slot) && slot != al.slot)
combinedArt->addPart(constituentInstance, slot);
else
combinedArt->addPart(constituentInstance, ArtifactPosition::PRE_FIRST);
if(!combinedArt->artType->isFused())
{
if(ArtifactUtils::isSlotEquipment(al.slot) && slot != al.slot)
combinedArt->addPart(constituentInstance, slot);
else
combinedArt->addPart(constituentInstance, ArtifactPosition::PRE_FIRST);
}
}
// Put new combined artifacts
@ -2482,10 +2483,7 @@ void SetBankConfiguration::applyGs(CGameState *gs)
const CArtifactInstance * ArtSlotInfo::getArt() const
{
if(locked)
{
logNetwork->warn("ArtifactLocation::getArt: This location is locked!");
return nullptr;
}
return artifact;
}