1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Moved creature upgrade logic to CGObjectInstance inheritors

This commit is contained in:
Ivan Savenko
2023-06-06 19:19:30 +03:00
parent fc190b14bb
commit 2e7c382612
13 changed files with 91 additions and 50 deletions

View File

@@ -1715,4 +1715,18 @@ bool CGHeroInstance::isMissionCritical() const
return false;
}
void CGHeroInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &stack) const
{
TConstBonusListPtr lista = getBonuses(Selector::typeSubtype(BonusType::SPECIAL_UPGRADE, stack.type->getId()));
for(const auto & it : *lista)
{
auto nid = CreatureID(it->additionalInfo[0]);
if (nid != stack.type->getId()) //in very specific case the upgrade is available by default (?)
{
info.newID.push_back(nid);
info.cost.push_back(nid.toCreature()->getFullRecruitCost() - stack.type->getFullRecruitCost());
}
}
}
VCMI_LIB_NAMESPACE_END