mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Replaced public artType member of ArtifactInstance with getter
This commit is contained in:
@@ -20,12 +20,12 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
void CCombinedArtifactInstance::addPart(CArtifactInstance * art, const ArtifactPosition & slot)
|
||||
{
|
||||
auto artInst = static_cast<CArtifactInstance*>(this);
|
||||
assert(vstd::contains_if(artInst->artType->getConstituents(),
|
||||
assert(vstd::contains_if(artInst->getType()->getConstituents(),
|
||||
[=](const CArtifact * partType)
|
||||
{
|
||||
return partType->getId() == art->getTypeId();
|
||||
}));
|
||||
assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->artType);
|
||||
assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->getType());
|
||||
partsInfo.emplace_back(art, slot);
|
||||
artInst->attachTo(*art);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ void CGrowingArtifactInstance::growingUp()
|
||||
{
|
||||
auto artInst = static_cast<CArtifactInstance*>(this);
|
||||
|
||||
if(artInst->artType->isGrowing())
|
||||
if(artInst->getType()->isGrowing())
|
||||
{
|
||||
|
||||
auto bonus = std::make_shared<Bonus>();
|
||||
@@ -86,7 +86,7 @@ void CGrowingArtifactInstance::growingUp()
|
||||
bonus->duration = BonusDuration::COMMANDER_KILLED;
|
||||
artInst->accumulateBonus(bonus);
|
||||
|
||||
for(const auto & bonus : artInst->artType->getBonusesPerLevel())
|
||||
for(const auto & bonus : artInst->getType()->getBonusesPerLevel())
|
||||
{
|
||||
// Every n levels
|
||||
if(artInst->valOfBonuses(BonusType::LEVEL_COUNTER) % bonus.first == 0)
|
||||
@@ -94,7 +94,7 @@ void CGrowingArtifactInstance::growingUp()
|
||||
artInst->accumulateBonus(std::make_shared<Bonus>(bonus.second));
|
||||
}
|
||||
}
|
||||
for(const auto & bonus : artInst->artType->getThresholdBonuses())
|
||||
for(const auto & bonus : artInst->getType()->getThresholdBonuses())
|
||||
{
|
||||
// At n level
|
||||
if(artInst->valOfBonuses(BonusType::LEVEL_COUNTER) == bonus.first)
|
||||
@@ -125,18 +125,23 @@ CArtifactInstance::CArtifactInstance()
|
||||
|
||||
void CArtifactInstance::setType(const CArtifact * art)
|
||||
{
|
||||
artType = art;
|
||||
artTypeID = art->getId();
|
||||
attachToSource(*art);
|
||||
}
|
||||
|
||||
std::string CArtifactInstance::nodeName() const
|
||||
{
|
||||
return "Artifact instance of " + (artType ? artType->getJsonKey() : std::string("uninitialized")) + " type";
|
||||
return "Artifact instance of " + (getType() ? getType()->getJsonKey() : std::string("uninitialized")) + " type";
|
||||
}
|
||||
|
||||
ArtifactID CArtifactInstance::getTypeId() const
|
||||
{
|
||||
return artType->getId();
|
||||
return artTypeID;
|
||||
}
|
||||
|
||||
const CArtifact * CArtifactInstance::getType() const
|
||||
{
|
||||
return artTypeID.toArtifact();
|
||||
}
|
||||
|
||||
ArtifactInstanceID CArtifactInstance::getId() const
|
||||
@@ -151,22 +156,22 @@ void CArtifactInstance::setId(ArtifactInstanceID id)
|
||||
|
||||
bool CArtifactInstance::canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot, bool assumeDestRemoved) const
|
||||
{
|
||||
return artType->canBePutAt(artSet, slot, assumeDestRemoved);
|
||||
return getType()->canBePutAt(artSet, slot, assumeDestRemoved);
|
||||
}
|
||||
|
||||
bool CArtifactInstance::isCombined() const
|
||||
{
|
||||
return artType->isCombined();
|
||||
return getType()->isCombined();
|
||||
}
|
||||
|
||||
bool CArtifactInstance::isScroll() const
|
||||
{
|
||||
return artType->isScroll();
|
||||
return getType()->isScroll();
|
||||
}
|
||||
|
||||
void CArtifactInstance::deserializationFix()
|
||||
{
|
||||
setType(artType);
|
||||
setType(artTypeID.toArtifact());
|
||||
for(PartInfo & part : partsInfo)
|
||||
attachTo(*part.art);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user