1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-19 00:17:56 +02:00

ArtifactUtils::createArtifact ArtifactUtils::createNewArtifactInstance unified

This commit is contained in:
SoundSSGood
2024-09-04 16:25:30 +03:00
parent b06426ac43
commit 30fa2846aa
8 changed files with 53 additions and 70 deletions

View File

@ -1472,17 +1472,11 @@ void NewObject::applyGs(CGameState *gs)
void NewArtifact::applyGs(CGameState *gs)
{
assert(!vstd::contains(gs->map->artInstances, art));
assert(!art->getParentNodes().size());
assert(art->artType);
art->setType(art->artType);
if(art->isCombined())
{
for(const auto & part : art->artType->getConstituents())
art->addPart(ArtifactUtils::createNewArtifactInstance(part), ArtifactPosition::PRE_FIRST);
}
auto art = ArtifactUtils::createArtifact(id);
gs->map->addNewArtifactInstance(art);
PutArtifact pa(ArtifactLocation(artHolder, pos));
pa.art = art;
pa.applyGs(gs);
}
const CStackInstance * StackLocation::getStack()
@ -1700,6 +1694,7 @@ void PutArtifact::applyGs(CGameState *gs)
auto hero = gs->getHero(al.artHolder);
assert(hero);
assert(art && art->canBePutAt(hero, al.slot));
assert(ArtifactUtils::checkIfSlotValid(*hero, al.slot));
art->putAt(*hero, al.slot);
}